Hi folks, I'm about to create an app to extract data from images using OpenAI and its function calling. I went through this tutorial: https://www.youtube.com/watch?v=TQEYfIqnwcY
I modified the API call, but the result is incorrect. Can anybody tell me what might be wrong with my API body? I wan't to get json compatible data. The Response is always asking for the image Url.
The API body
{
"model": "gpt-4-0613",
"messages": [
{
"role": "user",
"content": "Bitte extrahiere die Eventinformationen aus dem Bild und gib sie in folgendem JSON-Format zurück: {\"Eventname\": \"\", \"EventDatum\": \"\", \"EventLocation\": \"\", \"Beschreibung\": \"\", \"Preis\": \"\", \"Website\": \"\"}. Achte darauf, dass das Datum im Format \"YYYY-MM-DD HH:MM:SS\" ist und alle Felder ausgefüllt sind, wenn die Informationen im Bild vorhanden sind."
}
],
"functions": [
{
"name": "get_event_data",
"parameters": {
"type": "object",
"properties": {
"image_url": {
"type": "string",
"description": "The URL of the image from which event data should be extracted."
}
},
"required": [
"image_url"
]
}
}
],
"function_call": {
"name": "get_event_data",
"arguments": {
"image_url": "https://www.example.png"
}
}
}
The Response
{
"id": "chatcmpl-AEgEx2hM4towiqHHy6kPodjF0h1kl",
"object": "chat.completion",
"created": 1728062327,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "get_event_data",
"arguments": "{\n \"image_url\": \"https://example.com/image.jpg\"\n}"
},
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 154,
"completion_tokens": 15,
"total_tokens": 169,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"system_fingerprint": null
}