microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
9.38k stars 852 forks source link

[Feature Request] JSON parsing of node output #1813

Open johnsinco opened 9 months ago

johnsinco commented 9 months ago

Is your feature request related to a problem? Please describe. We are trying to use a JSON string output by the LLM as data for a downstream node within the jinja2 template. We have tried using the built-in and add-on jinja "filter" mechanism as below, but it doesnt appear to be available or supported within PromptFlow {% set data = tables|from_json %} <-- Gives an error

Describe the solution you'd like There seems to be some idea that strong-typing of inputs and outputs to nodes may be supported in the future? We are unable to determine how either automatic parsing of a JSON string into an object or parsing within the jinja tempates can be done.

Describe alternatives you've considered We could create a separate node to manually parse the string into JSON object within the flow. We will use this workaround but an automatic facility would be much better

thy09 commented 9 months ago

image https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters @johnsinco from_json seems not a built-in filter, what is your proposal?

  1. Add a pf built-in filters;
  2. Hint node with strong type and load the data?
johnsinco commented 9 months ago

There seems to be the idea that eventually node inputs would be strongly typed as suggested by the VSC UI here ->

image

If that is planned and one of the types could be a JSON object of some sort that would be ideal. Otherwise a method to use 3rd party jinja filters such as the load_json filter provided by Ansible would also make this scenario much easier for us.

thy09 commented 9 months ago

Hi @johnsinco, thank you for your feedback! Strong type value in prompt is not in our plan now. As for load_json filter, we will discuss on this feature. We will keep this item open and update the plan if we have some conclusion.

Please use another node as the workaround now, sorry for the inconvenience.

github-actions[bot] commented 7 months ago

Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you!