Skip to content

Commit

Permalink
feat(model): Support OpenAI-Compatible RESTful APIs (#768)
Browse files Browse the repository at this point in the history
- OpenAI-Compatible RESTful APIs
- Fix aquila model error after new FastChat version
- New unit test tools for model cluster
  • Loading branch information
Aries-ckt authored Nov 3, 2023
2 parents c7cad04 + 9e08886 commit 7f5bd8d
Show file tree
Hide file tree
Showing 28 changed files with 1,476 additions and 238 deletions.
10 changes: 10 additions & 0 deletions docker/compose_examples/cluster-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ services:
restart: unless-stopped
networks:
- dbgptnet
api-server:
image: eosphorosai/dbgpt:latest
command: dbgpt start apiserver --controller_addr http://controller:8000
restart: unless-stopped
depends_on:
- controller
networks:
- dbgptnet
ports:
- 8100:8100/tcp
llm-worker:
image: eosphorosai/dbgpt:latest
command: dbgpt start worker --model_name vicuna-13b-v1.5 --model_path /app/models/vicuna-13b-v1.5 --port 8001 --controller_addr http://controller:8000
Expand Down
1 change: 1 addition & 0 deletions docs/getting_started/install/cluster/cluster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ By analyzing this information, we can identify performance bottlenecks in model

./vms/standalone.md
./vms/index.md
./openai.md
51 changes: 51 additions & 0 deletions docs/getting_started/install/cluster/openai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
OpenAI-Compatible RESTful APIs
==================================
(openai-apis-index)=

### Install Prepare

You must [deploy DB-GPT cluster](https://db-gpt.readthedocs.io/en/latest/getting_started/install/cluster/vms/index.html) first.

### Launch Model API Server

```bash
dbgpt start apiserver --controller_addr http://127.0.0.1:8000 --api_keys EMPTY
```
By default, the Model API Server starts on port 8100.

### Validate with cURL

#### List models

```bash
curl http://127.0.0.1:8100/api/v1/models \
-H "Authorization: Bearer EMPTY" \
-H "Content-Type: application/json"
```

#### Chat completions

```bash
curl http://127.0.0.1:8100/api/v1/chat/completions \
-H "Authorization: Bearer EMPTY" \
-H "Content-Type: application/json" \
-d '{"model": "vicuna-13b-v1.5", "messages": [{"role": "user", "content": "hello"}]}'
```

### Validate with OpenAI Official SDK

#### Chat completions

```python
import openai
openai.api_key = "EMPTY"
openai.api_base = "http://127.0.0.1:8100/api/v1"
model = "vicuna-13b-v1.5"

completion = openai.ChatCompletion.create(
model=model,
messages=[{"role": "user", "content": "hello"}]
)
# print the completion
print(completion.choices[0].message.content)
```
9 changes: 6 additions & 3 deletions docs/getting_started/install/llm/proxyllm/proxyllm.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ PROXY_SERVER_URL=https://api.openai.com/v1/chat/completions
#Azure
LLM_MODEL=chatgpt_proxyllm
OPENAI_API_TYPE=azure
PROXY_API_KEY={your-openai-sk}
PROXY_SERVER_URL=https://xx.openai.azure.com/v1/chat/completions
PROXY_API_KEY={your-azure-sk}
PROXY_API_BASE=https://{your domain}.openai.azure.com/
PROXY_API_TYPE=azure
PROXY_SERVER_URL=xxxx
PROXY_API_VERSION=2023-05-15
PROXYLLM_BACKEND=gpt-35-turbo
#Aliyun tongyi
LLM_MODEL=tongyi_proxyllm
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2023, csunny
# This file is distributed under the same license as the DB-GPT package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: DB-GPT 👏👏 0.4.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-02 21:09+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: zh_CN\n"
"Language-Team: zh_CN <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: ../../getting_started/install/cluster/openai.md:1
#: 01f4e2bf853341198633b367efec1522
msgid "OpenAI-Compatible RESTful APIs"
msgstr "OpenAI RESTful 兼容接口"

#: ../../getting_started/install/cluster/openai.md:5
#: d8717e42335e4027bf4e76b3d28768ee
msgid "Install Prepare"
msgstr "安装准备"

#: ../../getting_started/install/cluster/openai.md:7
#: 9a48d8ee116942468de4c6faf9a64758
msgid ""
"You must [deploy DB-GPT cluster](https://db-"
"gpt.readthedocs.io/en/latest/getting_started/install/cluster/vms/index.html)"
" first."
msgstr "你必须先部署 [DB-GPT 集群]"
"(https://db-gpt.readthedocs.io/projects/db-gpt-docs-zh-cn/zh-cn/latest/getting_started/install/cluster/vms/index.html)。"

#: ../../getting_started/install/cluster/openai.md:9
#: 7673a7121f004f7ca6b1a94a7e238fa3
msgid "Launch Model API Server"
msgstr "启动模型 API Server"

#: ../../getting_started/install/cluster/openai.md:14
#: 84a925c2cbcd4e4895a1d2d2fe8f720f
msgid "By default, the Model API Server starts on port 8100."
msgstr "默认情况下,模型 API Server 使用 8100 端口启动。"

#: ../../getting_started/install/cluster/openai.md:16
#: e53ed41977cd4721becd51eba05c6609
msgid "Validate with cURL"
msgstr "通过 cURL 验证"

#: ../../getting_started/install/cluster/openai.md:18
#: 7c883b410b5c4e53a256bf17c1ded80d
msgid "List models"
msgstr "列出模型"

#: ../../getting_started/install/cluster/openai.md:26
#: ../../getting_started/install/cluster/openai.md:37
#: 7cf0ed13f0754f149ec085cd6cf7a45a 990d5d5ed5d64ab49550e68495b9e7a0
msgid "Chat completions"
msgstr ""

#: ../../getting_started/install/cluster/openai.md:35
#: 81583edd22df44e091d18a0832278131
msgid "Validate with OpenAI Official SDK"
msgstr "通过 OpenAI 官方 SDK 验证"

Loading

0 comments on commit 7f5bd8d

Please sign in to comment.