Ali2206 commited on
Commit
0f18196
·
1 Parent(s): 2e659cd

Integrate TxAgent into CPS API: add TxAgent files, update requirements, fix imports and database collections

Browse files
Files changed (1) hide show
  1. api/routes/txagent.py +6 -6
api/routes/txagent.py CHANGED
@@ -147,7 +147,7 @@ class RiskLevel(BaseModel):
147
 
148
  router = APIRouter(prefix="/txagent", tags=["TxAgent"])
149
 
150
- @router.get("/txagent/status")
151
  async def status(current_user: dict = Depends(get_current_user)):
152
  logger.info(f"Status endpoint accessed by {current_user['email']}")
153
  return {
@@ -157,7 +157,7 @@ async def status(current_user: dict = Depends(get_current_user)):
157
  "features": ["chat", "voice-input", "voice-output", "patient-analysis", "report-upload", "patient-reports-pdf", "all-patients-reports-pdf"]
158
  }
159
 
160
- @router.get("/txagent/patients/analysis-results")
161
  async def get_patient_analysis_results(
162
  name: Optional[str] = Query(None),
163
  current_user: dict = Depends(get_current_user)
@@ -198,7 +198,7 @@ async def get_patient_analysis_results(
198
  logger.error(f"Error fetching analysis results: {e}")
199
  return []
200
 
201
- @router.post("/txagent/chat")
202
  async def chat_with_txagent(
203
  request: ChatRequest,
204
  current_user: dict = Depends(get_current_user)
@@ -221,7 +221,7 @@ async def chat_with_txagent(
221
  logger.error(f"Error in TxAgent chat: {e}")
222
  raise HTTPException(status_code=500, detail="Failed to process chat request")
223
 
224
- @router.post("/txagent/voice/transcribe")
225
  async def transcribe_audio(
226
  audio: UploadFile = File(...),
227
  current_user: dict = Depends(get_current_user)
@@ -241,7 +241,7 @@ async def transcribe_audio(
241
  logger.error(f"Error in voice transcription: {e}")
242
  raise HTTPException(status_code=500, detail="Failed to transcribe audio")
243
 
244
- @router.post("/txagent/voice/synthesize")
245
  async def synthesize_speech(
246
  request: VoiceOutputRequest,
247
  current_user: dict = Depends(get_current_user)
@@ -263,7 +263,7 @@ async def synthesize_speech(
263
  logger.error(f"Error in voice synthesis: {e}")
264
  raise HTTPException(status_code=500, detail="Failed to synthesize speech")
265
 
266
- @router.get("/txagent/chats")
267
  async def get_chats(current_user: dict = Depends(get_current_user)):
268
  """Obtient l'historique des chats"""
269
  try:
 
147
 
148
  router = APIRouter(prefix="/txagent", tags=["TxAgent"])
149
 
150
+ @router.get("/status")
151
  async def status(current_user: dict = Depends(get_current_user)):
152
  logger.info(f"Status endpoint accessed by {current_user['email']}")
153
  return {
 
157
  "features": ["chat", "voice-input", "voice-output", "patient-analysis", "report-upload", "patient-reports-pdf", "all-patients-reports-pdf"]
158
  }
159
 
160
+ @router.get("/patients/analysis-results")
161
  async def get_patient_analysis_results(
162
  name: Optional[str] = Query(None),
163
  current_user: dict = Depends(get_current_user)
 
198
  logger.error(f"Error fetching analysis results: {e}")
199
  return []
200
 
201
+ @router.post("/chat")
202
  async def chat_with_txagent(
203
  request: ChatRequest,
204
  current_user: dict = Depends(get_current_user)
 
221
  logger.error(f"Error in TxAgent chat: {e}")
222
  raise HTTPException(status_code=500, detail="Failed to process chat request")
223
 
224
+ @router.post("/voice/transcribe")
225
  async def transcribe_audio(
226
  audio: UploadFile = File(...),
227
  current_user: dict = Depends(get_current_user)
 
241
  logger.error(f"Error in voice transcription: {e}")
242
  raise HTTPException(status_code=500, detail="Failed to transcribe audio")
243
 
244
+ @router.post("/voice/synthesize")
245
  async def synthesize_speech(
246
  request: VoiceOutputRequest,
247
  current_user: dict = Depends(get_current_user)
 
263
  logger.error(f"Error in voice synthesis: {e}")
264
  raise HTTPException(status_code=500, detail="Failed to synthesize speech")
265
 
266
+ @router.get("/chats")
267
  async def get_chats(current_user: dict = Depends(get_current_user)):
268
  """Obtient l'historique des chats"""
269
  try: