Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,132 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We are getting an error while trying to upload an Image with an URL through the GPT4o API. The error we are getting:
Exception from a finished function: TypeError: Cannot read properties of undefined (reading 'stack')
import { AzureKeyCredential, OpenAIClient } from '@azure/openai';
export const openaiPrompt = async (promptText: string, imageUrl: string) => {
const resource = process.env.RESOURCE_NAME;
const apiKey = process.env.AZURE_API_KEY || '';
const endpoint = `https://${resource}.openai.azure.com/`;
const credential = new AzureKeyCredential(apiKey);
try {
const client = new OpenAIClient(endpoint, credential);
console.log('Prompt azure:', imageUrl);
const messages = [
{
role: 'system',
content: 'You are a helpful assistant. Help me with my math homework!',
},
{
role: 'user',
content: {
type: 'text',
text: promptText,
},
},
{
role: 'user',
content: {
type: 'image_url',
image_url: imageUrl,
},
},
];
const response = await client.getChatCompletions(
'its-koral-enrich-v1',
messages,
{
temperature: 1.1,
topP: 1,
frequencyPenalty: 0,
presencePenalty: 0,
}
);
console.log('Response:', response);
if (response.choices) {
console.dir(response.choices[0]?.message?.content, { depth: null });
return response.choices[0]?.message?.content;
}
} catch (error) {
console.error('Error details:', error);
}
return '';
};
What is wrong?