1
1
import { BaseCache } from '@langchain/core/caches'
2
- import { ChatXAI , ChatXAIInput } from '@langchain/xai'
3
- import { ICommonObject , INode , INodeData , INodeParams } from '../../../src/Interface'
2
+ import { ChatXAIInput } from '@langchain/xai'
3
+ import { ICommonObject , IMultiModalOption , INode , INodeData , INodeParams } from '../../../src/Interface'
4
4
import { getBaseClasses , getCredentialData , getCredentialParam } from '../../../src/utils'
5
+ import { ChatXAI } from './FlowiseChatXAI'
5
6
6
7
class ChatXAI_ChatModels implements INode {
7
8
label : string
@@ -18,7 +19,7 @@ class ChatXAI_ChatModels implements INode {
18
19
constructor ( ) {
19
20
this . label = 'ChatXAI'
20
21
this . name = 'chatXAI'
21
- this . version = 1 .0
22
+ this . version = 2 .0
22
23
this . type = 'ChatXAI'
23
24
this . icon = 'xai.png'
24
25
this . category = 'Chat Models'
@@ -74,6 +75,15 @@ class ChatXAI_ChatModels implements INode {
74
75
step : 1 ,
75
76
optional : true ,
76
77
additionalParams : true
78
+ } ,
79
+ {
80
+ label : 'Allow Image Uploads' ,
81
+ name : 'allowImageUploads' ,
82
+ type : 'boolean' ,
83
+ description :
84
+ 'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.' ,
85
+ default : false ,
86
+ optional : true
77
87
}
78
88
]
79
89
}
@@ -84,6 +94,7 @@ class ChatXAI_ChatModels implements INode {
84
94
const modelName = nodeData . inputs ?. modelName as string
85
95
const maxTokens = nodeData . inputs ?. maxTokens as string
86
96
const streaming = nodeData . inputs ?. streaming as boolean
97
+ const allowImageUploads = nodeData . inputs ?. allowImageUploads as boolean
87
98
88
99
const credentialData = await getCredentialData ( nodeData . credential ?? '' , options )
89
100
const xaiApiKey = getCredentialParam ( 'xaiApiKey' , credentialData , nodeData )
@@ -97,7 +108,15 @@ class ChatXAI_ChatModels implements INode {
97
108
if ( cache ) obj . cache = cache
98
109
if ( maxTokens ) obj . maxTokens = parseInt ( maxTokens , 10 )
99
110
100
- const model = new ChatXAI ( obj )
111
+ const multiModalOption : IMultiModalOption = {
112
+ image : {
113
+ allowImageUploads : allowImageUploads ?? false
114
+ }
115
+ }
116
+
117
+ const model = new ChatXAI ( nodeData . id , obj )
118
+ model . setMultiModalOption ( multiModalOption )
119
+
101
120
return model
102
121
}
103
122
}
0 commit comments