实现获取聊天助手列表功能

This commit is contained in:
haotian 2025-09-05 16:00:46 +08:00
parent 0de0c9e53d
commit 31d080ae40
3 changed files with 52 additions and 4 deletions

View File

@ -107,7 +107,7 @@ async def update_file_dataset(
return parse_result(result)
# 解析文档
# 开始解析文档
@ragflowController.post('/parse_documents/{dataset_id}')
async def parse_documents(
dataset_id: str,
@ -117,6 +117,16 @@ async def parse_documents(
result = await RAGFlowService.parse_documents_services(dataset_id, parse_params)
return parse_result(result)
# 停止解析文档
@ragflowController.post('/stop_parse_documents/{dataset_id}')
async def stop_parse_documents(
dataset_id: str,
parse_params: DocumentIdsModel,
# query_db: AsyncSession = Depends(get_db),
):
result = await RAGFlowService.stop_parse_documents_services(dataset_id, parse_params)
return parse_result(result)
# 删除文档
@ragflowController.post('/delete_file/{dataset_id}')
async def delete_file(
@ -144,7 +154,19 @@ async def delete_datasets(
result = await RAGFlowService.delete_datasets_services(delete_params)
return parse_result(result)
# 查看聊天助手列表
@ragflowController.post('/get_chat_assistant_list')
async def get_chat_assistant_list(
query_params: RagflowListQueryModel,
):
"""
查看聊天助手列表
"""
result = await RAGFlowService.get_chat_assistant_list_services(query_params)
return parse_result(result)
# pass
def parse_result(result):

View File

@ -13,7 +13,8 @@ class RagflowListQueryModel(BaseModel):
orderby: Optional[str] = Field(default='create_time', description='排序字段')
desc: Optional[str] = Field(default='true', description='排序方式')
name: Optional[str] = Field(default=None, description='名称')
dataset_id: Optional[str] = Field(default=None, description='数据集ID')
# dataset_id: Optional[str] = Field(default=None, description='数据集ID')
# chat_id: Optional[str] = Field(default=None, description='聊天ID')
@as_query
class ListDocumentsQueryModel(BaseModel):

View File

@ -87,7 +87,7 @@ class RAGFlowService:
result = await client.upload_documents_bytes(dataset_id=dataset_id, file_bytes=files)
return result
#解析文档
# 开始解析文档
@classmethod
async def parse_documents_services(
cls,
@ -98,6 +98,20 @@ class RAGFlowService:
result = await client.parse_documents(dataset_id=dataset_id, document_ids=parse_params.documnet_ids)
return result
# 停止解析文档
@classmethod
async def stop_parse_documents_services(
cls,
dataset_id: str,
parse_params: DocumentIdsModel,
):
async with AsyncRAGFlowClient(RAGFlowConfig.RAGFLOW_BASE_URL, RAGFlowConfig.RAGFLOW_API_KEY) as client:
result = await client.stop_parsing_documents(dataset_id=dataset_id, document_ids=parse_params.documnet_ids)
return result
# 更新文档内容
@classmethod
async def update_file_dataset_services(
@ -131,4 +145,15 @@ class RAGFlowService:
async with AsyncRAGFlowClient(RAGFlowConfig.RAGFLOW_BASE_URL, RAGFlowConfig.RAGFLOW_API_KEY) as client:
result = await client.delete_datasets(**(delete_params.model_dump()))
return result
# 查看聊天助手列表
@classmethod
async def get_chat_assistant_list_services(
cls,
query_params: RagflowListQueryModel,
):
async with AsyncRAGFlowClient(RAGFlowConfig.RAGFLOW_BASE_URL, RAGFlowConfig.RAGFLOW_API_KEY) as client:
result = await client.list_chat_assistants(**(query_params.model_dump()))
return result