-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(model): Support OpenAI-Compatible RESTful APIs (#768)
- OpenAI-Compatible RESTful APIs - Fix aquila model error after new FastChat version - New unit test tools for model cluster
- Loading branch information
Showing
28 changed files
with
1,476 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
docs/locales/zh_CN/LC_MESSAGES/getting_started/install/cluster/openai.po
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 验证" | ||
|
Oops, something went wrong.