diff --git a/internal/chat/handler.go b/internal/chat/handler.go index 1dd296b..37bb57c 100644 --- a/internal/chat/handler.go +++ b/internal/chat/handler.go @@ -144,8 +144,11 @@ func (h *Handler) HandleChat(w http.ResponseWriter, r *http.Request) { if err != nil { log.Printf("Chat agent error: %v", err) w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.WriteHeader(http.StatusInternalServerError) - _, _ = fmt.Fprint(w, `
Something went wrong. Please try again.
`) + errMsg := "Something went wrong. Please try again in a moment." + if strings.Contains(err.Error(), "429") || strings.Contains(err.Error(), "RESOURCE_EXHAUSTED") { + errMsg = "The AI service is temporarily busy. Please try again in a few seconds." + } + _, _ = fmt.Fprintf(w, `
%s
`, errMsg) return } if event.IsFinalResponse() { diff --git a/templates/partials/modals/chat-help-modal.html b/templates/partials/modals/chat-help-modal.html index 52c2ea1..25b8805 100644 --- a/templates/partials/modals/chat-help-modal.html +++ b/templates/partials/modals/chat-help-modal.html @@ -31,10 +31,10 @@ {{if eq .Lang "es"}}Experiencia{{else}}Experience{{end}}
- - - - + + + +
@@ -45,11 +45,11 @@ {{if eq .Lang "es"}}Tecnologías{{else}}Technologies{{end}}
- - - - - + + + + +
@@ -60,9 +60,9 @@ {{if eq .Lang "es"}}Proyectos{{else}}Projects{{end}}
- - - + + +
@@ -73,9 +73,9 @@ {{if eq .Lang "es"}}Formación{{else}}Education{{end}}
- - - + + +
@@ -86,9 +86,9 @@ {{if eq .Lang "es"}}Habilidades{{else}}Skills{{end}}
- - - + + +
diff --git a/templates/partials/widgets/chat-widget.html b/templates/partials/widgets/chat-widget.html index 761f0c0..41d3984 100644 --- a/templates/partials/widgets/chat-widget.html +++ b/templates/partials/widgets/chat-widget.html @@ -6,14 +6,7 @@ class="chat-toggle-btn no-print has-tooltip tooltip-left" aria-label="{{if eq .Lang "es"}}Asistente del CV{{else}}CV Assistant{{end}}" data-tooltip="{{if eq .Lang "es"}}Asistente del CV{{else}}CV Assistant{{end}}" - _="on click toggle .chat-open on #chat-panel - then if #chat-panel matches .chat-open - then add .mascot-active to me - then set #chat-input.focus to true - then call #chat-input.focus() - else - remove .mascot-active from me - end"> + onclick="toggleChatPanel()"> @@ -46,27 +39,17 @@
{{if eq .Lang "es"}} - - - - - + + + + + {{else}} - - - - - + + + + + {{end}}
@@ -74,8 +57,7 @@ hx-post="/api/chat" hx-target="#chat-messages" hx-swap="beforeend scroll:#chat-messages:bottom" - hx-indicator="#chat-typing" - _="on htmx:afterRequest set #chat-input.value to ''"> + hx-indicator="#chat-typing"> + + + {{end}} {{end}}