From 0650b889a36d9b9fd42415b9b9819676f839ae9b Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期二, 08 四月 2025 09:54:09 +0800 Subject: [PATCH] 首页会话-模型修改 --- app/service/v2/app_driver/chat_data.py | 42 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/service/v2/app_driver/chat_data.py b/app/service/v2/app_driver/chat_data.py index 97939d2..be966eb 100644 --- a/app/service/v2/app_driver/chat_data.py +++ b/app/service/v2/app_driver/chat_data.py @@ -1,5 +1,6 @@ import json +from Log import logger from app.config.config import settings # from Log import logger from app.service.v2.app_driver.chat_base import ChatBase @@ -16,11 +17,6 @@ else: return {} - async def chat_ping(self, url, params, headers): - res = await self.http_get(url, params, headers) - return res.status_code - - async def chat_post(self, url, data, headers): res = await self.http_post(url, data, headers) @@ -28,6 +24,24 @@ return res.json() else: return {} + + async def chat_put(self, url, data, headers): + + res = await self.http_put(url, data, headers) + if res.status_code == 200 or res.status_code == 201: + return res.json() + else: + logger.error(res.text) + return {} + + async def chat_ping(self, url, params, headers): + res = await self.http_get(url, params, headers) + # print(res.text) + if res.status_code != 200: + return 0 + if res.json().get("code") == "unauthorized" or res.json().get("code") == 401: + return 0 + return 200 async def chat_login(self, url, data, headers): @@ -38,6 +52,14 @@ if authorization: res_json["data"]["access_token"] = authorization return res_json + else: + return {} + + async def chat_upload(self, url, files, data, headers): + + res = await self.http_upload_file(url, headers=headers, files=files, data=data) + if res.status_code == 200 or res.status_code == 201: + return res.json() else: return {} @@ -78,9 +100,13 @@ # ans = await chat.chat_parameters(url, params, headers) # print(ans) - ping_url = "http://192.168.20.119:13002/console/api/workspaces" - user_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNzBhNWVhZWYtYzU4Yi00YTE0LTliOGQtYWE2MzY0ZmE1ZDE3IiwiZXhwIjoxNzM5MjU2MDMyLCJpc3MiOiJTRUxGX0hPU1RFRCIsInN1YiI6IkNvbnNvbGUgQVBJIFBhc3Nwb3J0In0.tlxdRIVL2Ewgb0V4M5pj6v_U2yyvQxtCDrbvSxLjUBs" - token = "Bearer {}" + ping_url = "http://192.168.20.116:11080/v1/user/info" + # ping_url = "http://smartai.com:8294/v1/llm/list" + # ping_url = "http://192.168.20.119:13002/console/api/workspaces" + user_token = "eyJhbG|ciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjEzNzdiYzctZTViYy00YjhiLTgxYTYtNWZkOTVhODVlMmE4IiwiZXhwIjoxNzM5MjU3Njk1LCJpc3MiOiJTRUxGX0hPU1RFRCIsInN1YiI6IkNvbnNvbGUgQVBJIFBhc3Nwb3J0In0.w7xQrepd1dYR4iPXcbuthIZjdm45bTJFbolOM_SE9aQ" + user_token = "IjU4OTM5M2UyZjMyNzExZWZhZmVjMDI0MmFjMTIwMDA2Ig.Z702yg.Pmyy58wg-YBU5t50mHuqvwTDyjc" + # token = "Bearer {}" + token = "{}" res = await chat.chat_ping(ping_url, {}, await chat.get_chat_headers(token.format(user_token))) print(res) -- Gitblit v1.8.0