Skip to content

Commit 97d4994

Browse files
sunnymodi21Yshayy
authored andcommitted
Feature/Add Groq for followup prompts (FlowiseAI#3806)
Feature/Add-Groq-for-followup-prompts
1 parent 4165933 commit 97d4994

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

packages/components/src/Interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ export enum FollowUpPromptProvider {
427427
AZURE_OPENAI = 'azureChatOpenAI',
428428
GOOGLE_GENAI = 'chatGoogleGenerativeAI',
429429
MISTRALAI = 'chatMistralAI',
430-
OPENAI = 'chatOpenAI'
430+
OPENAI = 'chatOpenAI',
431+
GROQ = 'groqChat'
431432
}
432433

433434
export type FollowUpPromptProviderConfig = {

packages/components/src/followUpPrompts.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ChatOpenAI } from '@langchain/openai'
77
import { z } from 'zod'
88
import { PromptTemplate } from '@langchain/core/prompts'
99
import { StructuredOutputParser } from '@langchain/core/output_parsers'
10+
import { ChatGroq } from '@langchain/groq'
1011

1112
const FollowUpPromptType = z
1213
.object({
@@ -108,6 +109,16 @@ export const generateFollowUpPrompts = async (
108109
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
109110
return structuredResponse
110111
}
112+
case FollowUpPromptProvider.GROQ: {
113+
const llm = new ChatGroq({
114+
apiKey: credentialData.groqApiKey,
115+
model: providerConfig.modelName,
116+
temperature: parseFloat(`${providerConfig.temperature}`)
117+
})
118+
const structuredLLM = llm.withStructuredOutput(FollowUpPromptType)
119+
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
120+
return structuredResponse
121+
}
111122
}
112123
} else {
113124
return undefined

packages/ui/src/ui-component/extended/FollowUpPrompts.jsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import anthropicIcon from '@/assets/images/anthropic.svg'
1313
import azureOpenAiIcon from '@/assets/images/azure_openai.svg'
1414
import mistralAiIcon from '@/assets/images/mistralai.svg'
1515
import openAiIcon from '@/assets/images/openai.svg'
16+
import groqIcon from '@/assets/images/groq.png'
1617
import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser'
1718
import CredentialInputHandler from '@/views/canvas/CredentialInputHandler'
1819
import { Input } from '@/ui-component/input/Input'
@@ -32,6 +33,7 @@ const FollowUpPromptProviders = {
3233
ANTHROPIC: 'chatAnthropic',
3334
AZURE_OPENAI: 'azureChatOpenAI',
3435
GOOGLE_GENAI: 'chatGoogleGenerativeAI',
36+
GROQ: 'groqChat',
3537
MISTRALAI: 'chatMistralAI',
3638
OPENAI: 'chatOpenAI'
3739
}
@@ -149,6 +151,42 @@ const followUpPromptsOptions = {
149151
}
150152
]
151153
},
154+
[FollowUpPromptProviders.GROQ]: {
155+
label: 'Groq',
156+
name: FollowUpPromptProviders.GROQ,
157+
icon: groqIcon,
158+
inputs: [
159+
{
160+
label: 'Connect Credential',
161+
name: 'credential',
162+
type: 'credential',
163+
credentialNames: ['groqApi']
164+
},
165+
{
166+
label: 'Model Name',
167+
name: 'modelName',
168+
type: 'asyncOptions',
169+
loadMethod: 'listModels'
170+
},
171+
{
172+
label: 'Prompt',
173+
name: 'prompt',
174+
type: 'string',
175+
rows: 4,
176+
description: promptDescription,
177+
optional: true,
178+
default: defaultPrompt
179+
},
180+
{
181+
label: 'Temperature',
182+
name: 'temperature',
183+
type: 'number',
184+
step: 0.1,
185+
optional: true,
186+
default: 0.9
187+
}
188+
]
189+
},
152190
[FollowUpPromptProviders.MISTRALAI]: {
153191
label: 'Mistral AI',
154192
name: FollowUpPromptProviders.MISTRALAI,

0 commit comments

Comments
 (0)