I am trying to send an image for ChatCompletion using the Microsoft provided Azure OpenAi java sdk "com.azure:azure-ai-openai:1.0.0-beta.9".
val cco = ChatCompletionsOptions(
mutableListOf(
ChatRequestSystemMessage("You are an assistant which does Optical Character Recognition on scanned medical documents."),
ChatRequestUserMessage(mutableListOf<ChatMessageContentItem>(
ChatMessageTextContentItem("Read text from the scanned medical document. Only respond with the text content."),
ChatMessageImageContentItem(ChatMessageImageUrl("data:${contentType};base64,${Base64.getEncoder().encodeToString(bytes)}"
))
))))
The content is however not being sent correctly. It seems that the Microsoft provided client is not encoding the content correctly. Can someone confirm if this implementation works. The same code works with kotlin-openai and other libraries.
"error": {
"message": "This model's maximum context length is 128000 tokens. However, your messages resulted in 291246 tokens. Please reduce the length of the messages.",
"type": "invalid_request_error",
"param": "messages",
"code": "context_length_exceeded"
}
Someone to help with a issued faced during coding nd confirm if the specified library does indeed work.