Add an Ollama baseUrl in chatflow configuration for Follow-up prompts (#4169)

Add abn Ollama baseUrl in chatflow configuration for Follow-up prompts
This commit is contained in:
Sarge Joseph 2025-03-13 15:59:27 -04:00 committed by GitHub
parent c2b830f279
commit 2b9a1ae316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -436,6 +436,7 @@ export type FollowUpPromptProviderConfig = {
[key in FollowUpPromptProvider]: { [key in FollowUpPromptProvider]: {
credentialId: string credentialId: string
modelName: string modelName: string
baseUrl: string
prompt: string prompt: string
temperature: string temperature: string
} }

View File

@ -8,7 +8,7 @@ import { z } from 'zod'
import { PromptTemplate } from '@langchain/core/prompts' import { PromptTemplate } from '@langchain/core/prompts'
import { StructuredOutputParser } from '@langchain/core/output_parsers' import { StructuredOutputParser } from '@langchain/core/output_parsers'
import { ChatGroq } from '@langchain/groq' import { ChatGroq } from '@langchain/groq'
import ollama from 'ollama' import { Ollama } from 'ollama'
const FollowUpPromptType = z const FollowUpPromptType = z
.object({ .object({
@ -122,7 +122,11 @@ export const generateFollowUpPrompts = async (
return structuredResponse return structuredResponse
} }
case FollowUpPromptProvider.OLLAMA: { case FollowUpPromptProvider.OLLAMA: {
const response = await ollama.chat({ const ollamaClient = new Ollama({
host: providerConfig.baseUrl || 'http://127.0.0.1:11434'
})
const response = await ollamaClient.chat({
model: providerConfig.modelName, model: providerConfig.modelName,
messages: [ messages: [
{ {

View File

@ -269,6 +269,14 @@ const followUpPromptsOptions = {
name: FollowUpPromptProviders.OLLAMA, name: FollowUpPromptProviders.OLLAMA,
icon: ollamaIcon, icon: ollamaIcon,
inputs: [ inputs: [
{
label: 'Base URL',
name: 'baseUrl',
type: 'string',
placeholder: 'http://127.0.0.1:11434',
description: 'Base URL of your Ollama instance',
default: 'http://127.0.0.1:11434'
},
{ {
label: 'Model Name', label: 'Model Name',
name: 'modelName', name: 'modelName',