zhaoqingang
2025-02-10 3eabd0961bc63f08f10b4c582ed1c471df43a8c7
app/service/v2/app_driver/chat_data.py
@@ -18,7 +18,11 @@
    async def chat_ping(self, url, params, headers):
        res = await self.http_get(url, params, headers)
        return res.status_code
        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_post(self, url, data, headers):
@@ -47,6 +51,12 @@
        password = RagflowCrypto(settings.PUBLIC_KEY, settings.PRIVATE_KEY).encrypt(password)
        return password
    @staticmethod
    async def get_chat_headers(token):
        return {
            'Content-Type': 'application/json',
            'Authorization': token
        }
@@ -69,9 +79,16 @@
            'Content-Type': 'application/json',
            'Authorization': f"Bearer {token}"
        }
        ans = await chat.chat_parameters(url, params, headers)
        print(ans)
        # ans = await chat.chat_parameters(url, params, headers)
        # print(ans)
        ping_url = "http://192.168.20.116:11080/v1/system/version"
        # ping_url = "http://192.168.20.119:13002/console/api/workspaces"
        user_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjEzNzdiYzctZTViYy00YjhiLTgxYTYtNWZkOTVhODVlMmE4IiwiZXhwIjoxNzM5MjU3Njk1LCJpc3MiOiJTRUxGX0hPU1RFRCIsInN1YiI6IkNvbnNvbGUgQVBJIFBhc3Nwb3J0In0.w7xQrepd1dYR4iPXcbuthIZjdm45bTJFbolOM_SE9aQ"
        # token = "Bearer {}"
        token = "{}"
        res = await chat.chat_ping(ping_url, {}, await chat.get_chat_headers(token.format(user_token)))
        print(res)
    import asyncio