| | |
| | | from sqlalchemy.orm import sessionmaker, Session |
| | | |
| | | from app.config.config import settings |
| | | from app.config.const import RAGFLOW, BISHENG, DIFY, ENV_CONF_PATH |
| | | from app.config.const import RAGFLOW, BISHENG, DIFY, ENV_CONF_PATH, Dialog_STATSU_DELETE, Dialog_STATSU_ON |
| | | from app.models import KnowledgeModel |
| | | from app.models.dialog_model import DialogModel |
| | | from app.models.user_model import UserAppModel |
| | |
| | | description = Column(Text) # 说明 |
| | | status = Column(String(1)) # 状态 |
| | | doc_num = Column(Integer) # 文档 |
| | | embd_id = Column(String(128)) # 文档 |
| | | |
| | | |
| | | class RgUserTenant(Base): |
| | |
| | | existing_agent.name = row["name"] |
| | | existing_agent.description = row["description"] |
| | | existing_agent.mode = row["mode"] |
| | | 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"], |
| | |
| | | for dialog in db.query(DialogModel).filter_by(dialog_type=dialog_type).all(): |
| | | if dialog.id not in agent_id_list: |
| | | # print(dialog.id) |
| | | db.query(DialogModel).filter_by(id=dialog.id).update({"status": "2"}) |
| | | db.query(DialogModel).filter_by(id=dialog.id).update({"status": Dialog_STATSU_DELETE}) |
| | | db.commit() |
| | | except IntegrityError: |
| | | db.rollback() |
| | |
| | | try: |
| | | |
| | | row = db.query(RgKnowledge.id, RgKnowledge.name, RgKnowledge.description, RgKnowledge.status, |
| | | RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission).filter( |
| | | RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission, RgKnowledge.embd_id).filter( |
| | | RgKnowledge.id == klg_id).first() |
| | | return {"id": row[0], "name": row[1], "description": row[2], "status": str(row[3]), |
| | | "user_id": str(row[4]), "doc_num": row[5], "permission": row[6]} if row else {} |
| | | "user_id": str(row[4]), "doc_num": row[5], "permission": row[6], "embd_id": row[7]} if row else {} |
| | | finally: |
| | | db.close() |
| | | |