Skip to content

Commit 734b836

Browse files
committed
fix: googleGenerativeAI status 500 error
1 parent 9901712 commit 734b836

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

server/api/image.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ export default defineEventHandler(async (event) => {
55

66
const { prompt, imageParts } = await readBody(event);
77

8+
const imageData = imageParts.map((image) => {
9+
return {
10+
inlineData: image,
11+
};
12+
});
13+
814
try {
9-
const result = await model.generateContent([prompt, [...imageParts]]);
15+
const result = await model.generateContent([prompt, ...imageData]);
1016
const response = await result.response;
1117
const text = response.text();
1218

stores/useChatStore.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ export const useChatStore = defineStore({
4141

4242
getImageParts: (state) =>
4343
state.chatHistory.map((chat) => ({
44-
inlineData: {
45-
data: chat.imageData?.link,
46-
mimeType: chat.imageData?.type,
47-
},
44+
data: chat.imageData?.link,
45+
mimeType: chat.imageData?.type,
4846
})),
4947
},
5048
});

0 commit comments

Comments
 (0)