| | |
| | | from sqlalchemy.ext.asyncio import AsyncSession |
| | | from app.api import Response, pwd_context, get_current_user |
| | | from app.config.config import settings |
| | | from app.config.const import chat_server, RAGFLOW, workflow_server, DIFY, TMP_DICT |
| | | from app.models.app_token_model import AppToken |
| | | from app.models.base_model import get_db |
| | | from app.models.postgresql_base_model import get_pdb |
| | |
| | | token_dict = {} |
| | | user_tokens = db.query(UserTokenModel).all() |
| | | for user_token in user_tokens: |
| | | token_dict[user_token.id] = user_token.access_token |
| | | token_dict[TMP_DICT[user_token.id]] = user_token.access_token |
| | | result = await pdb.execute(select(AppToken).where(AppToken.id == user.id)) |
| | | db_app_token = result.scalars().first() |
| | | if isinstance(access_token, bytes): |
| | |
| | | chat_server = "chat_server" |
| | | workflow_server = "workflow_server" |
| | | smart_server = "smart_server" |
| | | |
| | | |
| | | TMP_DICT = {chat_server: RAGFLOW, workflow_server: DIFY} |
| | |
| | | |
| | | 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: |
| | |
| | | # print(ans) |
| | | |
| | | ping_url = "http://192.168.20.116:11080/v1/system/version" |
| | | 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 = "IjhkYTliMGE4ZWRjMjExZWY5OGI4MDI0MmFjMTIwMDA2Ig.Z7QqNA.8aN6VhyxupQdsb5Vlp7mwqTT4sA" |
| | | user_token = "IjNmZTA4NmM2ZjJjMjExZWY4ZTc2MDI0MmFjMTIwMDA2Ig.Z7yNLg.XooARY7YHv-Zo1qLoXwCuDe8J0k" |
| | | # token = "Bearer {}" |
| | | token = "{}" |
| | | res = await chat.chat_ping(ping_url, {}, await chat.get_chat_headers(token.format(user_token))) |
| | |
| | | |
| | | from Log import logger |
| | | # from app.api import pwd_context |
| | | from app.config.const import DIFY, ENV_CONF_PATH, RAGFLOW, smart_server, chat_server, workflow_server |
| | | from app.config.const import DIFY, ENV_CONF_PATH, RAGFLOW, smart_server, chat_server, workflow_server, TMP_DICT |
| | | from app.models import MenuCapacityModel, WebMenuModel, GroupModel, RoleModel, DialogModel, UserModel, UserAppModel, \ |
| | | cipher_suite, UserTokenModel |
| | | from app.service.auth import UserAppDao |
| | |
| | | try: |
| | | config = {} |
| | | app_dict = {} |
| | | tmp_dict = {chat_server:RAGFLOW, workflow_server:DIFY} |
| | | # tmp_dict = {chat_server:RAGFLOW, workflow_server:DIFY} |
| | | now_account =[] |
| | | with open(os.path.join(ENV_CONF_PATH, "admin.yaml"), 'r', encoding='utf-8') as file: |
| | | # 加载JSON数据 |
| | |
| | | db.query(UserTokenModel).filter_by(id=account.id).delete() |
| | | |
| | | for k, v in config.items(): |
| | | if k in tmp_dict: |
| | | app_dict[tmp_dict[k]] = v.get("id") |
| | | if k in TMP_DICT: |
| | | app_dict[TMP_DICT[k]] = v.get("id") |
| | | if k == smart_server: |
| | | db_user = db.query(UserModel).filter(UserModel.username == config["smart_server"]["account"]).first() |
| | | if db_user: |