1
- import { ChatOllama , ChatOllamaInput } from '@langchain/ollama'
1
+ import { ChatOllamaInput } from '@langchain/ollama'
2
2
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
3
3
import { BaseCache } from '@langchain/core/caches'
4
- import { INode , INodeData , INodeParams } from '../../../src/Interface'
4
+ import { IMultiModalOption , INode , INodeData , INodeParams } from '../../../src/Interface'
5
5
import { getBaseClasses } from '../../../src/utils'
6
+ import { ChatOllama } from './FlowiseChatOllama'
6
7
7
8
class ChatOllama_ChatModels implements INode {
8
9
label : string
@@ -19,7 +20,7 @@ class ChatOllama_ChatModels implements INode {
19
20
constructor ( ) {
20
21
this . label = 'ChatOllama'
21
22
this . name = 'chatOllama'
22
- this . version = 3 .0
23
+ this . version = 4 .0
23
24
this . type = 'ChatOllama'
24
25
this . icon = 'Ollama.svg'
25
26
this . category = 'Chat Models'
@@ -54,6 +55,23 @@ class ChatOllama_ChatModels implements INode {
54
55
default : 0.9 ,
55
56
optional : true
56
57
} ,
58
+ {
59
+ label : 'Allow Image Uploads' ,
60
+ name : 'allowImageUploads' ,
61
+ type : 'boolean' ,
62
+ description : 'Allow image uploads for multimodal models. e.g. llama3.2-vision' ,
63
+ default : false ,
64
+ optional : true
65
+ } ,
66
+ {
67
+ label : 'JSON Mode' ,
68
+ name : 'jsonMode' ,
69
+ type : 'boolean' ,
70
+ description :
71
+ 'Coerces model outputs to only return JSON. Specify in the system prompt to return JSON. Ex: Format all responses as JSON object' ,
72
+ optional : true ,
73
+ additionalParams : true
74
+ } ,
57
75
{
58
76
label : 'Keep Alive' ,
59
77
name : 'keepAlive' ,
@@ -203,6 +221,8 @@ class ChatOllama_ChatModels implements INode {
203
221
const repeatLastN = nodeData . inputs ?. repeatLastN as string
204
222
const repeatPenalty = nodeData . inputs ?. repeatPenalty as string
205
223
const tfsZ = nodeData . inputs ?. tfsZ as string
224
+ const allowImageUploads = nodeData . inputs ?. allowImageUploads as boolean
225
+ const jsonMode = nodeData . inputs ?. jsonMode as boolean
206
226
207
227
const cache = nodeData . inputs ?. cache as BaseCache
208
228
@@ -225,8 +245,16 @@ class ChatOllama_ChatModels implements INode {
225
245
if ( tfsZ ) obj . tfsZ = parseFloat ( tfsZ )
226
246
if ( keepAlive ) obj . keepAlive = keepAlive
227
247
if ( cache ) obj . cache = cache
248
+ if ( jsonMode ) obj . format = 'json'
249
+
250
+ const multiModalOption : IMultiModalOption = {
251
+ image : {
252
+ allowImageUploads : allowImageUploads ?? false
253
+ }
254
+ }
228
255
229
- const model = new ChatOllama ( obj )
256
+ const model = new ChatOllama ( nodeData . id , obj )
257
+ model . setMultiModalOption ( multiModalOption )
230
258
return model
231
259
}
232
260
}
0 commit comments