mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-31 15:47:05 +00:00
doc:update api docs
This commit is contained in:
parent
f43abf3155
commit
75f086a41d
@ -79,20 +79,6 @@ class DocumentSyncRequest(BaseModel):
|
|||||||
chunk_overlap: Optional[int] = None
|
chunk_overlap: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
# class KnowledgeSyncRequest(BaseModel):
|
|
||||||
# """Sync request"""
|
|
||||||
#
|
|
||||||
# """doc_ids: doc ids"""
|
|
||||||
# doc_id: int
|
|
||||||
#
|
|
||||||
# """model_name: model name"""
|
|
||||||
# model_name: Optional[str] = None
|
|
||||||
#
|
|
||||||
# """chunk_parameters: chunk parameters
|
|
||||||
# """
|
|
||||||
# chunk_parameters: ChunkParameters
|
|
||||||
|
|
||||||
|
|
||||||
class ChunkQueryRequest(BaseModel):
|
class ChunkQueryRequest(BaseModel):
|
||||||
"""id: id"""
|
"""id: id"""
|
||||||
|
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
# from datetime import datetime
|
|
||||||
#
|
|
||||||
# from sqlalchemy import Column, DateTime, Integer, String, Text
|
|
||||||
#
|
|
||||||
# from dbgpt._private.config import Config
|
|
||||||
# from dbgpt.app.knowledge.request.request import KnowledgeSpaceRequest
|
|
||||||
# from dbgpt.storage.metadata import BaseDao, Model
|
|
||||||
#
|
|
||||||
# CFG = Config()
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# class KnowledgeSpaceEntity(Model):
|
|
||||||
# __tablename__ = "knowledge_space"
|
|
||||||
# id = Column(Integer, primary_key=True)
|
|
||||||
# name = Column(String(100))
|
|
||||||
# vector_type = Column(String(100))
|
|
||||||
# desc = Column(String(100))
|
|
||||||
# owner = Column(String(100))
|
|
||||||
# context = Column(Text)
|
|
||||||
# gmt_created = Column(DateTime)
|
|
||||||
# gmt_modified = Column(DateTime)
|
|
||||||
#
|
|
||||||
# def __repr__(self):
|
|
||||||
# return f"KnowledgeSpaceEntity(id={self.id}, name='{self.name}', vector_type='{self.vector_type}', desc='{self.desc}', owner='{self.owner}' context='{self.context}', gmt_created='{self.gmt_created}', gmt_modified='{self.gmt_modified}')"
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# class KnowledgeSpaceDao(BaseDao):
|
|
||||||
# def create_knowledge_space(self, space: KnowledgeSpaceRequest):
|
|
||||||
# session = self.get_raw_session()
|
|
||||||
# knowledge_space = KnowledgeSpaceEntity(
|
|
||||||
# name=space.name,
|
|
||||||
# vector_type=CFG.VECTOR_STORE_TYPE,
|
|
||||||
# desc=space.desc,
|
|
||||||
# owner=space.owner,
|
|
||||||
# gmt_created=datetime.now(),
|
|
||||||
# gmt_modified=datetime.now(),
|
|
||||||
# )
|
|
||||||
# session.add(knowledge_space)
|
|
||||||
# session.commit()
|
|
||||||
# session.close()
|
|
||||||
#
|
|
||||||
# def get_knowledge_space(self, query: KnowledgeSpaceEntity):
|
|
||||||
# session = self.get_raw_session()
|
|
||||||
# knowledge_spaces = session.query(KnowledgeSpaceEntity)
|
|
||||||
# if query.id is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.id == query.id
|
|
||||||
# )
|
|
||||||
# if query.name is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.name == query.name
|
|
||||||
# )
|
|
||||||
# if query.vector_type is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.vector_type == query.vector_type
|
|
||||||
# )
|
|
||||||
# if query.desc is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.desc == query.desc
|
|
||||||
# )
|
|
||||||
# if query.owner is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.owner == query.owner
|
|
||||||
# )
|
|
||||||
# if query.gmt_created is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.gmt_created == query.gmt_created
|
|
||||||
# )
|
|
||||||
# if query.gmt_modified is not None:
|
|
||||||
# knowledge_spaces = knowledge_spaces.filter(
|
|
||||||
# KnowledgeSpaceEntity.gmt_modified == query.gmt_modified
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# knowledge_spaces = knowledge_spaces.order_by(
|
|
||||||
# KnowledgeSpaceEntity.gmt_created.desc()
|
|
||||||
# )
|
|
||||||
# result = knowledge_spaces.all()
|
|
||||||
# session.close()
|
|
||||||
# return result
|
|
||||||
#
|
|
||||||
# def update_knowledge_space(self, space: KnowledgeSpaceEntity):
|
|
||||||
# session = self.get_raw_session()
|
|
||||||
# session.merge(space)
|
|
||||||
# session.commit()
|
|
||||||
# session.close()
|
|
||||||
# return True
|
|
||||||
#
|
|
||||||
# def delete_knowledge_space(self, space: KnowledgeSpaceEntity):
|
|
||||||
# session = self.get_raw_session()
|
|
||||||
# if space:
|
|
||||||
# session.delete(space)
|
|
||||||
# session.commit()
|
|
||||||
# session.close()
|
|
@ -27,14 +27,14 @@ import TabItem from '@theme/TabItem';
|
|||||||
<TabItem value="curl">
|
<TabItem value="curl">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
APP_ID="{YOUR_APP_ID}"
|
APP_ID={YOUR_APP_ID}
|
||||||
|
|
||||||
curl -X POST "http://localhost:5000/api/v2/chat/completions" \
|
curl -X POST "http://localhost:5000/api/v2/chat/completions" \
|
||||||
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
||||||
-H "accept: application/json" \
|
-H "accept: application/json" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_app\", \"chat_param\": "$APP_ID"}"
|
-d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_app\", \"chat_param\": \"$APP_ID\"}"
|
||||||
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@ -65,6 +65,43 @@ data: [DONE]
|
|||||||
GET /api/v2/serve/apps/{app_id}
|
GET /api/v2/serve/apps/{app_id}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<Tabs
|
||||||
|
defaultValue="curl_get_app"
|
||||||
|
groupId="chat1"
|
||||||
|
values={[
|
||||||
|
{label: 'Curl', value: 'curl_get_app'},
|
||||||
|
{label: 'Python', value: 'python_get_app'},
|
||||||
|
]
|
||||||
|
}>
|
||||||
|
|
||||||
|
<TabItem value="curl_get_app">
|
||||||
|
|
||||||
|
```shell
|
||||||
|
DBGPT_API_KEY=dbgpt
|
||||||
|
APP_ID={YOUR_APP_ID}
|
||||||
|
curl -X GET "http://localhost:5000/api/v2/serve/apps/$APP_ID" -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem value="python_get_app">
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
from dbgpt.client.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)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
#### Query Parameters
|
#### Query Parameters
|
||||||
________
|
________
|
||||||
<b>app_id</b> <font color="gray"> string </font> <font color="red"> Required </font>
|
<b>app_id</b> <font color="gray"> string </font> <font color="red"> Required </font>
|
||||||
@ -80,6 +117,41 @@ Return <a href="#the-app-object">App Object</a>
|
|||||||
```python
|
```python
|
||||||
GET /api/v2/serve/apps
|
GET /api/v2/serve/apps
|
||||||
```
|
```
|
||||||
|
<Tabs
|
||||||
|
defaultValue="curl_list_app"
|
||||||
|
groupId="chat1"
|
||||||
|
values={[
|
||||||
|
{label: 'Curl', value: 'curl_list_app'},
|
||||||
|
{label: 'Python', value: 'python_list_app'},
|
||||||
|
]
|
||||||
|
}>
|
||||||
|
|
||||||
|
<TabItem value="curl_list_app">
|
||||||
|
|
||||||
|
```shell
|
||||||
|
DBGPT_API_KEY=dbgpt
|
||||||
|
|
||||||
|
curl -X GET 'http://localhost:5000/api/v2/serve/apps' -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem value="python_list_app">
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
from dbgpt.client.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)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
#### Response body
|
#### Response body
|
||||||
Return <a href="#the-app-object">App Object</a> List
|
Return <a href="#the-app-object">App Object</a> List
|
||||||
|
@ -27,14 +27,14 @@ import TabItem from '@theme/TabItem';
|
|||||||
<TabItem value="curl">
|
<TabItem value="curl">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
FLOW_ID="{YOUR_FLOW_ID}"
|
FLOW_ID={YOUR_FLOW_ID}
|
||||||
|
|
||||||
curl -X POST "http://localhost:5000/api/v2/chat/completions" \
|
curl -X POST "http://localhost:5000/api/v2/chat/completions" \
|
||||||
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
||||||
-H "accept: application/json" \
|
-H "accept: application/json" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_flow\", \"chat_param\": "$FLOW_ID"}"
|
-d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_flow\", \"chat_param\": \"$FLOW_ID\"}"
|
||||||
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@ -86,27 +86,27 @@ DELETE /api/v2/serve/awel/flows
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultValue="curl_update_knowledge"
|
defaultValue="curl_update_flow"
|
||||||
groupId="chat1"
|
groupId="chat1"
|
||||||
values={[
|
values={[
|
||||||
{label: 'Curl', value: 'curl_update_knowledge'},
|
{label: 'Curl', value: 'curl_update_flow'},
|
||||||
{label: 'Python', value: 'python_update_knowledge'},
|
{label: 'Python', value: 'python_update_flow'},
|
||||||
]
|
]
|
||||||
}>
|
}>
|
||||||
|
|
||||||
<TabItem value="curl_update_knowledge">
|
<TabItem value="curl_update_flow">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
FLOW_ID="{YOUR_FLOW_ID}"
|
FLOW_ID={YOUR_FLOW_ID}
|
||||||
|
|
||||||
curl -X DELETE "http://localhost:5000/api/v2/serve/knowledge/spaces/$FLOW_ID" \
|
curl -X DELETE "http://localhost:5000/api/v2/serve/awel/flows/$FLOW_ID" \
|
||||||
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
||||||
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem value="python_update_knowledge">
|
<TabItem value="python_update_flow">
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -140,26 +140,26 @@ Return <a href="#the-flow-object">Flow Object</a>
|
|||||||
GET /api/v2/serve/awel/flows/{flow_id}
|
GET /api/v2/serve/awel/flows/{flow_id}
|
||||||
```
|
```
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultValue="curl_get_knowledge"
|
defaultValue="curl_get_flow"
|
||||||
groupId="chat1"
|
groupId="chat1"
|
||||||
values={[
|
values={[
|
||||||
{label: 'Curl', value: 'curl_get_knowledge'},
|
{label: 'Curl', value: 'curl_get_flow'},
|
||||||
{label: 'Python', value: 'python_get_knowledge'},
|
{label: 'Python', value: 'python_get_flow'},
|
||||||
]
|
]
|
||||||
}>
|
}>
|
||||||
|
|
||||||
<TabItem value="curl_get_knowledge">
|
<TabItem value="curl_get_flow">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
FLOW_ID="{YOUR_FLOW_ID}"
|
FLOW_ID={YOUR_FLOW_ID}
|
||||||
|
|
||||||
|
curl -X GET "http://localhost:5000/api/v2/serve/awel/flows/$FLOW_ID" -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
|
|
||||||
curl --location --request GET 'http://localhost:5000/api/v2/serve/awel/flows/$FLOW_ID' \
|
|
||||||
--header 'Authorization: Bearer $DBGPT_API_KEY'
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem value="python_get_knowledge">
|
<TabItem value="python_get_flow">
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -195,25 +195,25 @@ GET /api/v2/serve/awel/flows
|
|||||||
|
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultValue="curl_list_knowledge"
|
defaultValue="curl_list_flow"
|
||||||
groupId="chat1"
|
groupId="chat1"
|
||||||
values={[
|
values={[
|
||||||
{label: 'Curl', value: 'curl_list_knowledge'},
|
{label: 'Curl', value: 'curl_list_flow'},
|
||||||
{label: 'Python', value: 'python_list_knowledge'},
|
{label: 'Python', value: 'python_list_flow'},
|
||||||
]
|
]
|
||||||
}>
|
}>
|
||||||
|
|
||||||
<TabItem value="curl_list_knowledge">
|
<TabItem value="curl_list_flow">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
|
|
||||||
|
curl -X GET "http://localhost:5000/api/v2/serve/awel/flows" -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
|
|
||||||
curl -X GET "http://localhost:5000/api/v2/serve/awel/flows" \
|
|
||||||
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem value="python_list_knowledge">
|
<TabItem value="python_list_flow">
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -27,20 +27,14 @@ import TabItem from '@theme/TabItem';
|
|||||||
<TabItem value="curl">
|
<TabItem value="curl">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
SPACE_NAME="{YOUR_SPACE_NAME}"
|
SPACE_NAME={YOUR_SPACE_NAME}
|
||||||
|
|
||||||
curl --location --request POST 'http://127.0.0.1:5000/api/v2/chat/completions' \
|
|
||||||
--header 'Authorization: Bearer $DBGPT_API_KEY' \
|
|
||||||
--header 'Content-Type: application/json' \
|
|
||||||
--data-raw '{
|
|
||||||
|
|
||||||
"model": "chatgpt_proxyllm",
|
|
||||||
"messages": "introduce awel",
|
|
||||||
"chat_mode":"chat_knowledge",
|
|
||||||
"chat_param":$SPACE_NAME
|
|
||||||
}'
|
|
||||||
|
|
||||||
|
curl -X POST "http://localhost:5000/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\"}"
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
@ -490,8 +484,8 @@ DELETE /api/v2/serve/knowledge/spaces
|
|||||||
<TabItem value="curl_update_knowledge">
|
<TabItem value="curl_update_knowledge">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
SPACE_ID="{YOUR_SPACE_ID}"
|
SPACE_ID={YOUR_SPACE_ID}
|
||||||
|
|
||||||
curl -X DELETE "http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID" \
|
curl -X DELETE "http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID" \
|
||||||
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
-H "Authorization: Bearer $DBGPT_API_KEY" \
|
||||||
@ -546,11 +540,9 @@ GET /api/v2/serve/knowledge/spaces/{space_id}
|
|||||||
<TabItem value="curl_get_knowledge">
|
<TabItem value="curl_get_knowledge">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
SPACE_ID="{YOUR_SPACE_ID}"
|
SPACE_ID={YOUR_SPACE_ID}
|
||||||
|
curl -X GET "http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID" -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
curl --location --request GET 'http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID' \
|
|
||||||
--header 'Authorization: Bearer $DBGPT_API_KEY'
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
@ -600,10 +592,9 @@ GET /api/v2/serve/knowledge/spaces
|
|||||||
<TabItem value="curl_list_knowledge">
|
<TabItem value="curl_list_knowledge">
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
DBGPT_API_KEY="dbgpt"
|
DBGPT_API_KEY=dbgpt
|
||||||
|
|
||||||
curl --location --request GET 'http://localhost:5000/api/v2/serve/knowledge/spaces' \
|
curl -X GET 'http://localhost:5000/api/v2/serve/knowledge/spaces' -H "Authorization: Bearer $DBGPT_API_KEY"
|
||||||
--header 'Authorization: Bearer dbgpt'
|
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user