| | |
| | | token = await get_chat_token(db, session.chat_id) |
| | | chat = ChatAgent() |
| | | url = settings.dify_base_url + DF_CHAT_AGENT |
| | | chat_request = json.loads(session.query) |
| | | if session.mindmap: |
| | | chat_request = json.loads(session.query) |
| | | |
| | | 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") |