与Data APP对话的API
与APP对话
POST /api/v2/chat/completions
例子
Curl调用
DBGPT_API_KEY=dbgpt
APP_ID={YOUR_APP_ID}
curl -X POST "http://localhost:5670/api/v2/chat/completions" \
-H "Authorization: Bearer $DBGPT_API_KEY" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_app\", \"chat_param\": \"$APP_ID\"}"
Python SDK调用
from dbgpt.client import Client
DBGPT_API_KEY = "dbgpt"
APP_ID="{YOUR_APP_ID}"
client = Client(api_key=DBGPT_API_KEY)
async for data in client.chat_stream(
messages="Introduce AWEL",
model="chatgpt_proxyllm",
chat_mode="chat_app",
chat_param=APP_ID
):
print(data)
流式响应
data: {"id": "109bfc28-fe87-452c-8e1f-d4fe43283b7d", "created": 1710919480, "model": "chatgpt_proxyllm", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "```agent-plans\n[{\"name\": \"Introduce Awel\", \"num\": 2, \"status\": \"complete\", \"agent\": \"Human\", \"markdown\": \"```agent-messages\\n[{\\\"sender\\\": \\\"Summarizer\\\", \\\"receiver\\\": \\\"Human\\\", \\\"model\\\": \\\"chatgpt_proxyllm\\\", \\\"markdown\\\": \\\"Agentic Workflow Expression Language (AWEL) is a specialized language designed for developing large model applications with intelligent agent workflows. It offers flexibility and functionality, allowing developers to focus on business logic for LLMs applications without getting bogged down in model and environment details. AWEL uses a layered API design architecture, making it easier to work with. You can find examples and source code to get started with AWEL, and it supports various operators and environments. AWEL is a powerful tool for building native data applications through workflows and agents.\"}]\n```"}}]}
data: [DONE]
获取应用列表
GET /api/v2/serve/apps
Curl调用
DBGPT_API_KEY=dbgpt
curl -X GET 'http://localhost:5670/api/v2/serve/apps' -H "Authorization: Bearer $DBGPT_API_KEY"
Python SDK调用
from dbgpt.client import Client
from dbgpt.client.app import list_app
DBGPT_API_KEY = "dbgpt"
app_id = "{your_app_id}"
client = Client(api_key=DBGPT_API_KEY)
res = await list_app(client=client)
返回对象
参数 | 参数描述 | 备注 |
---|---|---|
app_code |
应用编号 | |
app_name |
应用名 | |
app_describe |
应用描述 | |
team_mode |
team mode | |
language |
语言 | |
team_context |
team context | |
user_code |
用户码 | |
sys_code |
系统码 | |
is_collected |
||
icon |
||
created_at |
||
updated_at |
||
details |
python { "app_code": "", "app_name": "", "agent_name": "", "node_id": "", "resources": "", "prompt_template": "", "llm_strategy": "", "llm_strategy_value": "", "create_at": "", "update_at": "" } |
获取应用详情
GET /api/v2/serve/apps/{app_id}
Curl调用
DBGPT_API_KEY=dbgpt
APP_ID={YOUR_APP_ID}
curl -X GET "http://localhost:5670/api/v2/serve/apps/$APP_ID" -H "Authorization: Bearer $DBGPT_API_KEY"
Python SDK调用
from dbgpt.client import Client
from dbgpt.client.app import get_app
DBGPT_API_KEY = "dbgpt"
app_id = "{your_app_id}"
client = Client(api_key=DBGPT_API_KEY)
res = await get_app(client=client, app_id=app_id)