@@ -78,7 +78,7 @@ export interface LangchainProvider {
78
78
chat : ChatOpenAI ;
79
79
embeddings : OpenAIEmbeddings ;
80
80
queryDocument : < Args extends { text : string ; question ?: string } > (
81
- url : LangchainDocument [ ] ,
81
+ docs : LangchainDocument [ ] ,
82
82
question : string ,
83
83
options ?: { model ?: AvailableModels ; prompt ?: PromptFn < Args > } ,
84
84
) => Promise < string > ;
@@ -102,14 +102,15 @@ export const GetLangchainProvider = (
102
102
const options = {
103
103
...opts ,
104
104
} ;
105
+
105
106
const chat = new ChatOpenAI ( {
106
107
model : chatModel ,
107
108
temperature : 0 ,
108
109
apiKey : opts . apiKey ,
109
110
timeout : 60 * 30 * 1000 , // 30 minutes
110
111
maxConcurrency : 1 ,
111
112
maxRetries : 2 ,
112
- streamUsage : false ,
113
+ streaming : true ,
113
114
...opts . options ?. chat ,
114
115
configuration : {
115
116
baseURL : opts . baseURL ,
@@ -121,6 +122,7 @@ export const GetLangchainProvider = (
121
122
122
123
const embeddings = new OpenAIEmbeddings ( {
123
124
model : embeddingsModel ,
125
+ modelName : embeddingsModel ,
124
126
apiKey : opts . apiKey ,
125
127
timeout : 60 * 30 * 1000 , // 30 minutes,
126
128
...opts . options ?. embeddings ,
@@ -141,20 +143,19 @@ export const GetLangchainProvider = (
141
143
chat,
142
144
embeddings,
143
145
queryDocument : async ( content , question , options ) => {
144
- const model =
145
- options ?. model ?? opts . models ?. embeddings ?? "text-embedding-ada-002" ;
146
+ const model = options ?. model ?? embeddingsModel ;
146
147
147
- const chatModel = options ?. model ?? opts . models ?. chat ?? "gpt-4o" ;
148
+ const chatModel2 = options ?. model ?? chatModel ;
148
149
149
150
langchainLogger . info . log (
150
151
"queryDocument use embedding model %s to query document with size %d using chat model %s" ,
151
152
model ,
152
153
content . length ,
153
- chatModel ,
154
+ chatModel2 ,
154
155
) ;
155
156
156
157
const chat = new ChatOpenAI ( {
157
- model : chatModel ,
158
+ model : chatModel2 ,
158
159
temperature : 0 ,
159
160
apiKey : opts . apiKey ,
160
161
configuration : {
@@ -168,6 +169,7 @@ export const GetLangchainProvider = (
168
169
model,
169
170
apiKey : opts . apiKey ,
170
171
timeout : 60 * 30 * 1000 , // 30 minutes
172
+ encodingFormat : "base64" ,
171
173
configuration : {
172
174
baseURL : opts . baseURL ,
173
175
...opts . options ?. embeddings . configuration ,
@@ -229,7 +231,7 @@ export const GetLangchainProvider = (
229
231
configuration : {
230
232
baseURL : opts . baseURL ,
231
233
} ,
232
- streaming : true ,
234
+ // streaming: true,
233
235
} ) ;
234
236
235
237
const textSplitter = new RecursiveCharacterTextSplitter ( {
0 commit comments