与Data APP对话的API

与APP对话

  1. POST /api/v2/chat/completions

例子

Curl调用

  1. DBGPT_API_KEY=dbgpt
  2. APP_ID={YOUR_APP_ID}
  3. curl -X POST "http://localhost:5670/api/v2/chat/completions" \
  4. -H "Authorization: Bearer $DBGPT_API_KEY" \
  5. -H "accept: application/json" \
  6. -H "Content-Type: application/json" \
  7. -d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_app\", \"chat_param\": \"$APP_ID\"}"

Python SDK调用

  1. from dbgpt.client import Client
  2. DBGPT_API_KEY = "dbgpt"
  3. APP_ID="{YOUR_APP_ID}"
  4. client = Client(api_key=DBGPT_API_KEY)
  5. async for data in client.chat_stream(
  6. messages="Introduce AWEL",
  7. model="chatgpt_proxyllm",
  8. chat_mode="chat_app",
  9. chat_param=APP_ID
  10. ):
  11. print(data)

流式响应

  1. 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```"}}]}
  2. data: [DONE]

获取应用列表

  1. GET /api/v2/serve/apps

Curl调用

  1. DBGPT_API_KEY=dbgpt
  2. curl -X GET 'http://localhost:5670/api/v2/serve/apps' -H "Authorization: Bearer $DBGPT_API_KEY"

Python SDK调用

  1. from dbgpt.client import Client
  2. from dbgpt.client.app import list_app
  3. DBGPT_API_KEY = "dbgpt"
  4. app_id = "{your_app_id}"
  5. client = Client(api_key=DBGPT_API_KEY)
  6. res = await list_app(client=client)

应用API - 图1

返回对象

参数 参数描述 备注
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": "" }

获取应用详情

  1. GET /api/v2/serve/apps/{app_id}

Curl调用

  1. DBGPT_API_KEY=dbgpt
  2. APP_ID={YOUR_APP_ID}
  3. curl -X GET "http://localhost:5670/api/v2/serve/apps/$APP_ID" -H "Authorization: Bearer $DBGPT_API_KEY"

Python SDK调用

  1. from dbgpt.client import Client
  2. from dbgpt.client.app import get_app
  3. DBGPT_API_KEY = "dbgpt"
  4. app_id = "{your_app_id}"
  5. client = Client(api_key=DBGPT_API_KEY)
  6. res = await get_app(client=client, app_id=app_id)

应用API - 图2

附录