| | |
| | | from Log import logger |
| | | from app.api import get_current_user_websocket, ResponseList, get_current_user, format_file_url, process_files |
| | | from app.config.config import settings |
| | | from app.models import MenuCapacityModel |
| | | from app.models.agent_model import AgentModel, AgentType |
| | | from app.models.base_model import get_db |
| | | from app.models.user_model import UserModel |
| | |
| | | chat_id: str, |
| | | current_user: UserModel = Depends(get_current_user_websocket), |
| | | db: Session = Depends(get_db)): |
| | | agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first() |
| | | agent = db.query(MenuCapacityModel).filter(MenuCapacityModel.chat_id == agent_id).first() |
| | | if not agent: |
| | | agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first() |
| | | agent_type = agent.agent_type |
| | | chat_type = agent.type |
| | | else: |
| | | agent_type = agent.capacity_type |
| | | chat_type = agent.chat_type |
| | | if not agent: |
| | | ret = {"message": "Agent not found", "type": "close"} |
| | | return websocket.send_json(ret) |
| | | agent_type = agent.agent_type |
| | | # agent_type = agent.agent_type |
| | | if chat_id == "" or chat_id == "0": |
| | | ret = {"message": "Chat ID not found", "type": "close"} |
| | | return websocket.send_json(ret) |
| | |
| | | ret = {"message": "Agent error", "type": "close"} |
| | | return websocket.send_json(ret) |
| | | |
| | | token = get_bisheng_token(db, current_user.id) |
| | | token = await get_bisheng_token(db, current_user.id) |
| | | service_uri = f"{settings.sgb_websocket_url}/api/v1/chat/{agent_id}?type=L1&t=&chat_id={chat_id}" |
| | | headers = {'cookie': f"access_token_cookie={token};"} |
| | | |
| | |
| | | return ResponseList(code=404, msg="Agent not found") |
| | | bisheng_service = BishengService(base_url=settings.sgb_base_url) |
| | | try: |
| | | token = get_bisheng_token(db, current_user.id) |
| | | token = await get_bisheng_token(db, current_user.id) |
| | | result = await bisheng_service.variable_list(token, agent_id) |
| | | except Exception as e: |
| | | raise HTTPException(status_code=500, detail=str(e)) |