[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:

![img](https://github.com/kwaroran/RisuAI/assets/35911521/e3e2cc5a-8fe8-4661-ba5b-317c5700eb86)
This commit is contained in:
kwaroran
2023-12-24 10:35:24 +09:00
committed by GitHub

View File

@@ -1194,8 +1194,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
let fullRes = ''
for(const data of res.data){
const processDataItem = (data:any) => {
if(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 {
type: 'success',
result: fullRes