-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hello. The com.aallam.openai library treats content as a string, not as an array of JSON objects.
As a result, the attached image is not parsed.
fun analyzeImageWithGPT(apiKey: String, imageUrl: String): String = runBlocking {
val openAI = OpenAI(apiKey)
val request = ChatCompletionRequest(
model = ModelId("gpt-4o-mini"),
messages = listOf(
ChatMessage(
role = ChatRole.User,
content = """
[
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "$imageUrl"
}
}
]
""".trimIndent()
)
),
maxTokens = 300
)
val response = openAI.chatCompletion(request)
response.choices.firstOrNull()?.message?.content ?: "No response"
}
Maybe I'm not making the request correctly, please tell me?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request