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

[Feature Request] Make flow output json dump configurable to allow object as output #3099

Open
duongthaiha opened this issue May 2, 2024 · 4 comments
Labels
enhancement New feature or request long-term

Comments

@duongthaiha
Copy link

Is your feature request related to a problem? Please describe.
I want to return an class as output for the python tool however it shows error JSON dump failed: For example for the following code:
it will return an error
image

@dataclass
class ThoughtStep:
    title: str
    description: Optional[Any]
    props: Optional[dict[str, Any]] = None

# The inputs section will change based on the arguments of the tool function, after you save the code
# Adding type to arguments and return value will help the system show the types properly
# Please update the function name/signature per need
@tool
def my_python_tool(zone_instruction: str, modify_query:str, answer_question:str) -> list:
    thought_steps = [
        ThoughtStep(title="Look up Zone Instruction", description=zone_instruction, props=None),
        ThoughtStep(title="Modify the query with history and zone instruction", description=modify_query, props=None),
        ThoughtStep(title="Search relevant documentation", description=None, props=None),
        ThoughtStep(title="Answer the questions", description=answer_question, props=None)
    ]
    return thought_steps

Describe the solution you'd like
Allow option to inject how to serialise an complex object

Describe alternatives you've considered
My current work around is to manually use jsonoutput = json.dumps(thought_steps, default=lambda o: o.dict) inside the pythong tool and return a string instead

Additional context
Happy to connect to explain in more detail if it helps

@duongthaiha duongthaiha added the enhancement New feature or request label May 2, 2024
@ferBV
Copy link

ferBV commented May 3, 2024

For me this would be of great utility too, before migrating to Azure AI Studio in our project we were using Instructor package that uses pydantic for validate the outputs and was an almost perfect solution. I would be willing to contribute to make an enhancement feature.

@0mza987
Copy link
Contributor

0mza987 commented May 7, 2024

@duongthaiha,
Thanks for the feedback, I want to confirm that do you just want to pass a customized object inside a flow (from a node to another node)? If that's the case you can refer to Function based flow — Prompt flow documentation, with this type of flow you can pass any object inside a flow, actually there is no concept of node anymore, no dag either.

If you still want to use dag flow and return a customized object for a node (or flow output) just like your sample code, then we need a comprehensive design for this feature, it could be a long-term task to implement this feature.

@ferBV,

Thanks for your comments, really appreciate it. Could you please provide a more detailed design for this work? Maybe a doc or something? We would love it if community can contribute to prompt flow project.

@0mza987 0mza987 self-assigned this May 8, 2024
@duongthaiha
Copy link
Author

@0mza987 Yes it was the idea please. It will be a great feature as it will extend so much more use cases please

@0mza987
Copy link
Contributor

0mza987 commented May 21, 2024

Hi @duongthaiha , thanks for the feedback, our team does not have the bandwidth now, I'll mark this as a long-term item and will pick it up once we have the bandwidth. Thanks.

@0mza987 0mza987 removed their assignment May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request long-term
Projects
None yet
Development

No branches or pull requests

3 participants