From db21bab73b44e6a5dfc160a891fccc2b2bd95b5c Mon Sep 17 00:00:00 2001 From: aimanmalib <84276911+aimanmalib@users.noreply.github.com> Date: Sat, 6 Jun 2026 17:14:53 +0000 Subject: [PATCH] feat: add Groq, DeepSeek, Together, and Mistral provider presets --- README.md | 4 ++++ src/codeguard/core/config.py | 28 ++++++++++++++++++++++++++++ tests/unit/test_llm_config.py | 31 ++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25d22eb..a3ef179 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ CodeGuard talks to any OpenAI-compatible `/chat/completions` endpoint. Built-in | OpenAI | `openai` | `gpt-4o-mini` | Bearer | `OPENAI_API_KEY`, `OPENAI_BASE_URL` | | OpenRouter | `openrouter` | `openai/gpt-4o-mini` | Bearer | `OPENROUTER_API_KEY` | | Ollama (local) | `ollama` | `llama3.1` | Bearer | `OLLAMA_BASE_URL` | +| Groq | `groq` | `llama-3.3-70b-versatile` | Bearer | `GROQ_API_KEY` | +| DeepSeek | `deepseek` | `deepseek-chat` | Bearer | `DEEPSEEK_API_KEY` | +| Together | `together` | `meta-llama/Llama-3.3-70B-Instruct-Turbo` | Bearer | `TOGETHER_API_KEY` | +| Mistral | `mistral` | `mistral-small-latest` | Bearer | `MISTRAL_API_KEY` | | Xiaomi MiMo | `mimo` | `mimo-v2.5-pro` | api-key | `MIMO_API_KEY` | Point `base_url` at any other compatible endpoint (llama.cpp, vLLM, LM Studio, a local proxy) and it just works. Code review runs at a low default temperature (0.3) for consistent severity classification regardless of provider. diff --git a/src/codeguard/core/config.py b/src/codeguard/core/config.py index a6e8671..728429a 100644 --- a/src/codeguard/core/config.py +++ b/src/codeguard/core/config.py @@ -45,6 +45,34 @@ "env_key": "OLLAMA_API_KEY", "env_base": "OLLAMA_BASE_URL", }, + "groq": { + "base_url": "https://api.groq.com/openai/v1", + "auth_style": "bearer", + "model": "llama-3.3-70b-versatile", + "env_key": "GROQ_API_KEY", + "env_base": "GROQ_BASE_URL", + }, + "deepseek": { + "base_url": "https://api.deepseek.com/v1", + "auth_style": "bearer", + "model": "deepseek-chat", + "env_key": "DEEPSEEK_API_KEY", + "env_base": "DEEPSEEK_BASE_URL", + }, + "together": { + "base_url": "https://api.together.xyz/v1", + "auth_style": "bearer", + "model": "meta-llama/Llama-3.3-70B-Instruct-Turbo", + "env_key": "TOGETHER_API_KEY", + "env_base": "TOGETHER_BASE_URL", + }, + "mistral": { + "base_url": "https://api.mistral.ai/v1", + "auth_style": "bearer", + "model": "mistral-small-latest", + "env_key": "MISTRAL_API_KEY", + "env_base": "MISTRAL_BASE_URL", + }, } DEFAULT_PROVIDER = "mimo" diff --git a/tests/unit/test_llm_config.py b/tests/unit/test_llm_config.py index 5e97279..885699f 100644 --- a/tests/unit/test_llm_config.py +++ b/tests/unit/test_llm_config.py @@ -15,7 +15,16 @@ class TestProviderPresets: def test_known_providers_present(self): - for provider in ("mimo", "openai", "openrouter", "ollama"): + for provider in ( + "mimo", + "openai", + "openrouter", + "ollama", + "groq", + "deepseek", + "together", + "mistral", + ): assert provider in PROVIDER_PRESETS def test_default_provider_is_mimo(self): @@ -43,6 +52,26 @@ def test_unknown_provider_falls_back_to_default(self): c = LLMConfig(provider="does-not-exist", api_key="x") assert "xiaomimimo.com" in c.base_url + def test_groq_preset(self): + c = LLMConfig(provider="groq", api_key="t") + assert "api.groq.com" in c.base_url + assert c.auth_style == "bearer" + + def test_deepseek_preset(self): + c = LLMConfig(provider="deepseek", api_key="t") + assert "api.deepseek.com" in c.base_url + assert c.auth_style == "bearer" + + def test_together_preset(self): + c = LLMConfig(provider="together", api_key="t") + assert "api.together.xyz" in c.base_url + assert c.auth_style == "bearer" + + def test_mistral_preset(self): + c = LLMConfig(provider="mistral", api_key="t") + assert "api.mistral.ai" in c.base_url + assert c.auth_style == "bearer" + def test_explicit_values_override_preset(self): c = LLMConfig(provider="openai", base_url="https://proxy.local/v1", model="custom") assert c.base_url == "https://proxy.local/v1"