|  |  |  | 
|---|
|  |  |  | import json | 
|---|
|  |  |  |  | 
|---|
|  |  |  | from app.config.config import settings | 
|---|
|  |  |  | # from Log import logger | 
|---|
|  |  |  | from app.service.v2.app_driver.chat_base import ChatBase | 
|---|
|  |  |  | from app.utils.rsa_crypto import RagflowCrypto | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | class ChatBaseApply(ChatBase): | 
|---|
|  |  |  |  | 
|---|
|  |  |  | async def chat_parameters(self, url, params, headers): | 
|---|
|  |  |  | async def chat_get(self, url, params, headers): | 
|---|
|  |  |  |  | 
|---|
|  |  |  | res = await self.http_get(url, params, headers) | 
|---|
|  |  |  | if res.status_code == 200: | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | if res.status_code == 200: | 
|---|
|  |  |  | return res.json() | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | return {} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | async def chat_login(self, url, data, headers): | 
|---|
|  |  |  |  | 
|---|
|  |  |  | res = await self.http_post(url, data, headers) | 
|---|
|  |  |  | if res.status_code == 200: | 
|---|
|  |  |  | res_json = res.json() | 
|---|
|  |  |  | authorization = res.headers.get('Authorization') | 
|---|
|  |  |  | if authorization: | 
|---|
|  |  |  | res_json["data"]["access_token"] = authorization | 
|---|
|  |  |  | return res_json | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | return {} | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @staticmethod | 
|---|
|  |  |  | async def password_encrypt(password): | 
|---|
|  |  |  | password = RagflowCrypto(settings.PUBLIC_KEY, settings.PRIVATE_KEY).encrypt(password) | 
|---|
|  |  |  | return password | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|