Giter VIP home page Giter VIP logo

api-doc-gpt's Introduction

API Doc GPT

This is an AI tool that helps you discover your API documentation. It is based on the GPT-3.5 language model from OpenAI. You can use this with either directly connecting to a FastApi app or by passing in an openapi.json file.

Setup

Install the dependencies

pip install -r requirements.txt

How to use with FastApi

  1. Run your backend app
uvicorn main:app --reload
  1. Run the script
python api_master.py --openai-key <your-openai-key> --target <your-fastapi-app> --base-url <your-base-url>

How to use with openapi.json

python api_master.py --openai-key <your-openai-key> --openapi-json <openapi-json> --base-url <your-base-url>

Running example

python api_master.py --openai-key=<your-openai-key> --openapi-json=./example/openapi.json --base-url="https://petstore3.swagger.io/api/v3"

Enjoy interacting with your API documentation showcase

With GPT-4

This also works with GPT-4. You just need to pass parameter --model-name=gpt-4 while running the script.

How it works

This works by creating open api documentation from your fastapi app and then using the GPT-3.5 language model to analyze documentation for your API.

sequenceDiagram
    User-->>+Processor: Give me a list of items. I only need 5 of them
    Processor-->>+AI: PROMPT: Give me a list of items. I only need 5 of them
    AI-->>+Processor: CMD: GET /items?filter=5
    Processor-->>+AI: CMD_RESP: [{"name": "cucumber"}, {"name": "celery"}...]
    AI-->>+Processor: OUT: Items are cucumber, celery...
    Processor-->>+User: Items are cucumber, celery...
Loading

This also supports react. More detail can be found at: https://arxiv.org/abs/2210.03629

Constraints

  • Token size

api-doc-gpt's People

Contributors

egeucak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

api-doc-gpt's Issues

How to overcome token limit

Hi, thanks for this amazing work !

I'm getting this error:

"openai.error.InvalidRequestError: This model's maximum context length is 4097 tokens. However, your messages resulted in 43204 tokens. Please reduce the length of the messages."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.