| | |
| | | status_code=status.HTTP_401_UNAUTHORIZED, |
| | | detail="登录过期", |
| | | ) |
| | | if ret_code != 0: |
| | | return {} |
| | | # if ret_code != 0: |
| | | # return {} |
| | | |
| | | # 检查返回的数据类型 |
| | | if isinstance(data.get("data"), dict): |
| | |
| | | |
| | | |
| | | |
| | | async def get_session_history(self, token: str, chat_id: str, is_all: int=0): |
| | | url = f"{self.base_url}/v1/conversation/get?conversation_id={chat_id}" |
| | | headers = {"Authorization": token} |
| | | async def get_session_history(self, token: str, conversation_id: str, user: str): |
| | | url = f"{self.base_url}/v1/messages" |
| | | params = { |
| | | 'user': user, |
| | | 'conversation_id': conversation_id |
| | | } |
| | | headers = {"Authorization": f'Bearer {token}'} |
| | | async with httpx.AsyncClient() as client: |
| | | response = await client.get(url, headers=headers) |
| | | response = await client.get(url, params=params, headers=headers) |
| | | # print(response.text) |
| | | # print(response.status_code) |
| | | # print(response.res) |
| | | data = self._handle_response(response) |
| | | # print("----------------data----------------------:", data) |
| | | if is_all: |
| | | return data |
| | | return data.get("message", []) |
| | | |
| | | return data |
| | | |
| | | async def upload(self, token: str, filename: str, file: bytes, user_id) -> dict: |
| | | url = f"{self.base_url}/v1/files/upload" |