Skip to content

Commit

Permalink
Merge pull request #355 from miurla/support-groq
Browse files Browse the repository at this point in the history
feat: Support Groq AI Provider
  • Loading branch information
miurla authored Sep 30, 2024
2 parents 5df58cf + b0fc9e5 commit e73a537
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ SEARXNG_SAFESEARCH=0 # Safe search setting: 0 (off), 1 (moderate), 2 (strict)
# If you want to use Anthropic instead of OpenAI, enable the following settings.
# ANTHROPIC_API_KEY=[YOUR_ANTHROPIC_API_KEY]

# If you want to use Groq, enable the following variables. only available for tool use compatible models.
# GROQ_API_KEY=[YOUR_GROQ_API_KEY]
# GROQ_API_MODEL=[YOUR_GROQ_API_MODEL] # e.g. llama3-groq-8b-8192-tool-use-preview

# If you want to use Ollama, enable the following variables.
# OLLAMA_MODEL=[YOUR_OLLAMA_MODEL] # The main model to use. Currently compatible: qwen2.5
# OLLAMA_BASE_URL=[YOUR_OLLAMA_URL] # The base URL to use. e.g. http://localhost:11434
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ An AI-powered search engine with a generative UI.
- Azure OpenAI Provider [](https://github.com/miurla/morphic/issues/13)
- Anthropic Provider [](https://github.com/miurla/morphic/pull/239)
- Ollama Provider [](https://github.com/miurla/morphic/issues/215#issuecomment-2381902347)
- Groq Provider
- Local Redis support
- SearXNG Search API support with customizable depth (basic or advanced)
- Configurable search depth (basic or advanced)
Expand Down Expand Up @@ -233,3 +234,6 @@ engines:
- Claude 3.5 Sonnet
- Ollama
- qwen2.5
- Groq
- llama3-groq-8b-8192-tool-use-preview
- llama3-groq-70b-8192-tool-use-preview
11 changes: 11 additions & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export function getModel(useSubModel = false) {
let azureDeploymentName = process.env.AZURE_DEPLOYMENT_NAME || 'gpt-4o'
const googleApiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY
const anthropicApiKey = process.env.ANTHROPIC_API_KEY
const groqApiKey = process.env.GROQ_API_KEY
const groqApiModel = process.env.GROQ_API_MODEL

if (
!(ollamaBaseUrl && ollamaModel) &&
Expand Down Expand Up @@ -63,6 +65,15 @@ export function getModel(useSubModel = false) {
return azure.chat(azureDeploymentName)
}

if (groqApiKey && groqApiModel) {
const groq = createOpenAI({
apiKey: groqApiKey,
baseURL: 'https://api.groq.com/openai/v1'
})

return groq.chat(groqApiModel)
}

// Fallback to OpenAI instead
const openai = createOpenAI({
baseURL: openaiApiBase, // optional base URL for proxies etc.
Expand Down

0 comments on commit e73a537

Please sign in to comment.