valentinfrlch / ha-llmvision

Let Home Assistant see!
Apache License 2.0
161 stars 6 forks source link

Anthropic Claude: Invalid Request. There was an issue with the format or content of your request. #48

Closed martinhoess closed 2 months ago

martinhoess commented 2 months ago

Bug Description

Can't use Anthropic Claude with image or image entity

Version: v1.0.2 Home Assistant Core 2024.7.4

Service Call

service: llmvision.image_analyzer
data:
  provider: Anthropic
  max_tokens: 250
  temperature: 0.5
  model: claude-3-5-sonnet-20240620
  message: Describe what you see?
  image_file: /config/www/tmp/example.jpg
  target_width: 1000

Logs

2024-08-12 11:29:43.054 DEBUG (MainThread) [custom_components.llmvision.request_handlers] Base64 Images: ['<long_string>']
2024-08-12 11:29:43.054 INFO (MainThread) [custom_components.llmvision.request_handlers] Request data: {'model': 'claude-3-5-sonnet-20240620', 'messages': [{'role': 'user', 'content': [{'type': 'text', 'text': 'Image 1:'}, {'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': '<long_string>'}}, {'type': 'text', 'text': 'Describe what you see?'}]}], 'max_tokens': 250, 'temperature': 0.5}
2024-08-12 11:29:44.022 DEBUG (MainThread) [custom_components.llmvision.request_handlers] Provider: anthropic
2024-08-12 11:29:44.022 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: Invalid Request. There was an issue with the format or content of your request.
2024-08-12 11:29:44.023 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140278611944080] Invalid Request. There was an issue with the format or content of your request.

Additional context

martinhoess commented 2 months ago

Just tried the older 0.4.7 version and it works fine (same service call data)

valentinfrlch commented 2 months ago

I've been able to replicate the error. Not sure where the problem is, but this is definitely an issue. Thanks for pointing it out!

valentinfrlch commented 2 months ago

Should be fixed now. Thanks again for pointing it out!

martinhoess commented 2 months ago

short test, now works as expected. thank you!