promptflow 为Python添加对DAG定义的支持,

bjg7j2ky  于 2个月前  发布在  Python
关注(0)|答案(1)|浏览(40)

你好,
你计划支持使用Python(而不是flow.dag.yaml)来定义DAG吗?这样更接近于Airflow或kubeflow,并且端到端的感觉更“Pythonic”(不管那是什么意思)。

期望的行为

Hello World流程的当前配置

$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
  text:
    type: string
outputs:
  output_prompt:
    type: string
    reference: ${echo_my_prompt.output}
nodes:
- name: hello_prompt
  type: prompt
  source:
    type: code
    path: hello.jinja2
  inputs:
    text: ${inputs.text}
- name: echo_my_prompt
  type: python
  source:
    type: code
    path: hello.py
  inputs:
    input1: ${hello_prompt.output}
environment:
  python_requirements_txt: requirements.txt

Python伪代码等效物

from typing import NamedTuple

from promptflow import flow, node

@node(type="prompt", source="hello.jinja2")
def hello_prompt(text: str) -> str:
    pass

# default type is python
@node
def echo_my_prompt(input1: str) -> str:
    return "Prompt: " + input1

@flow
def hello_world_flow(
        text: str
) -> NamedTuple('Outputs',
                output_prompt=str,
                ):
    out = hello_prompt(text)
    echo_my_prompt(out)

谢谢。

l3zydbqr

l3zydbqr1#

我们短期内没有计划做这件事。在ask中添加了一个长期标签。

相关问题