|
|
@@ -43,6 +43,7 @@ class Dialog(Base):
|
|
|
status = Column(String(1), nullable=False)
|
|
|
description = Column(String(255), nullable=False)
|
|
|
tenant_id = Column(String(36), nullable=False)
|
|
|
+ kb_ids = Column(String(128), nullable=False)
|
|
|
|
|
|
|
|
|
class DfApps(Base):
|
|
|
@@ -257,13 +258,13 @@ def get_data_from_ragflow_v2(base_db, names: List[str], tenant_id) -> List[Dict]
|
|
|
query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id) \
|
|
|
.filter(Dialog.name.in_(names), Dialog.status == "1")
|
|
|
else:
|
|
|
- query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id).filter(
|
|
|
+ query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id, Dialog.kb_ids).filter(
|
|
|
Dialog.status == "1", Dialog.tenant_id == 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", "parameters": para} for row in results if row[0] not in chat_ids]
|
|
|
+ "user_id": str(row[4]), "mode": "agent-dialog", "parameters": para, "kb_ids": row[5]} for row in results if row[0] not in chat_ids]
|
|
|
return formatted_results
|
|
|
finally:
|
|
|
db.close()
|
|
|
@@ -301,13 +302,14 @@ def update_ids_in_local_v2(data: List[Dict], dialog_type: str):
|
|
|
existing_agent.name = row["name"]
|
|
|
existing_agent.description = row["description"]
|
|
|
existing_agent.mode = row["mode"]
|
|
|
+ existing_agent.kb_ids = row.get("kb_ids", "")
|
|
|
if existing_agent.status == Dialog_STATSU_DELETE:
|
|
|
existing_agent.status = Dialog_STATSU_ON
|
|
|
if row["parameters"]:
|
|
|
existing_agent.parameters = json.dumps(row["parameters"])
|
|
|
else:
|
|
|
existing = DialogModel(id=row["id"], status=row["status"], name=row["name"],
|
|
|
- description=row["description"],
|
|
|
+ description=row["description"], kb_ids=row.get("kb_ids", ""),
|
|
|
tenant_id=get_rag_user_id(db, row["user_id"], type_dict[dialog_type]),
|
|
|
dialog_type=dialog_type, mode=row["mode"], parameters=json.dumps(row["parameters"]))
|
|
|
db.add(existing)
|
|
|
@@ -411,10 +413,10 @@ def get_one_from_ragflow_knowledge(klg_id):
|
|
|
def get_one_from_ragflow_dialog(dialog_id):
|
|
|
db = SessionRagflow()
|
|
|
try:
|
|
|
- row = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id) \
|
|
|
+ row = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id, Dialog.kb_ids) \
|
|
|
.filter(Dialog.id==dialog_id).first()
|
|
|
return {"id": row[0], "name": row[1], "description": row[2], "status": str(row[3]),
|
|
|
- "user_id": str(row[4])} if row else {}
|
|
|
+ "user_id": str(row[4]), "kb_ids": row[5]} if row else {}
|
|
|
finally:
|
|
|
db.close()
|
|
|
|