Skip to content

Commit

Permalink
Feature/Add Groq for followup prompts (#3806)
Browse files Browse the repository at this point in the history
Feature/Add-Groq-for-followup-prompts
  • Loading branch information
sunnymodi21 authored Jan 4, 2025
1 parent 1111101 commit 3b13e83
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/components/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ export enum FollowUpPromptProvider {
AZURE_OPENAI = 'azureChatOpenAI',
GOOGLE_GENAI = 'chatGoogleGenerativeAI',
MISTRALAI = 'chatMistralAI',
OPENAI = 'chatOpenAI'
OPENAI = 'chatOpenAI',
GROQ = 'groqChat'
}

export type FollowUpPromptProviderConfig = {
Expand Down
11 changes: 11 additions & 0 deletions packages/components/src/followUpPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ChatOpenAI } from '@langchain/openai'
import { z } from 'zod'
import { PromptTemplate } from '@langchain/core/prompts'
import { StructuredOutputParser } from '@langchain/core/output_parsers'
import { ChatGroq } from '@langchain/groq'

const FollowUpPromptType = z
.object({
Expand Down Expand Up @@ -108,6 +109,16 @@ export const generateFollowUpPrompts = async (
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
return structuredResponse
}
case FollowUpPromptProvider.GROQ: {
const llm = new ChatGroq({
apiKey: credentialData.groqApiKey,
model: providerConfig.modelName,
temperature: parseFloat(`${providerConfig.temperature}`)
})
const structuredLLM = llm.withStructuredOutput(FollowUpPromptType)
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
return structuredResponse
}
}
} else {
return undefined
Expand Down
38 changes: 38 additions & 0 deletions packages/ui/src/ui-component/extended/FollowUpPrompts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import anthropicIcon from '@/assets/images/anthropic.svg'
import azureOpenAiIcon from '@/assets/images/azure_openai.svg'
import mistralAiIcon from '@/assets/images/mistralai.svg'
import openAiIcon from '@/assets/images/openai.svg'
import groqIcon from '@/assets/images/groq.png'
import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser'
import CredentialInputHandler from '@/views/canvas/CredentialInputHandler'
import { Input } from '@/ui-component/input/Input'
Expand All @@ -32,6 +33,7 @@ const FollowUpPromptProviders = {
ANTHROPIC: 'chatAnthropic',
AZURE_OPENAI: 'azureChatOpenAI',
GOOGLE_GENAI: 'chatGoogleGenerativeAI',
GROQ: 'groqChat',
MISTRALAI: 'chatMistralAI',
OPENAI: 'chatOpenAI'
}
Expand Down Expand Up @@ -149,6 +151,42 @@ const followUpPromptsOptions = {
}
]
},
[FollowUpPromptProviders.GROQ]: {
label: 'Groq',
name: FollowUpPromptProviders.GROQ,
icon: groqIcon,
inputs: [
{
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['groqApi']
},
{
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels'
},
{
label: 'Prompt',
name: 'prompt',
type: 'string',
rows: 4,
description: promptDescription,
optional: true,
default: defaultPrompt
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
optional: true,
default: 0.9
}
]
},
[FollowUpPromptProviders.MISTRALAI]: {
label: 'Mistral AI',
name: FollowUpPromptProviders.MISTRALAI,
Expand Down

0 comments on commit 3b13e83

Please sign in to comment.