tmp
zhaoqingang
2025-01-15 0bd950c8798958434c5ec61aababb9bbac4d7808
app/service/v2/chat.py
@@ -5,7 +5,7 @@
    DF_CHAT_WORKFLOW
from app.config.config import settings
from app.config.const import *
from app.models import DialogModel, ApiTokenModel
from app.models import DialogModel, ApiTokenModel, UserTokenModel
from app.models.v2.session_model import ChatSessionDao, ChatData
from app.service.v2.app_driver.chat_agent import ChatAgent
from app.service.v2.app_driver.chat_data import ChatBaseApply
@@ -40,6 +40,13 @@
        logger.error(e)
    return None
async def get_app_token(db, app_id):
    app_token = db.query(UserTokenModel).filter_by(id=app_id).first()
    if app_token:
        return app_token.access_token
    return ""
async def get_chat_token(db, app_id):
    app_token = db.query(ApiTokenModel).filter_by(app_id=app_id).first()
@@ -48,6 +55,16 @@
    return ""
async def add_chat_token(db, data):
    try:
        api_token = ApiTokenModel(**data)
        db.add(api_token)
        db.commit()
    except Exception as e:
        logger.error(e)
async def get_chat_info(db, chat_id: str):
    return db.query(DialogModel).filter_by(id=chat_id, status=Dialog_STATSU_ON).first()