diff --git a/dbgpt/app/knowledge/request/request.py b/dbgpt/app/knowledge/request/request.py index f15d3e7f2..14e12ce90 100644 --- a/dbgpt/app/knowledge/request/request.py +++ b/dbgpt/app/knowledge/request/request.py @@ -79,20 +79,6 @@ class DocumentSyncRequest(BaseModel): 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): """id: id""" diff --git a/dbgpt/app/knowledge/space_db.py b/dbgpt/app/knowledge/space_db.py deleted file mode 100644 index 933a2b57b..000000000 --- a/dbgpt/app/knowledge/space_db.py +++ /dev/null @@ -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() diff --git a/docs/docs/api/app.md b/docs/docs/api/app.md index 1972719cd..3a0105543 100644 --- a/docs/docs/api/app.md +++ b/docs/docs/api/app.md @@ -27,14 +27,14 @@ import TabItem from '@theme/TabItem'; ```shell - DBGPT_API_KEY="dbgpt" - APP_ID="{YOUR_APP_ID}" + DBGPT_API_KEY=dbgpt + APP_ID={YOUR_APP_ID} 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_app\", \"chat_param\": "$APP_ID"}" + -d "{\"messages\":\"Hello\",\"model\":\"chatgpt_proxyllm\", \"chat_mode\": \"chat_app\", \"chat_param\": \"$APP_ID\"}" ``` @@ -65,6 +65,43 @@ data: [DONE] GET /api/v2/serve/apps/{app_id} ``` + + + + +```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" +``` + + + + + +```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) + +``` + + + + + #### Query Parameters ________ app_id string Required @@ -80,6 +117,41 @@ Return App Object ```python GET /api/v2/serve/apps ``` + + + + +```shell +DBGPT_API_KEY=dbgpt + +curl -X GET 'http://localhost:5000/api/v2/serve/apps' -H "Authorization: Bearer $DBGPT_API_KEY" +``` + + + + + +```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) + +``` + + + #### Response body Return App Object List diff --git a/docs/docs/api/flow.md b/docs/docs/api/flow.md index e91438c20..8e4173139 100644 --- a/docs/docs/api/flow.md +++ b/docs/docs/api/flow.md @@ -27,14 +27,14 @@ import TabItem from '@theme/TabItem'; ```shell - DBGPT_API_KEY="dbgpt" - FLOW_ID="{YOUR_FLOW_ID}" +DBGPT_API_KEY=dbgpt +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 "accept: 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\"}" ``` @@ -86,27 +86,27 @@ DELETE /api/v2/serve/awel/flows ``` - + ```shell - DBGPT_API_KEY="dbgpt" - FLOW_ID="{YOUR_FLOW_ID}" +DBGPT_API_KEY=dbgpt +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" \ ``` - + ```python @@ -140,26 +140,26 @@ Return Flow Object GET /api/v2/serve/awel/flows/{flow_id} ``` - + ```shell - DBGPT_API_KEY="dbgpt" - FLOW_ID="{YOUR_FLOW_ID}" +DBGPT_API_KEY=dbgpt +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' ``` - + ```python @@ -195,25 +195,25 @@ GET /api/v2/serve/awel/flows - + ```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" \ ``` - + ```python diff --git a/docs/docs/api/knowledge.md b/docs/docs/api/knowledge.md index f2bdf2b32..ef3818bb0 100644 --- a/docs/docs/api/knowledge.md +++ b/docs/docs/api/knowledge.md @@ -27,20 +27,14 @@ import TabItem from '@theme/TabItem'; ```shell - DBGPT_API_KEY="dbgpt" - 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 -}' +DBGPT_API_KEY=dbgpt +SPACE_NAME={YOUR_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\"}" ``` @@ -490,8 +484,8 @@ DELETE /api/v2/serve/knowledge/spaces ```shell - DBGPT_API_KEY="dbgpt" - SPACE_ID="{YOUR_SPACE_ID}" + DBGPT_API_KEY=dbgpt + SPACE_ID={YOUR_SPACE_ID} curl -X DELETE "http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID" \ -H "Authorization: Bearer $DBGPT_API_KEY" \ @@ -546,11 +540,9 @@ GET /api/v2/serve/knowledge/spaces/{space_id} ```shell - DBGPT_API_KEY="dbgpt" - SPACE_ID="{YOUR_SPACE_ID}" - - curl --location --request GET 'http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID' \ - --header 'Authorization: Bearer $DBGPT_API_KEY' +DBGPT_API_KEY=dbgpt +SPACE_ID={YOUR_SPACE_ID} +curl -X GET "http://localhost:5000/api/v2/serve/knowledge/spaces/$SPACE_ID" -H "Authorization: Bearer $DBGPT_API_KEY" ``` @@ -600,10 +592,9 @@ GET /api/v2/serve/knowledge/spaces ```shell - DBGPT_API_KEY="dbgpt" + DBGPT_API_KEY=dbgpt -curl --location --request GET 'http://localhost:5000/api/v2/serve/knowledge/spaces' \ ---header 'Authorization: Bearer dbgpt' +curl -X GET 'http://localhost:5000/api/v2/serve/knowledge/spaces' -H "Authorization: Bearer $DBGPT_API_KEY" ```