| | |
| | | # token = get_dify_token(db, current_user.id) |
| | | try: |
| | | async def forward_to_dify(): |
| | | if agent.type == "imageTalk": |
| | | if chat_type == "imageTalk": |
| | | token = DfTokenDao(db).get_token_by_id(IMAGE_TO_TEXT) |
| | | if not token: |
| | | await websocket.send_json({"message": "Invalid token", "type": "error"}) |
| | |
| | | result = {"message": f"内部错误: {e2}", "type": "close"} |
| | | await websocket.send_json(result) |
| | | print(f"Error process message of ragflow: {e2}") |
| | | elif agent.type == "reportWorkflow": |
| | | elif chat_type == "reportWorkflow": |
| | | |
| | | while True: |
| | | receive_message = await websocket.receive_json() |
| | |
| | | |
| | | |
| | | @system_router.get("/info", response_model=Response) |
| | | async def api_get_system_data(current_user: UserModel = Depends(get_current_user), db=Depends(get_db)): |
| | | async def api_get_system_data(db=Depends(get_db)): |
| | | |
| | | data = await services_get_system_data(db) |
| | | return Response(code=200, msg="successfully", data=data) |
| | |
| | | password: gAAAAABnvAq8bErFiR9x_ZcODjUeOdrDo8Z5UVOzyqo6SxIhAvLpw81kciQN0frwIFVfY9wrxH1WqrpTICpEwfH7r2SkLjS7SQ== |
| | | |
| | | chat_server: |
| | | id: 2c039666c29d11efa4670242ac1b0006 |
| | | account: zhao1@example.com |
| | | password: gAAAAABnpFLtotY2OIRH12BJh4MzMgn5Zil7-DVpIeuqlFwvr0g6g_n4ULogn-LNhCbtk6cCDkzZlqAHvBSX2e_zf7AsoyzbiQ== |
| | | id: fe24dd2c9be611ef92880242ac160006 |
| | | account: user@example.com |
| | | password: gAAAAABnvs3e3fZOYfUUAJ6uT80dkhNeN7rhylzZErTWRZThNSLzMbZGetPCe9A2BJ86V0nZBLMNNu8w6rWp4dC7JxYxByJcow== |
| | | |
| | | workflow_server: |
| | | account: admin@basic.com |
| | | password: gAAAAABnpFLtotY2OIRH12BJh4MzMgn5Zil7-DVpIeuqlFwvr0g6g_n4ULogn-LNhCbtk6cCDkzZlqAHvBSX2e_zf7AsoyzbiQ== |
| | | account: basic@mail.com |
| | | password: gAAAAABnvs5i7xUn9pb2szCozJciGSiWPGv80PH_2HFFzNM2r1ZLTOQqftnUso_bvchtmwAmccfNrf53sf9_WMFVTc0hjTKRRQ== |
| | |
| | | secret_key: your-secret-key |
| | | sgb_base_url: http://192.168.20.119:13001 |
| | | sgb_websocket_url: ws://192.168.20.119:13001 |
| | | fwr_base_url: http://192.168.20.116:11080 |
| | | database_url: mysql+pymysql://root:infini_rag_flow@192.168.20.119:5455/rag_basic |
| | | fwr_base_url: http://192.168.20.119:11080 |
| | | database_url: mysql+pymysql://root:rag_gateway@192.168.20.116:23306/rag_gateway |
| | | sgb_db_url: mysql+pymysql://root:1234@192.168.20.119:13306/bisheng |
| | | fwr_db_url: mysql+pymysql://root:infini_rag_flow@192.168.20.116:15455/rag_flow |
| | | fwr_db_url: mysql+pymysql://root:infini_rag_flow@192.168.20.119:15455/rag_flow |
| | | PUBLIC_KEY: | |
| | | -----BEGIN PUBLIC KEY----- |
| | | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArq9XTUSeYr2+N1h3Afl/z8Dse/2yD0ZGrKwx+EEEcdsBLca9Ynmx3nIB5obmLlSfmskLpBo0UACBmB5rEjBp2Q2f3AG3Hjd4B+gNCG6BDaawuDlgANIhGnaTLrIqWrrcm4EMzJOnAOI1fgzJRsOOUEfaS318Eq9OVO3apEyCCt0lOQK6PuksduOjVxtltDav+guVAA068NrPYmRNabVKRNLJpL8w4D44sfth5RvZ3q9t+6RTArpEtc5sh5ChzvqPOzKGMXW83C95TxmXqpbK6olN4RevSfVjEAgCydH6HN6OhtOQEcnrU97r9H0iZOWwbw3pVrZiUkuRD1R56Wzs2wIDAQAB |
| | |
| | | PASSWORD_KEY: VKinqB-8XMrwCLLrcf_PyHyo12_4PVKvWzaHjNFions= |
| | | basic_base_url: http://192.168.20.231:8000 |
| | | basic_paper_url: http://192.168.20.231:8000 |
| | | dify_base_url: http://192.168.20.119:13002 |
| | | dify_base_url: http://192.168.20.116 |
| | | dify_api_token: app-YmOAMDsPpDDlqryMHnc9TzTO |
| | | postgresql_database_url: postgresql+asyncpg://kong:kongpass@192.168.20.119:5432/kong |
| | | postgresql_database_url: postgresql+asyncpg://kong:kongpass@192.168.20.116:15433/kong |
| | | dify_workflow_clean: app-OpF0drPu0XcgqcekQpT4FA8a |
| | | dify_workflow_report: app-0MAkdFWqh9zxwmU69O0BFU1s |
| | | dify_database_url: postgresql+psycopg2://postgres:difyai123456@192.168.20.119:15432/dify |
| | | dify_database_url: postgresql+psycopg2://postgres:difyai123456@192.168.20.116:15432/dify |
| | | |
| | | |
| | |
| | | from app.models.base_model import SessionLocal |
| | | from app.service.v2.initialize_data import dialog_menu_sync, default_group_sync, default_role_sync, \ |
| | | basic_agent_sync, admin_account_sync, sync_rg_api_token |
| | | from app.task.sync_account_token import sync_token |
| | | |
| | | |
| | | async def sync_default_data(): |
| | |
| | | await basic_agent_sync(db) # 开发的agent |
| | | await admin_account_sync(db) # |
| | | await sync_rg_api_token(db) # |
| | | await sync_token() # 启动同步token任务 |
| | | |
| | | except Exception as e: |
| | | print(e) |
| | |
| | | |
| | | async def services_update_system_data(db, title, desc, logo): |
| | | try: |
| | | if os.path.exists(os.path.join(APP_STATIC_PATH, logo)): |
| | | shutil.move(os.path.join(APP_STATIC_PATH, logo), os.path.join(APP_STATIC_PATH, "logo.png")) |
| | | system = db.query(SystemDataModel).filter_by(id=SYSTEM_ID).first() |
| | | system.title = title |
| | |
| | | query = chat_data.query |
| | | else: |
| | | query = "start new workflow" |
| | | session = await add_session_log(db, session_id, query, chat_id, user_id, mode, conversation_id, 3) |
| | | session = await add_session_log(db, session_id,query if query else "start new conversation", chat_id, user_id, mode, conversation_id, 3) |
| | | if session: |
| | | conversation_id = session.conversation_id |
| | | try: |
| | |
| | | data["outputs"] = await data_process(data.get("outputs", {})) |
| | | data["files"] = await data_process(data.get("files", [])) |
| | | data["process_data"] = "" |
| | | if data.get("status") == "failed": |
| | | status = http_500 |
| | | error = data.get("error", "") |
| | | node_list.append(ans) |
| | | event = [smart_workflow_started, smart_node_started, smart_node_finished][ |
| | | [workflow_started, node_started, node_finished].index(ans.get("event"))] |
| | |
| | | answer_workflow = data.get("outputs", {}).get("output") |
| | | download_url = data.get("outputs", {}).get("download_url") |
| | | event = smart_workflow_finished |
| | | if data.get("status") == "failed": |
| | | status = http_500 |
| | | error = data.get("error", "") |
| | | node_list.append(ans) |
| | | |
| | | elif ans.get("event") == message_end: |
| | |
| | | except: |
| | | ... |
| | | finally: |
| | | await update_session_log(db, session_id, {"role": "assistant", "answer": answer_event or answer_agent or answer_workflow, |
| | | await update_session_log(db, session_id, {"role": "assistant", "answer": answer_event or answer_agent or answer_workflow or error, |
| | | "download_url":download_url, |
| | | "node_list": node_list, "task_id": task_id, "id": message_id, |
| | | "error": error}, conversation_id) |
| | |
| | | sync_agents_v2() # 智能体 |
| | | sync_knowledge() # 知识库 |
| | | sync_resources_from_json() |
| | | await sync_token() # 启动同步token任务 |
| | | yield |
| | | # 在应用关闭时执行清理操作(如果需要) |
| | | pass |