[fix] iterable error when use gemini-pro (#277)
# PR Checklist - [ ] Did you check if it works normally in all models? *ignore this when it dosen't uses models* - [x] Did you check if it works normally in all of web, local and node hosted versions? if it dosen't, did you blocked it in those versions? - [ ] Did you added a type def? # Description An error occurred when use gemini-pro model with disabled Vertex-AI: 
This commit is contained in:
@@ -1194,8 +1194,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
|
|
||||||
let fullRes = ''
|
let fullRes = ''
|
||||||
|
|
||||||
for(const data of res.data){
|
const processDataItem = (data:any) => {
|
||||||
|
|
||||||
if(data?.candidates?.[0]?.content?.parts?.[0]?.text){
|
if(data?.candidates?.[0]?.content?.parts?.[0]?.text){
|
||||||
fullRes += data.candidates[0].content.parts[0].text
|
fullRes += data.candidates[0].content.parts[0].text
|
||||||
}
|
}
|
||||||
@@ -1213,6 +1212,15 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// traverse responded data if it contains multipart contents
|
||||||
|
if (typeof (res.data)[Symbol.iterator] === 'function') {
|
||||||
|
for(const data of res.data){
|
||||||
|
processDataItem(data)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
processDataItem(res.data)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
result: fullRes
|
result: fullRes
|
||||||
|
|||||||
Reference in New Issue
Block a user