mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
feat(follow-up/ollama): support ollama provider (#3795)
This commit is contained in:
@@ -112,6 +112,7 @@
|
||||
"node-html-markdown": "^1.3.0",
|
||||
"notion-to-md": "^3.1.1",
|
||||
"object-hash": "^3.0.0",
|
||||
"ollama": "^0.5.11",
|
||||
"openai": "^4.57.3",
|
||||
"pdf-parse": "^1.1.1",
|
||||
"pdfjs-dist": "^3.7.107",
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 17 KiB |
@@ -14,6 +14,7 @@ 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 ollamaIcon from '@/assets/images/ollama.svg'
|
||||
import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser'
|
||||
import CredentialInputHandler from '@/views/canvas/CredentialInputHandler'
|
||||
import { Input } from '@/ui-component/input/Input'
|
||||
@@ -35,7 +36,8 @@ const FollowUpPromptProviders = {
|
||||
GOOGLE_GENAI: 'chatGoogleGenerativeAI',
|
||||
GROQ: 'groqChat',
|
||||
MISTRALAI: 'chatMistralAI',
|
||||
OPENAI: 'chatOpenAI'
|
||||
OPENAI: 'chatOpenAI',
|
||||
OLLAMA: 'ollama'
|
||||
}
|
||||
|
||||
const followUpPromptsOptions = {
|
||||
@@ -261,6 +263,38 @@ const followUpPromptsOptions = {
|
||||
default: 0.9
|
||||
}
|
||||
]
|
||||
},
|
||||
[FollowUpPromptProviders.OLLAMA]: {
|
||||
label: 'Ollama',
|
||||
name: FollowUpPromptProviders.OLLAMA,
|
||||
icon: ollamaIcon,
|
||||
inputs: [
|
||||
{
|
||||
label: 'Model Name',
|
||||
name: 'modelName',
|
||||
type: 'string',
|
||||
placeholder: 'llama2',
|
||||
description: 'Name of the Ollama model to use',
|
||||
default: 'llama3.2-vision:latest'
|
||||
},
|
||||
{
|
||||
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.7
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user