From cbb634f9c133c726a00faf8199ba8954e18d4b05 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 15 十月 2024 14:33:45 +0800 Subject: [PATCH] 智能体列表增加排序和类型字段 --- app/service/ragflow.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/app/service/ragflow.py b/app/service/ragflow.py index df131f1..934af1a 100644 --- a/app/service/ragflow.py +++ b/app/service/ragflow.py @@ -59,3 +59,24 @@ return else: yield f"Error: {response.status_code}" + + async def get_chat_sessions(self, token: str, dialog_id: str) -> list: + url = f"{self.base_url}/v1/conversation/list?dialog_id={dialog_id}" + headers = { + "Authorization": token + } + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=headers) + if response.status_code != 200: + raise Exception(f"Failed to fetch data from Ragflow API: {response.text}") + + data = response.json().get("data", []) + result = [ + { + "id": item["id"], + "name": item["name"], + "updated_time": item["update_time"] + } + for item in data + ] + return result -- Gitblit v1.8.0