-
Notifications
You must be signed in to change notification settings - Fork 465
Python: Handle dict input for MagenticStartMessage #1446
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for handling dictionary input when starting a Magentic workflow, specifically for dictionaries containing an "input" key. The change allows the workflow to accept dictionary messages and extract the text content from the "input" field.
- Added dictionary input handling for MagenticStartMessage creation
- Extracts text from dict["input"] and converts it to a MagenticStartMessage using the existing from_string method
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
message = MagenticStartMessage.from_string(message) | ||
elif isinstance(message, ChatMessage): | ||
message = MagenticStartMessage(task=message) | ||
elif isinstance(message, dict) and "input" in message: |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dict input handling lacks validation. Consider validating that message['input'] is a string before passing it to from_string(), as the method expects a string parameter but could receive any type from the dict.
elif isinstance(message, dict) and "input" in message: | |
elif isinstance(message, dict) and "input" in message: | |
if not isinstance(message["input"], str): | |
raise TypeError(f"Expected 'input' to be a string, got {type(message['input']).__name__}") |
Copilot uses AI. Check for mistakes.
Fixes #1310