anderson-ufrj commited on
Commit
1edd4d6
·
1 Parent(s): 288f06d

fix: correct all IntentType enum values in chat_stable

Browse files

- Change ANALYSIS to ANALYZE to match enum definition
- Fix all occurrences in conditions and mappings
- Resolves AttributeError: ANALYSIS in HuggingFace deployment

Files changed (1) hide show
  1. src/api/routes/chat_stable.py +5 -5
src/api/routes/chat_stable.py CHANGED
@@ -67,7 +67,7 @@ FALLBACK_RESPONSES = {
67
  "Vou ajudar você a investigar os gastos públicos. Temos dados sobre contratos, fornecedores e órgãos públicos. Por onde gostaria de começar?",
68
  "Perfeito! Posso analisar contratos e despesas públicas. Me diga qual órgão, período ou tipo de gasto você quer investigar."
69
  ],
70
- IntentType.ANALYSIS: [
71
  "Vou analisar essas informações para você. Nossa plataforma examina padrões de gastos, identifica anomalias e fornece insights sobre transparência pública.",
72
  "Certo, vou fazer uma análise detalhada. Posso examinar tendências, comparar fornecedores e identificar possíveis irregularidades nos dados públicos.",
73
  "Entendido! Farei uma análise completa dos dados solicitados, incluindo padrões de gastos e possíveis pontos de atenção."
@@ -110,7 +110,7 @@ async def process_with_maritaca(message: str, intent_type: IntentType, session_i
110
 
111
  if intent_type == IntentType.INVESTIGATE:
112
  system_prompt += "\nO usuário quer investigar gastos. Seja específico sobre como você pode ajudar."
113
- elif intent_type == IntentType.ANALYSIS:
114
  system_prompt += "\nO usuário quer uma análise. Explique que tipo de análise você pode fornecer."
115
 
116
  messages = [
@@ -190,7 +190,7 @@ async def chat_stable(request: ChatRequest) -> ChatResponse:
190
  elif any(word in message_lower for word in ["investigar", "verificar", "buscar", "procurar"]):
191
  intent_type = IntentType.INVESTIGATE
192
  elif any(word in message_lower for word in ["analisar", "análise", "examinar"]):
193
- intent_type = IntentType.ANALYSIS
194
  elif any(word in message_lower for word in ["ajuda", "help", "como", "o que"]):
195
  intent_type = IntentType.HELP
196
  else:
@@ -211,7 +211,7 @@ async def chat_stable(request: ChatRequest) -> ChatResponse:
211
  agent_info = {
212
  IntentType.GREETING: ("drummond", "Carlos Drummond"),
213
  IntentType.INVESTIGATE: ("zumbi", "Zumbi dos Palmares"),
214
- IntentType.ANALYSIS: ("anita", "Anita Garibaldi"),
215
  IntentType.HELP: ("drummond", "Carlos Drummond"),
216
  IntentType.REPORT: ("tiradentes", "Tiradentes"),
217
  IntentType.UNKNOWN: ("drummond", "Carlos Drummond")
@@ -223,7 +223,7 @@ async def chat_stable(request: ChatRequest) -> ChatResponse:
223
  suggested_actions = {
224
  IntentType.GREETING: ["investigate_contracts", "view_recent_expenses", "help"],
225
  IntentType.INVESTIGATE: ["filter_by_date", "filter_by_agency", "view_suppliers"],
226
- IntentType.ANALYSIS: ["generate_report", "view_charts", "compare_periods"],
227
  IntentType.HELP: ["start_investigation", "learn_more", "examples"],
228
  IntentType.REPORT: ["download_pdf", "share_report", "new_analysis"],
229
  IntentType.UNKNOWN: ["help", "examples", "start_investigation"]
 
67
  "Vou ajudar você a investigar os gastos públicos. Temos dados sobre contratos, fornecedores e órgãos públicos. Por onde gostaria de começar?",
68
  "Perfeito! Posso analisar contratos e despesas públicas. Me diga qual órgão, período ou tipo de gasto você quer investigar."
69
  ],
70
+ IntentType.ANALYZE: [
71
  "Vou analisar essas informações para você. Nossa plataforma examina padrões de gastos, identifica anomalias e fornece insights sobre transparência pública.",
72
  "Certo, vou fazer uma análise detalhada. Posso examinar tendências, comparar fornecedores e identificar possíveis irregularidades nos dados públicos.",
73
  "Entendido! Farei uma análise completa dos dados solicitados, incluindo padrões de gastos e possíveis pontos de atenção."
 
110
 
111
  if intent_type == IntentType.INVESTIGATE:
112
  system_prompt += "\nO usuário quer investigar gastos. Seja específico sobre como você pode ajudar."
113
+ elif intent_type == IntentType.ANALYZE:
114
  system_prompt += "\nO usuário quer uma análise. Explique que tipo de análise você pode fornecer."
115
 
116
  messages = [
 
190
  elif any(word in message_lower for word in ["investigar", "verificar", "buscar", "procurar"]):
191
  intent_type = IntentType.INVESTIGATE
192
  elif any(word in message_lower for word in ["analisar", "análise", "examinar"]):
193
+ intent_type = IntentType.ANALYZE
194
  elif any(word in message_lower for word in ["ajuda", "help", "como", "o que"]):
195
  intent_type = IntentType.HELP
196
  else:
 
211
  agent_info = {
212
  IntentType.GREETING: ("drummond", "Carlos Drummond"),
213
  IntentType.INVESTIGATE: ("zumbi", "Zumbi dos Palmares"),
214
+ IntentType.ANALYZE: ("anita", "Anita Garibaldi"),
215
  IntentType.HELP: ("drummond", "Carlos Drummond"),
216
  IntentType.REPORT: ("tiradentes", "Tiradentes"),
217
  IntentType.UNKNOWN: ("drummond", "Carlos Drummond")
 
223
  suggested_actions = {
224
  IntentType.GREETING: ["investigate_contracts", "view_recent_expenses", "help"],
225
  IntentType.INVESTIGATE: ["filter_by_date", "filter_by_agency", "view_suppliers"],
226
+ IntentType.ANALYZE: ["generate_report", "view_charts", "compare_periods"],
227
  IntentType.HELP: ["start_investigation", "learn_more", "examples"],
228
  IntentType.REPORT: ["download_pdf", "share_report", "new_analysis"],
229
  IntentType.UNKNOWN: ["help", "examples", "start_investigation"]