Álvaro Valenzuela Valdes commited on
Commit
583ea7d
·
1 Parent(s): b25238b

fix: chat response visibility and backend fallback

Browse files
backend/app/routers/analysis.py CHANGED
@@ -53,4 +53,6 @@ async def agent_chat(request: ChatRequest):
53
  )
54
 
55
  response = await call_gemini_with_model(prompt, request.model)
 
 
56
  return {"response": response}
 
53
  )
54
 
55
  response = await call_gemini_with_model(prompt, request.model)
56
+ if not response:
57
+ response = "Lo siento, tuve un problema procesando tu solicitud. ¿Podrías intentar de nuevo?"
58
  return {"response": response}
frontend/components/AgentChat.tsx CHANGED
@@ -44,6 +44,7 @@ export default function AgentChat({ tender, companyProfile }: Props) {
44
  ];
45
 
46
  const simulateTyping = (text: string, agentName: string) => {
 
47
  setIsTyping(true);
48
  let currentText = "";
49
  const words = text.split(" ");
@@ -64,7 +65,7 @@ export default function AgentChat({ tender, companyProfile }: Props) {
64
  clearInterval(interval);
65
  setIsTyping(false);
66
  }
67
- }, 40);
68
  };
69
 
70
  useEffect(() => {
@@ -164,17 +165,17 @@ export default function AgentChat({ tender, companyProfile }: Props) {
164
  )}
165
  {messages.map((msg, i) => (
166
  <div key={i} className={`flex ${msg.role === 'user' ? 'justify-end' : 'justify-start'}`}>
167
- <div className={`max-w-[80%] rounded-2xl px-5 py-3 text-sm ${
168
  msg.role === 'user'
169
  ? 'bg-purple-600 text-white rounded-tr-none'
170
- : 'bg-white/10 text-slate-200 border border-white/10 rounded-tl-none'
171
  }`}>
172
  {msg.role === 'assistant' && (
173
  <div className="text-[10px] font-black uppercase text-purple-400 mb-1 tracking-widest">
174
  {msg.agent}
175
  </div>
176
  )}
177
- <p className="leading-relaxed whitespace-pre-wrap">{msg.content}</p>
178
  </div>
179
  </div>
180
  ))}
 
44
  ];
45
 
46
  const simulateTyping = (text: string, agentName: string) => {
47
+ if (!text) return; // Don't simulate empty text
48
  setIsTyping(true);
49
  let currentText = "";
50
  const words = text.split(" ");
 
65
  clearInterval(interval);
66
  setIsTyping(false);
67
  }
68
+ }, 20); // Faster typing
69
  };
70
 
71
  useEffect(() => {
 
165
  )}
166
  {messages.map((msg, i) => (
167
  <div key={i} className={`flex ${msg.role === 'user' ? 'justify-end' : 'justify-start'}`}>
168
+ <div className={`max-w-[80%] rounded-2xl px-6 py-4 text-[13px] shadow-lg ${
169
  msg.role === 'user'
170
  ? 'bg-purple-600 text-white rounded-tr-none'
171
+ : 'bg-white/10 text-white border border-white/20 rounded-tl-none backdrop-blur-md'
172
  }`}>
173
  {msg.role === 'assistant' && (
174
  <div className="text-[10px] font-black uppercase text-purple-400 mb-1 tracking-widest">
175
  {msg.agent}
176
  </div>
177
  )}
178
+ <p className="leading-relaxed whitespace-pre-wrap min-h-[1.25em] text-white/90">{msg.content}</p>
179
  </div>
180
  </div>
181
  ))}