Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: add support for Groq as a pre-configured LLM (#34402)

Sam87476ce2c18f
diff --git a/plugins/discourse-ai/app/models/llm_model.rb b/plugins/discourse-ai/app/models/llm_model.rb
index 4673771369f..3be95d82dd1 100644
--- a/plugins/discourse-ai/app/models/llm_model.rb
+++ b/plugins/discourse-ai/app/models/llm_model.rb
@@ -59,6 +59,17 @@ class LlmModel < ActiveRecord::Base
default: "default",
},
},
+ groq: {
+ disable_native_tools: :checkbox,
+ disable_temperature: :checkbox,
+ disable_top_p: :checkbox,
+ disable_streaming: :checkbox,
+ reasoning_effort: {
+ type: :enum,
+ values: %w[default minimal low medium high],
+ default: "default",
+ },
+ },
mistral: {
disable_native_tools: :checkbox,
},
diff --git a/plugins/discourse-ai/config/locales/client.en.yml b/plugins/discourse-ai/config/locales/client.en.yml
index c6ed718e8da..d3067955778 100644
--- a/plugins/discourse-ai/config/locales/client.en.yml
+++ b/plugins/discourse-ai/config/locales/client.en.yml
@@ -626,6 +626,8 @@ en:
open_router-x-ai-grok-3-beta: "xAI's latest model"
open_router-deepseek-deepseek-r1-0528-free: "DeepSeek's latest reasoning model"
open_router-meta-llama-3-3-70b-instruct: "Highly capable multilingual model"
+ groq-openai-gpt-oss-120b: "State of the art open-weight model by Open AI"
+ groq-openai-gpt-oss-20b: "Lightweigh, fast, open-weight model by Open AI"
preseeded_model_description: "Pre-configured open-source model utilizing %{model}"
@@ -672,6 +674,7 @@ en:
samba_nova: "SambaNova"
mistral: "Mistral"
open_router: "OpenRouter"
+ groq: "Groq"
fake: "Custom"
provider_fields:
diff --git a/plugins/discourse-ai/lib/completions/endpoints/open_ai.rb b/plugins/discourse-ai/lib/completions/endpoints/open_ai.rb
index 9a4e7c43384..52d698efd17 100644
--- a/plugins/discourse-ai/lib/completions/endpoints/open_ai.rb
+++ b/plugins/discourse-ai/lib/completions/endpoints/open_ai.rb
@@ -5,7 +5,7 @@ module DiscourseAi
module Endpoints
class OpenAi < Base
def self.can_contact?(model_provider)
- %w[open_ai azure].include?(model_provider)
+ %w[open_ai azure groq].include?(model_provider)
end
def normalize_model_params(model_params)
diff --git a/plugins/discourse-ai/lib/completions/llm.rb b/plugins/discourse-ai/lib/completions/llm.rb
index ff31990e804..0f6b1f294ba 100644
--- a/plugins/discourse-ai/lib/completions/llm.rb
+++ b/plugins/discourse-ai/lib/completions/llm.rb
@@ -224,6 +224,30 @@ module DiscourseAi
endpoint: "https://openrouter.ai/api/v1/chat/completions",
provider: "open_router",
},
+ {
+ id: "groq",
+ models: [
+ {
+ name: "openai/gpt-oss-120b",
+ tokens: 131_072,
+ display_name: "GPT-OSS 120B",
+ input_cost: 0.15,
+ output_cost: 0.75,
+ max_output_tokens: 65_536,
+ },
+ {
+ name: "openai/gpt-oss-20b",
+ display_name: "GPT-OSS 20B",
+ tokens: 131_072,
+ input_cost: 0.1,
+ output_cost: 0.5,
+ max_output_tokens: 65_536,
+ },
+ ],
+ tokenizer: DiscourseAi::Tokenizer::OpenAiTokenizer,
+ endpoint: "https://api.groq.com/openai/v1/chat/completions",
+ provider: "groq",
+ },
]
end
end
@@ -241,6 +265,7 @@ module DiscourseAi
samba_nova
mistral
open_router
+ groq
]
if !Rails.env.production?
providers << "fake"