promptflow icon indicating copy to clipboard operation
promptflow copied to clipboard

[BUG] List variable inputs aren't interpreted for python nodes

Open axecopfire opened this issue 1 year ago • 1 comments

Describe the bug Input variables are not being interpolated for python node inputs.

How To Reproduce the bug

- name: process_topic
  type: python
  source:
    type: code
    path: src/process_detected_topics.py
  inputs:
    topics:
    - ${topic_detection_1.output}
    - ${topic_detection_2.output}

Results in the input for topics: ["${topic_detection_1.output}","${topic_detection_2.output}"].

Expected behavior topic_detection_[N].output should be interpolated to the output values of those nodes.

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

Running Information(please complete the following information):

  • Promptflow Package Version using pf -v: [e.g. 0.0.102309906]
  • Operating System: [e.g. Ubuntu 20.04, Windows 11]
  • Python Version using python --version: [e.g. python==3.10.12]

Additional context Add any other context about the problem here.

axecopfire avatar Mar 19 '24 16:03 axecopfire

@axecopfire Currently it is by design that we do not resolve ${} values in the list since it is hard to distinguish it from a normal list. As a workaround, you may add a node with **kwargs then return a list. Here is an example:

def construct_list(**kwargs):
    sorted_keys = sorted(list(kwargs.keys))
    return [kwargs[key] for key in sorted_keys]

thy09 avatar Mar 20 '24 14:03 thy09

Not a bug.

thy09 avatar Jun 11 '24 05:06 thy09