NoeMartinezSanchez commited on
Commit
fbe249f
·
1 Parent(s): 94252ff

Coreccion de metodos que se llamaban y hacian que la aplicacion se cayera

Browse files
Files changed (2) hide show
  1. api/main.py +3 -2
  2. models/gemma_wrapper.py +17 -1
api/main.py CHANGED
@@ -140,12 +140,13 @@ async def chat(request: ChatRequest):
140
  logger.info(f"🔍 DEBUG - sources count: {len(sources) if sources else 0}")
141
  logger.info(f"📤 Respuesta generada: {'RAG' if is_rag else 'Intent'} - Confianza: {confidence:.2%}")
142
 
143
- # Crear respuesta - NO mostrar confianza al usuario
 
144
  response = ChatResponse(
145
  response=response_text,
146
  sources=sources,
147
  is_rag_response=is_rag,
148
- confidence=None # Ocultar confianza del usuario
149
  )
150
 
151
  # Almacenar conversación
 
140
  logger.info(f"🔍 DEBUG - sources count: {len(sources) if sources else 0}")
141
  logger.info(f"📤 Respuesta generada: {'RAG' if is_rag else 'Intent'} - Confianza: {confidence:.2%}")
142
 
143
+ # Crear respuesta
144
+ conf_value = confidence if confidence is not None else 0.5
145
  response = ChatResponse(
146
  response=response_text,
147
  sources=sources,
148
  is_rag_response=is_rag,
149
+ confidence=conf_value
150
  )
151
 
152
  # Almacenar conversación
models/gemma_wrapper.py CHANGED
@@ -399,4 +399,20 @@ Responde de forma clara y útil en español. Si no tienes información suficient
399
  "dtype": "float32",
400
  "parameters": "2B",
401
  "quantization": "none",
402
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  "dtype": "float32",
400
  "parameters": "2B",
401
  "quantization": "none",
402
+ }
403
+
404
+ def _clean_response(self, text: str) -> str:
405
+ """Clean response text - fix formatting issues.
406
+
407
+ Args:
408
+ text: Raw response text.
409
+
410
+ Returns:
411
+ Cleaned response text.
412
+ """
413
+ if not text:
414
+ return text
415
+ text = text.lstrip()
416
+ if text and text[0].islower():
417
+ text = text[0].upper() + text[1:]
418
+ return text