| | |
| | | |
| | | def get_data_from_ragflow_v2(names: List[str]) -> List[Dict]: |
| | | db = SessionRagflow() |
| | | para = { |
| | | "user_input_form": [], |
| | | "retriever_resource": { |
| | | "enabled": True |
| | | }, |
| | | "file_upload": { |
| | | "enabled": False |
| | | } |
| | | } |
| | | try: |
| | | if names: |
| | | query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id) \ |
| | |
| | | results = query.all() |
| | | formatted_results = [ |
| | | {"id": row[0], "name": row[1], "description": row[2], "status": "1" if row[3] == "1" else "2", |
| | | "user_id": str(row[4]), "mode": "agent-dialog"} for row in results] |
| | | "user_id": str(row[4]), "mode": "agent-dialog", "parameters": para} for row in results] |
| | | return formatted_results |
| | | finally: |
| | | db.close() |
| | | |
| | | |
| | | def get_data_from_dify_v2(names: List[str]) -> List[Dict]: |
| | | def get_data_from_dy_v2(names: List[str]) -> List[Dict]: |
| | | db = SessionDify() |
| | | try: |
| | | if names: |
| | |
| | | results = query.all() |
| | | formatted_results = [ |
| | | {"id": str(row[0]), "name": row[1], "description": row[2], "status": "1", |
| | | "user_id": str(row[4]), "mode": row[5]} for row in results] |
| | | "user_id": str(row[4]), "mode": row[5], "parameters": {}} for row in results] |
| | | return formatted_results |
| | | finally: |
| | | db.close() |
| | |
| | | if existing_agent: |
| | | existing_agent.name = row["name"] |
| | | existing_agent.description = row["description"] |
| | | # existing_agent.status = row["status"] |
| | | existing_agent.mode = row["mode"] |
| | | # existing_agent.tenant_id = get_rag_user_id(db, row["user_id"], type_dict[dialog_type]) |
| | | else: |
| | | existing = DialogModel(id=row["id"], status=row["status"], name=row["name"], |
| | | description=row["description"], |
| | | tenant_id=get_rag_user_id(db, row["user_id"], type_dict[dialog_type]), |
| | | dialog_type=dialog_type, mode=row["mode"]) |
| | | dialog_type=dialog_type, mode=row["mode"], parameters=json.dumps(row["parameters"])) |
| | | db.add(existing) |
| | | db.commit() |
| | | for dialog in db.query(DialogModel).filter_by(dialog_type=dialog_type).all(): |
| | |
| | | ragflow_data = get_data_from_ragflow_v2([]) |
| | | if ragflow_data: |
| | | update_ids_in_local_v2(ragflow_data, "1") |
| | | elif app["id"] == BISHENG: |
| | | bisheng_data = get_data_from_bisheng_v2([]) |
| | | if bisheng_data: |
| | | update_ids_in_local_v2(bisheng_data, "2") |
| | | # elif app["id"] == BISHENG: |
| | | # bisheng_data = get_data_from_bisheng_v2([]) |
| | | # if bisheng_data: |
| | | # update_ids_in_local_v2(bisheng_data, "2") |
| | | elif app["id"] == DIFY: |
| | | dify_data = get_data_from_dify_v2([]) |
| | | dify_data = get_data_from_dy_v2([]) |
| | | if dify_data: |
| | | update_ids_in_local_v2(dify_data, "4") |
| | | print("v2 Agents synchronized successfully") |