mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
feat(follow-up/ollama): support ollama provider (#3795)
This commit is contained in:
@@ -428,7 +428,8 @@ export enum FollowUpPromptProvider {
|
||||
GOOGLE_GENAI = 'chatGoogleGenerativeAI',
|
||||
MISTRALAI = 'chatMistralAI',
|
||||
OPENAI = 'chatOpenAI',
|
||||
GROQ = 'groqChat'
|
||||
GROQ = 'groqChat',
|
||||
OLLAMA = 'ollama'
|
||||
}
|
||||
|
||||
export type FollowUpPromptProviderConfig = {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { z } from 'zod'
|
||||
import { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { StructuredOutputParser } from '@langchain/core/output_parsers'
|
||||
import { ChatGroq } from '@langchain/groq'
|
||||
import ollama from 'ollama'
|
||||
|
||||
const FollowUpPromptType = z
|
||||
.object({
|
||||
@@ -119,6 +120,38 @@ export const generateFollowUpPrompts = async (
|
||||
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
|
||||
return structuredResponse
|
||||
}
|
||||
case FollowUpPromptProvider.OLLAMA: {
|
||||
const response = await ollama.chat({
|
||||
model: providerConfig.modelName,
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: followUpPromptsPrompt
|
||||
}
|
||||
],
|
||||
format: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
questions: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minItems: 3,
|
||||
maxItems: 3,
|
||||
description: 'Three follow-up questions based on the conversation history'
|
||||
}
|
||||
},
|
||||
required: ['questions'],
|
||||
additionalProperties: false
|
||||
},
|
||||
options: {
|
||||
temperature: parseFloat(`${providerConfig.temperature}`)
|
||||
}
|
||||
})
|
||||
const result = FollowUpPromptType.parse(JSON.parse(response.message.content))
|
||||
return result
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
|
||||
Reference in New Issue
Block a user