| | |
| | | "rank": 91, |
| | | "dialog": [ |
| | | { |
| | | "id": "87b8e17c-594d-424f-b9f8-0b56036904c9", |
| | | "chat_id": "basic_report_clean", |
| | | "chat_type": "reportWorkflow", |
| | | "agentType": 4 |
| | | }, |
| | | { |
| | | "id": "61d26deb-9371-4f9c-b61b-b9f9a24a9188", |
| | | "chat_id": "basic_report_clean", |
| | | "chat_type": "reportWorkflow", |
| | | "agentType": 4 |
| | | }, |
| | | { |
| | | "id": "d6eea92d-444a-4658-b9e7-9ab7bd5cb19d", |
| | | "id": "basic_report_talk", |
| | | "chat_id": "basic_report_clean", |
| | | "chat_type": "reportWorkflow", |
| | | "agentType": 4 |
| | |
| | | "chatMode": self.chatMode, |
| | | "knowledgeId": self.knowledgeId, |
| | | "files": self.files, |
| | | "isDeep": self.isDeep, |
| | | } |
| | | |
| | | |
| | |
| | | from datetime import datetime |
| | | from app.api import pwd_context |
| | | from app.config.const import RAGFLOW, BISHENG, DIFY, USER_STATSU_DELETE, ROLE_STATUS_ON, DEPT_STATUS_ON, \ |
| | | Dialog_STATSU_ON |
| | | Dialog_STATSU_ON, USER_STATSU_ON |
| | | from app.models import RoleModel, GroupModel, AgentType, role_resource_table, DialogModel, OrganizationModel, \ |
| | | ResourceModel |
| | | from app.models.menu_model import WebMenuModel, MenuCapacityModel |
| | |
| | | menu_list = db.query(WebMenuModel.id, WebMenuModel.title, WebMenuModel.describe, WebMenuModel.icon, WebMenuModel.desc,WebMenuModel.rank, |
| | | WebMenuModel.img, MenuCapacityModel.capacity_id, MenuCapacityModel.capacity_type, MenuCapacityModel.chat_id.label("agentId"), MenuCapacityModel.chat_type).outerjoin( |
| | | MenuCapacityModel, WebMenuModel.id == MenuCapacityModel.menu_id).outerjoin( |
| | | DialogModel, MenuCapacityModel.capacity_id == DialogModel.id).filter(DialogModel.status=="1").all() |
| | | DialogModel, MenuCapacityModel.capacity_id == DialogModel.id).filter(DialogModel.status==USER_STATSU_ON).all() |
| | | |
| | | for menu in menu_list: |
| | | menu_dict[menu.id] = menu_dict.get(menu.id, []) + [menu] |
| | |
| | | async for ans in chat.chat_completions(url, |
| | | await chat.complex_request_data(chat_request.query, conversation_id, str(user_id), files=chat_request.files, inputs=inputs), |
| | | await chat.get_headers(token)): |
| | | # print(ans) |
| | | print(ans) |
| | | data = {} |
| | | status = http_200 |
| | | conversation_id = ans.get("conversation_id") |
| | |
| | | token = await get_chat_token(db, session.chat_id) |
| | | chat = ChatAgent() |
| | | url = settings.dify_base_url + DF_CHAT_AGENT |
| | | if session.mindmap: |
| | | chat_request = json.loads(session.query) |
| | | if session.mindmap: |
| | | |
| | | inputs = {"is_deep": chat_request.get("isDeep", 1)} |
| | | if session.chat_mode == complex_knowledge_chat: |
| | | inputs["query_json"] = json.dumps( |
| | |
| | | return res |
| | | else: |
| | | mindmap_query = session.content |
| | | |
| | | # print("-----------------", mindmap_query) |
| | | try: |
| | | if chat_request.get("isDeep", 1) == 2: |
| | | mindmap_query = mindmap_query.split("</think>")[-1] |
| | | mindmap_str = "" |
| | | # print("mindmap_query", mindmap_query) |
| | | token = await get_chat_token(db, mindmap_chat_id) |
| | | async for ans in chat.chat_completions(url, |
| | | await chat.complex_request_data(mindmap_query, "", |
| | |
| | | except Exception as e: |
| | | logger.error(e) |
| | | return res |
| | | # print(mindmap_str) |
| | | if "```json" in mindmap_str: |
| | | mindmap_list = mindmap_str.split("```") |
| | | mindmap_str = mindmap_list[1].lstrip("json") |