luanpoppe commited on
Commit
5ea29d8
·
1 Parent(s): 68ee60a

feat: convertendo texto final de markdown para html + melhorando custom exception handler

Browse files
_utils/custom_exception_handler.py CHANGED
@@ -1,9 +1,10 @@
1
  # myapp/exception_handler.py
2
 
 
 
3
  from typing import Dict
4
  from rest_framework.views import exception_handler
5
  import logging
6
-
7
  from _utils.bubble_integrations.enviar_resposta_final import enviar_resposta_final
8
 
9
  logger = logging.getLogger(__name__)
@@ -35,12 +36,13 @@ def custom_exception_handler(exc, context):
35
  return response
36
 
37
  def custom_exception_handler_wihout_api_handler(error, serializer: Dict):
 
38
  print("INICIANDO RESPOSTA DE ERRO PARA O BUBBLE")
39
  resposta_bubble = enviar_resposta_final(
40
  serializer.get("doc_id", ""),
41
  serializer.get("form_response_id", ""),
42
  serializer.get("version", ""),
43
- serializer.get("texto_completo", ""),
44
  True,
45
  )
46
  print("\n\nresposta_bubble.status_code", resposta_bubble.status_code)
 
1
  # myapp/exception_handler.py
2
 
3
+ from datetime import datetime
4
+ import pytz
5
  from typing import Dict
6
  from rest_framework.views import exception_handler
7
  import logging
 
8
  from _utils.bubble_integrations.enviar_resposta_final import enviar_resposta_final
9
 
10
  logger = logging.getLogger(__name__)
 
36
  return response
37
 
38
  def custom_exception_handler_wihout_api_handler(error, serializer: Dict):
39
+ bahia_tz = pytz.timezone("America/Bahia")
40
  print("INICIANDO RESPOSTA DE ERRO PARA O BUBBLE")
41
  resposta_bubble = enviar_resposta_final(
42
  serializer.get("doc_id", ""),
43
  serializer.get("form_response_id", ""),
44
  serializer.get("version", ""),
45
+ f"------------ ERRO NO BACKEND ÀS {datetime.now(bahia_tz).strftime("%d/%m/%Y - %H:%M:%S")} ------------:\nMensagem de erro: {error} ", # serializer.get("texto_completo", ""),
46
  True,
47
  )
48
  print("\n\nresposta_bubble.status_code", resposta_bubble.status_code)
_utils/gerar_relatorio_modelo_usuario/contextual_retriever.py CHANGED
@@ -88,7 +88,7 @@ class ContextualRetriever:
88
  print("COMEÇANDO UMA REQUISIÇÃO DO CONTEXTUAL")
89
  # raw_response = await agpt_answer(prompt)
90
  # raw_response = await agemini_answer(prompt, "gemini-2.0-flash-lite-preview-02-05")
91
- raw_response = await agemini_answer(prompt, "gemini-2.0-flash-lite")
92
 
93
  print("TERMINOU UMA REQUISIÇÃO DO CONTEXTUAL")
94
  response = cast(str, raw_response)
 
88
  print("COMEÇANDO UMA REQUISIÇÃO DO CONTEXTUAL")
89
  # raw_response = await agpt_answer(prompt)
90
  # raw_response = await agemini_answer(prompt, "gemini-2.0-flash-lite-preview-02-05")
91
+ raw_response = await agemini_answer(prompt, "gemini-2.0-flash-li")
92
 
93
  print("TERMINOU UMA REQUISIÇÃO DO CONTEXTUAL")
94
  response = cast(str, raw_response)
_utils/resumo_completo_cursor.py CHANGED
@@ -16,7 +16,7 @@ from _utils.gerar_relatorio_modelo_usuario.utils import (
16
  from _utils.models.gerar_relatorio import (
17
  RetrievalConfig,
18
  )
19
-
20
 
21
  def reciprocal_rank_fusion(result_lists, weights=None):
22
  """Combine multiple ranked lists using reciprocal rank fusion"""
@@ -134,7 +134,7 @@ async def get_llm_summary_answer_by_cursor_complete(
134
  print("TERMINOU A REQUISIÇÃO FINAL PARA O BUBBLE")
135
 
136
  return {
137
- "texto_completo": texto_completo,
138
  "resultado": structured_summaries,
139
  "parametros-utilizados": gerar_resposta_compilada(serializer),
140
  }
 
16
  from _utils.models.gerar_relatorio import (
17
  RetrievalConfig,
18
  )
19
+ import markdown
20
 
21
  def reciprocal_rank_fusion(result_lists, weights=None):
22
  """Combine multiple ranked lists using reciprocal rank fusion"""
 
134
  print("TERMINOU A REQUISIÇÃO FINAL PARA O BUBBLE")
135
 
136
  return {
137
+ "texto_completo": markdown.markdown(texto_completo),
138
  "resultado": structured_summaries,
139
  "parametros-utilizados": gerar_resposta_compilada(serializer),
140
  }