Skip to content

Conversation

@Rafael-Fortes
Copy link

Description

This PR adds support for Groq as a new LLM provider for the Obsidian Quiz Generator. Groq offers ultra-fast inference with free tier access to popular open-source models including Llama, Mixtral, and Gemma.

Motivation

Groq provides:

  • Ultra-fast inference: One of the fastest LLM inference platforms available
  • Free tier access: Generous free tier for users to try the service
  • Popular models: Access to Llama 3.3, Llama 3.1, Mixtral, and Gemma models
  • OpenAI compatibility: Easy integration using existing OpenAI SDK

Changes Made

New Files Created

Generator Implementation

  • src/generators/groq/groqModels.ts - Defines all available Groq text generation models
  • src/generators/groq/groqGenerator.ts - Implements the GroqGenerator class

Settings Configuration

  • src/settings/model/groq/groqConfig.ts - Configuration interface and defaults
  • src/settings/model/groq/groqSettings.ts - Settings UI component

Modified Files

Core Integration

  • src/generators/providers.ts - Added GROQ to Provider enum
  • src/generators/generatorFactory.ts - Added GroqGenerator to factory map

Settings Integration

  • src/settings/model/modelConfig.ts - Integrated Groq configuration
  • src/settings/model/modelSettings.ts - Added Groq settings UI

Documentation

  • README.md - Added Groq to Supported Providers section

Supported Models

The implementation includes all 10 current Groq text generation models:

  1. Llama 3.3 70B Versatile (default)
  2. Llama 3.1 70B Versatile
  3. Llama 3.1 8B Instant
  4. Llama 3.2 1B Preview
  5. Llama 3.2 3B Preview
  6. Llama 3.2 11B Text Preview
  7. Llama 3.2 90B Text Preview
  8. Mixtral 8x7B 32768
  9. Gemma 2 9B IT
  10. Gemma 7B IT

Technical Implementation

API Compatibility

Groq provides an OpenAI-compatible API, allowing use of the existing OpenAI SDK with a custom baseURL (https://api.groq.com/openai/v1). This approach:

  • Minimizes code duplication
  • Ensures maintainability
  • Follows existing project patterns

Code Patterns

The implementation follows established patterns from existing providers:

  • Generator structure similar to PerplexityGenerator (both lack embedding support)
  • Settings UI pattern similar to OpenAISettings
  • Consistent TypeScript typing and error handling
  • Proper integration with the factory pattern

Limitations

  • No Embedding Support: Groq currently does not provide embedding models, so grading for short and long answer questions is not available. Users attempting to use these question types will receive a clear error message directing them to use a provider with embedding support.

Testing

  • ✅ No linter errors
  • ✅ TypeScript compilation successful
  • ✅ Build completes without errors
  • ✅ Follows existing code patterns and conventions
  • ✅ All files follow project structure

How to Test

  1. Checkout this PR branch
  2. Run npm install and npm run build
  3. Enable the plugin in Obsidian
  4. Go to Settings → Quiz Generator → Model
  5. Select "Groq" from the Provider dropdown
  6. Enter your Groq API key (get one at console.groq.com)
  7. Select a model from the dropdown
  8. Test quiz generation with your notes

Breaking Changes

None. This is a purely additive change that adds a new provider option without modifying existing functionality.

Checklist

  • Code follows the project's coding style
  • All new files follow existing patterns
  • TypeScript types are properly defined
  • No linter errors
  • Build succeeds
  • Documentation updated (README.md)
  • No breaking changes

Additional Notes

  • The implementation can be easily extended to support embedding models if/when Groq adds them to their API
  • The model list in groqModels.ts can be easily updated as Groq releases new models
  • Settings include a "restore default" button for the base URL, matching other providers

Thank you for considering this contribution!

- Add GroqGenerator implementation using OpenAI-compatible API
- Support for Llama 3.3, Llama 3.1, Llama 3.2, Mixtral, and Gemma models
- Add settings UI for API key, base URL, and model selection
- Update README with Groq in Supported Providers section
- No embedding support (similar to Perplexity provider)

Groq offers ultra-fast inference with free tier access, making it a
valuable addition for users seeking fast and cost-effective quiz generation.
Copy link

@LipeLou LipeLou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

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.

3 participants