Skip to content

feat(api): add configurable AI models and improve error messaging - #8

Open
nandes007 wants to merge 1 commit into
honestyan:mainfrom
nandes007:feat/configurable-models-and-better-errors
Open

feat(api): add configurable AI models and improve error messaging#8
nandes007 wants to merge 1 commit into
honestyan:mainfrom
nandes007:feat/configurable-models-and-better-errors

Conversation

@nandes007

Copy link
Copy Markdown

Description of Changes

1. Root Cause / Problem Addressed

  • Hardcoded & Deprecated Model IDs: Previously, groqClient used hardcoded models and geminiClient had a hardcoded endpoint (gemini-2.5-flash). When model availability changes or when models are deprecated/inaccessible on a user tier, requests fail with 404 Not Found.
  • Vague & Masked Error Messages: Axios errors were caught by reading only error.message (which outputs generic strings like Request failed with status code 404), completely discarding the detailed error payload from Groq/Gemini (error.response.data.error.message).

2. Summary of Adjustments

  • Configurable Models:
    • Added GROQ_MODEL (defaults to openai/gpt-oss-120b) and GEMINI_MODEL (defaults to gemini-3.6-flash) in src/config.ts.
    • Added support for configuring models via malas setConfig <KEY> <VALUE>, environment variables (GROQ_MODEL, GEMINI_MODEL), and CLI flags (-m, --model) on malas, malas generate, and malas pr.
  • Human-Readable Error Messages:
    • Enhanced error handling in groqClient.ts and geminiClient.ts using axios.isAxiosError to extract the actual API error message.
    • Formatted specific, actionable error messages for HTTP 401 (invalid API key), 404 (model not found/deprecated with command suggestions), and 429 (rate limit/quota exceeded).
    • Cleaned up error cascades and fallback messaging in aiClient.ts and commitService.ts.
  • Test Suite:
    • Added tests/aiClients.test.ts to test client error handling, status code mappings, and model parameters.
    • Updated tests/commitService.test.ts to align with the current prompt and test model propagation.

Related Issues

N/A

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation update

Testing Information

  • Ran unit tests with Jest: npm test (11/11 tests passing across 2 test suites).
  • Built project: npm run build (TypeScript compilation and import extension fixes).
  • Verified live end-to-end completions with active Groq and Gemini APIs.

@nandes007
nandes007 requested a review from honestyan as a code owner August 20, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant