Skip to content

Commit

Permalink
🐛 fix: Azure OpenAI vision models issue (lobehub#2207)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnoyiX committed May 8, 2024
1 parent dedbfa2 commit b98de56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libs/agent-runtime/azureOpenai/index.ts
Expand Up @@ -30,6 +30,18 @@ export class LobeAzureOpenAI implements LobeRuntimeAI {
// ============ 1. preprocess messages ============ //
const { messages, model, ...params } = payload;

// fix the issue: "The sample encountered an error: TypeError: Cannot read properties of undefined (reading 'url')"
messages.forEach(message => {
if (message['content'] instanceof Array) {
message['content'].forEach((content: any) => {
if (content['type'] === 'image_url') {
content['imageUrl'] = content['image_url'];
delete content['image_url'];
}
});
};
});

// ============ 2. send api ============ //

try {
Expand Down

0 comments on commit b98de56

Please sign in to comment.