Knowledge
Get started with the Knowledge API
Chat Knowledge Space
POST /api/v2/chat/completions
Examples
Chat Knowledge
- Curl
- Python
DBGPT_API_KEY=dbgpt
SPACE_NAME={YOUR_SPACE_NAME}
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_knowledge\", \"chat_param\": \"$SPACE_NAME\"}"
from dbgpt.client import Client
DBGPT_API_KEY = "dbgpt"
SPACE_NAME="{YOUR_SPACE_NAME}"
client = Client(api_key=DBGPT_API_KEY)
async for data in client.chat_stream(
messages="Introduce AWEL",
model="chatgpt_proxyllm",
chat_mode="chat_knowledge",
chat_param=SPACE_NAME
):
print(data)
Chat Completion Response
{
"id": "acb050ab-eb2c-4754-97e4-6f3b94b7dac2",
"object": "chat.completion",
"created": 1710917272,
"model": "chatgpt_proxyllm",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "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."
},
"finish_reason": null
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens": 0
}
}