Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Smolagents invalid types with message content #1247

Open
albertvillanova opened this issue Feb 3, 2025 · 4 comments
Open

[bug] Smolagents invalid types with message content #1247

albertvillanova opened this issue Feb 3, 2025 · 4 comments
Labels
bug Something isn't working instrumentation: smolagents language: python Related to Python integration

Comments

@albertvillanova
Copy link

albertvillanova commented Feb 3, 2025

Describe the bug
Smolagents message content is now a dict and raises invalid type warning:

Invalid type dict in attribute 'llm.input_messages.0.message.content' value sequence. 
Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None
Invalid type dict in attribute 'llm.input_messages.1.message.content' value sequence. 
Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None
Invalid type dict in attribute 'llm.input_messages.2.message.content' value sequence. 
Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or None

To Reproduce
Reported here by @ismael-dm:

Expected behavior
No warning.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Copy link

dosubot bot commented Feb 3, 2025

Hey there, @albertvillanova! I'm here to help you out with any bugs, questions, or contributions you have for Smolagents. Let's tackle this together!

The issue you're encountering with Smolagents, where message.content is being passed as a dictionary instead of the expected types (boolean, string, bytes, integer, float, or None), seems to be a type validation problem. The llm.input_messages.message.content attribute should indeed be one of the expected types, as demonstrated in the example code from the Smolagents library, where message.content is typically a string [1].

To address this issue, you should ensure that the message.content is being set to a valid type before it is passed to the LLM. If the content is being generated or modified in your code, verify that it is converted to a string or another acceptable type before assignment.

If this issue persists and is not due to your code, it might be a bug in the Smolagents library itself. In such cases, keeping an eye on the linked GitHub issue for updates or potential patches from the maintainers would be beneficial.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@albertvillanova
Copy link
Author

@dosu, the smolagents library recently changed the type of message.content: it defaults to a list of dicts, although for some specific cases, the previous str type is set.

Copy link

dosubot bot commented Feb 3, 2025

The recent change in the Smolagents library, where message.content defaults to a list of dicts, is likely intended to support more complex message structures. The expected structure within these dicts includes keys like role, content, and tool_calls [1]. For specific cases where the previous str type is set, it might be due to backward compatibility or specific use cases that require simpler message content. If you encounter issues with type validation, ensure that your code handles both the list of dicts and string cases appropriately.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@mikeldking mikeldking added language: python Related to Python integration instrumentation: smolagents and removed triage Issues that require triage labels Feb 3, 2025
@mikeldking
Copy link
Contributor

I believe this is related to #1237 - tagging @nate-mar to see if this is fixed together in a currently open PR.

Thanks for reporting @albertvillanova - we are trying to stay current with this instrumentation and appreciate your prompt filing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working instrumentation: smolagents language: python Related to Python integration
Projects
Status: No status
Development

No branches or pull requests

2 participants