From 7ee38c3bbcdd563ab941cf6a7dfa7165abb35460 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 25 十月 2024 16:24:35 +0800
Subject: [PATCH] 改名
---
app/api/agent.py | 35 ++++++++++++++---------------------
1 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/app/api/agent.py b/app/api/agent.py
index cded0f8..2879506 100644
--- a/app/api/agent.py
+++ b/app/api/agent.py
@@ -1,3 +1,5 @@
+import uuid
+
from fastapi import Depends, APIRouter, Query, HTTPException
from pydantic import BaseModel
from sqlalchemy.orm import Session
@@ -14,27 +16,10 @@
router = APIRouter()
-# Pydantic 妯″瀷鐢ㄤ簬鍝嶅簲
-class AgentResponse(BaseModel):
- id: str
- name: str
- agent_type: AgentType
-
- class Config:
- orm_mode = True
-
-
@router.get("/list", response_model=ResponseList)
async def agent_list(db: Session = Depends(get_db)):
- agents = db.query(AgentModel).all()
- result = [
- {
- "id": item.id,
- "name": item.name,
- "agent_type": item.agent_type
- }
- for item in agents
- ]
+ agents = db.query(AgentModel).order_by(AgentModel.sort.asc()).all()
+ result = [item.to_dict() for item in agents]
return ResponseList(code=200, msg="", data=result)
@@ -45,7 +30,7 @@
return ResponseList(code=404, msg="Agent not found")
if agent.agent_type == AgentType.RAGFLOW:
- ragflow_service = RagflowService(base_url=settings.ragflow_base_url)
+ ragflow_service = RagflowService(base_url=settings.fwr_base_url)
try:
token = get_ragflow_token(db, current_user.id)
result = await ragflow_service.get_chat_sessions(token, agent_id)
@@ -54,7 +39,7 @@
return ResponseList(code=200, msg="", data=result)
elif agent.agent_type == AgentType.BISHENG:
- bisheng_service = BishengService(base_url=settings.bisheng_base_url)
+ bisheng_service = BishengService(base_url=settings.sgb_base_url)
try:
token = get_bisheng_token(db, current_user.id)
result = await bisheng_service.get_chat_sessions(token)
@@ -65,3 +50,11 @@
else:
return ResponseList(code=200, msg="Unsupported agent type")
+
+@router.get("/get-chat-id/{agent_id}", response_model=Response)
+async def get_chat_id(agent_id: str, db: Session = Depends(get_db)):
+ agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first()
+ if not agent:
+ return Response(code=404, msg="Agent not found")
+
+ return Response(code=200, msg="", data={"chat_id": uuid.uuid4().hex})
--
Gitblit v1.8.0