| | |
| | | await update_token(db, user.id, access_token, token_dict) |
| | | result = await pdb.execute(select(AppToken).where(AppToken.id == user.id)) |
| | | db_app_token = result.scalars().first() |
| | | if isinstance(access_token, bytes): |
| | | access_token = access_token.decode() |
| | | if not db_app_token: |
| | | app_token_str = json.dumps(token_dict) |
| | | # print(app_token_str) |
| | | app_token = AppToken(id=user.id, token=access_token.decode(), app_token=app_token_str) |
| | | app_token = AppToken(id=user.id, token=access_token, app_token=app_token_str) |
| | | pdb.add(app_token) |
| | | await pdb.commit() |
| | | await pdb.refresh(app_token) |
| | | else: |
| | | db_app_token.token = access_token.decode() |
| | | db_app_token.token = access_token |
| | | db_app_token.app_token = json.dumps(token_dict) |
| | | await pdb.commit() |
| | | await pdb.refresh(db_app_token) |
| | |
| | | kwargs['fwr_base_url'] = kwargs.get('fwr_base_url', '').replace('127.0.0.1', host_ip) |
| | | kwargs['sgb_db_url'] = kwargs.get('sgb_db_url', '').replace('127.0.0.1', host_ip) |
| | | kwargs['fwr_db_url'] = kwargs.get('fwr_db_url', '').replace('127.0.0.1', host_ip) |
| | | kwargs['dify_base_url'] = kwargs.get('dify_base_url', '').replace('127.0.0.1', host_ip) |
| | | kwargs['basic_base_url'] = kwargs.get('basic_base_url', '').replace('127.0.0.1', host_ip) |
| | | # Check if all required fields are provided and set them |
| | | for field in self.__annotations__.keys(): |
| | | if field not in kwargs: |
| | |
| | | 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.119:11080 |
| | | database_url: mysql+pymysql://root:infini_rag_flow@192.168.20.119:5455/rag_basic |
| | | database_url: mysql+pymysql://root:infini_rag_flow@192.168.20.119:5455/199c90c51171 |
| | | 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.119:15455/rag_flow |
| | | PUBLIC_KEY: | |
| | |
| | | @staticmethod |
| | | def is_type(record_id, t): |
| | | record = UnifiedAgentModel.get_by_id(record_id) |
| | | return record and record.type == t |
| | | return record and record.type == t |
| | | |
| | | |
| | |
| | | import os |
| | | |
| | | from sqlalchemy import create_engine |
| | | from sqlalchemy import create_engine, text |
| | | from sqlalchemy.ext.declarative import declarative_base |
| | | from sqlalchemy.orm import sessionmaker, Session |
| | | |
| | | from app.config.config import settings |
| | | # from app.models.agent_model import AgentModel |
| | | |
| | | DATABASE_URL = os.getenv('DATABASE_URL') or settings.database_url |
| | | |
| | |
| | | |
| | | # 创建所有表(如果有新的模型类,会自动创建相应的表) |
| | | def init_db(): |
| | | try: |
| | | sql = text('DROP TABLE IF EXISTS agent;') |
| | | engine.execute(sql) |
| | | except Exception as e: |
| | | print(e) |
| | | |
| | | Base.metadata.create_all(bind=engine) |
| | | |
| | | |
| | |
| | | try: |
| | | yield db |
| | | finally: |
| | | db.close() |
| | | db.close() |
| | | |
| | | |
| | | # def drop_table(): |
| | | # sql = text('DROP TABLE IF EXISTS agent;') |
| | | # engine.execute(sql) |
| | |
| | | try: |
| | | count = db.query(AgentModel).count() |
| | | if count > 0: |
| | | return |
| | | # 删除表中的所有数据 |
| | | result = db.query(AgentModel).delete() |
| | | db.commit() # 提交事务 |
| | | |
| | | initial_agents = [ |
| | | ('80ee430a-e396-48c4-a12c-7c7cdf5eda51', 1, '报告生成', 'BISHENG', 'report'), |
| | | ('basic_excel_merge', 2, '报表合并', 'BASIC', 'excelMerge'), |
| | | ('bfd090d589d811efb3630242ac190006', 4, '文档智能', 'BISHENG', 'report'), |
| | | ('da3451da89d911efb9490242ac190006', 3, '知识问答', 'RAGFLOW', 'knowledgeQA'), |
| | | ('e96eb7a589db11ef87d20242ac190006', 5, '智能问答', 'RAGFLOW', 'chat'), |
| | | ('basic_excel_talk', 6, '智能数据', 'BASIC', 'excelTalk'), |
| | | ('basic_question_talk', 7, '出题组卷', 'BASIC', 'questionTalk'), |
| | | ('9d75142a-66eb-4e23-b7d4-03efe4584915', 8, '小数绘图', 'DIFY', 'imageTalk'), |
| | | ('basic_paper_talk', 8, '文档出卷', 'BASIC', 'paperTalk') |
| | | ('basic_report_clean', 6, '文档报告', 'DIFY', 'reportWorkflow') |
| | | # ('basic_excel_talk', 6, '智能数据', 'BASIC', 'excelTalk'), |
| | | # ('basic_question_talk', 7, '出题组卷', 'BASIC', 'questionTalk'), |
| | | # ('9d75142a-66eb-4e23-b7d4-03efe4584915', 8, '小数绘图', 'DIFY', 'imageTalk'), |
| | | # ('basic_paper_talk', 8, '文档出卷', 'BASIC', 'paperTalk') |
| | | ] |
| | | |
| | | for agent in initial_agents: |