You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to initialize the Messages class from the ddtrace.llmobs.utils module with a message containing non-string content types (e.g., images) intended for vision models, a TypeError is raised. The error message indicates that the message content must be a string, suggesting that the Messages class does not support complex content structures within the content field, particularly those required for vision model integrations as outlined in OpenAI's Vision Models Guide .
Reproduction Code
from ddtrace.llmobs.utils import Messages
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
},
],
}
]
# Attempt to initialize Messages with the above data
Messages(messages)
Additional Code Context:
The error originally occurred when executing the following code block:
with LLMObs.llm(model_name=model, model_provider="openai") as llm_span:
response = self.client.beta.chat.completions.parse(
model=model,
messages=messages,
**parameters,
)
LLMObs.annotate(
span=llm_span,
input_data=messages,
output_data=[
{"role": choice.message.role, "content": choice.message.content} for choice in response.choices
],
)
Error Logs
2025-02-07T15:16:39.188Z Failed to parse input messages.
2025-02-07T15:16:39.188Z Traceback (most recent call last):
File "/var/task/ddtrace/llmobs/_llmobs.py", line 823, in _tag_llm_io
input_messages = Messages(input_messages)
File "/var/task/ddtrace/llmobs/utils.py", line 52, in __init__
raise TypeError("Message content must be a string.")
TypeError: Message content must be a string.
Hi @harshilprajapati96, yes we don't currently support reporting vision payloads. Are you seeing these errors with our OpenAI auto instrumentation or just when instrumenting manually?
Tracer Version(s)
2.20.0
Python Version(s)
Python 3.11.7
Pip Version(s)
pip 24.2
Bug Report
When attempting to initialize the Messages class from the ddtrace.llmobs.utils module with a message containing non-string content types (e.g., images) intended for vision models, a TypeError is raised. The error message indicates that the message content must be a string, suggesting that the Messages class does not support complex content structures within the content field, particularly those required for vision model integrations as outlined in OpenAI's Vision Models Guide .
Reproduction Code
Additional Code Context:
The error originally occurred when executing the following code block:
Error Logs
Libraries in Use
Operating System
AWS Lambda x86_64
The text was updated successfully, but these errors were encountered: