I’m upgrading the Groq app with a new module for Groq Vision. The underlying API supports both:
- pass a remote URL to an image; or
- pass a local image via converting it to
data:image/jpeg;base64,...
and passing that as a URL
I do not know how to coerce both ideas into my module’s body
.
For initial release I’m just going to support image_url
only.
For “local file” support I think I have two questions:
- How might I convert an arbitrary jpg/png/gif etc image into
data:image/jpeg;base64,...
string within my custom app’s body? - What are my options for changing the value of
image_url
based on whether I have a data buffer input or not?
For the “image_url parameter only” release my app looks like:
{
// Request to API endpoint.
"url": "/openai/v1/chat/completions", // Relative to base URL
"method": "POST",
"body": {
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "{{parameters.prompt}}"
},
{
"type": "image_url",
"image_url": {
"url": "{{parameters.image_url}}"
}
}
]
}
],
"{{...}}": "{{omit(parameters, 'prompt', 'image_url')}}"
},
// Response handling
"response": {
"output": {
"{{...}}": "{{body}}", // Include all body keys and values
"result": "{{body.choices[1].message.content}}" // Add the result key from the first item in choices array as a test
}
}
}
Any pointers to either problem would be appreciated.