DocAPI is a Python package that automatically generates API documentation using LLM.
Project description
[ English | 中文 ]
DocAPI is a Python package that uses LLM to automatically generate API documentation.
Features
-
The Flask framework supports automatic scanning of the routing structure of API services;
-
Supports a variety of domestic and foreign commercial and open source models;
-
Supports automatic document generation and partial document update;
-
Supports Chinese and English documents;
-
Supports web page deployment to display API documentation.
Installation
pip install docapi
or
pip install -U docapi -i https://pypi.org/simple
GitHub source code installation
pip install git+https://github.com/Shulin-Zhang/docapi
Usage
Method 1 (Recommended)
Automatically scan the routing structure. This is only valid for flask projects and must be used in the environment of api projects.
OpenAI:
export OPENAI_API_KEY=api_key
export OPENAI_API_MODEL=gpt-4o-mini
# Generate documents
docapi generate server.py --lang en
# Update documents
docapi update server.py --lang en
# Start web service
docapi serve
Qianwen, open source model:
export OPENAI_API_KEY=api_key
export OPENAI_API_BASE=api_base_url
export OPENAI_API_MODEL=model_name
# Generate documents
docapi generate server.py --lang en
# Update documents
docapi update server.py --lang en
# Start web service
docapi serve
Baidu Qianfan:
export QIANFAN_ACCESS_KEY=access_key
export QIANFAN_SECRET_KEY=secret_key
export QIANFAN_MODEL=ERNIE-3.5-8K
# Generate documents
docapi generate server.py --lang en
# Update documents
docapi update server.py --lang en
# Start web service
docapi serve
ZhipuAI:
export ZHIPUAI_API_KEY=api_key
export ZHIPUAI_MODEL=glm-4-flash
# Generate documents
docapi generate server.py
# Update documents
docapi update server.py
# Start web service
docapi serve
Method 2
Generate the configuration file
docapi init
Edit the config.yaml file
# API file list
api_files:
- 'flask_server.py'
- 'flask_api.py'
# OpenAI
openai_api_key: xxx
openai_base_url: 'http://ip:port/v1'
openai_model: 'qwen-plus'
# Azure OpenAI
azure_api_key: null
azure_endpoint: null
azure_api_version: null
azure_model: null
# Generate API documentation
docapi generate --doc_dir ./docs --lang zh --config config.yaml --lang en
# Update API documentation
docapi update --doc_dir ./docs --lang zh --config config.yaml --lang en
# Start the web service
docapi serve ./docs -h 127.0.0.1 -p 9000
Changelog
- [2024-11-17] Support Zhipu AI, Baidu Qianfan model, optimize document structure, and add javascript code examples.
Supported Models
-
OpenAI
-
AzureOpenAI
-
Tongyi Qianwen
-
Zhipu AI
-
Baidu Qianfan
-
Open source model
Supported API Frameworks
- Flask
Automatic scanning is only valid for the Flask framework and is recommended for use on Flask services.
API Web Page
TODO
-
Supports large models such as Wenxin Yiyan and Zhipu AI. -
Supports automatic scanning of frameworks such as Django.
-
Supports online web page display of documents. -
Supports custom document templates.
-
Multithreading accelerates requests.
-
Import to postman.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file docapi-0.0.18.tar.gz
.
File metadata
- Download URL: docapi-0.0.18.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4be7d91b5a948e256b8f325cbefd6d8fb4522f07e6054ef46ba6a8eacbeaddf3 |
|
MD5 | 5670ec3edf5519685e01661ff0a679e3 |
|
BLAKE2b-256 | 4e369d83ae3c362dfeb158bdf31cc96b58439ff08031b3ae4dbfdae67ce6afe8 |
File details
Details for the file docapi-0.0.18-py3-none-any.whl
.
File metadata
- Download URL: docapi-0.0.18-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c52e19d5cbb472a04f1947a854d3b18f8de1c4443fffb8d4dcdc63f8fafa0def |
|
MD5 | 864150e23d87d07054fb0ef1642f5ffd |
|
BLAKE2b-256 | 9bfae598ef3433e5a068329fa807f9d11b7ef3cf4c52e903484fd3c04c4f2ffb |