openai: use auto vision level

This commit is contained in:
Cyberes 2024-04-10 18:24:19 -06:00
parent 06396a70da
commit d811deebc9
1 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,10 @@ class OpenAIClient(ApiClient):
self._context.append({'role': role, 'content': content})
async def append_img(self, img_event: RoomMessageImage, role: str):
"""
We crop the largest dimension of the image to 512px and then let the AI decide
if it should use low or high res analysis.
"""
assert role in [self._HUMAN_NAME, self._BOT_NAME]
img_bytes = await download_mxc(img_event.url, self._client_helper.client)
encoded_image = await process_image(img_bytes, resize_px=512)
@ -34,7 +38,7 @@ class OpenAIClient(ApiClient):
'type': 'image_url',
'image_url': {
'url': f"data:image/png;base64,{encoded_image}",
'detail': 'low'
'detail': 'auto'
}
}]
})