gemini/fix/llm-retries #50

Merged
eleith merged 4 commits from gemini/fix/llm-retries into main 2025-08-19 19:01:27 +00:00
4 Commits
Author SHA1 Message Date
eleith 3fd3549560 refactor: abstract LLM retry logic
- Extracts the LLM API call retry logic into a private `generateContentWithRetry` method for improved readability and separation of concerns.
- Defines a `maxRetries` constant for the retry limit.
2025-08-19 19:00:04 +00:00
eleith fd67ec3723 refactor: consolidate template functions
- Moves the `htmlEscape` function from `templates.go` to `funcs.go` to centralize all template functions.
- Renames `nl2br` to `textToHTML` for clarity.
- Updates the templates to use the new function name.
2025-08-19 18:54:45 +00:00
eleith 1c49f731da feat: convert summary newlines to line breaks
Adds a template function to convert newline characters in the digest summary to HTML `<br>` tags, preserving the intended formatting.

The new `nl2br` function also ensures the summary content is HTML-escaped to prevent XSS vulnerabilities.
2025-08-19 18:48:42 +00:00
eleith f6355e2684 feat: add retry logic for overloaded LLM errors
Implements a retry mechanism for when the LLM service returns a 503 "overloaded" error.

The changes include:
- Retrying the API call up to two times (three attempts total).
- A backoff delay that increases with each retry.
- Specific error checking for `*genai.APIError` with a 503 status code and "overloaded" message.
- Logging of LLM API errors to aid in future debugging.
2025-08-19 18:45:41 +00:00