microsoft / microsoft/promptflow

add support for dag definition in python

Open
#1,091 1 comment 0 reactions 2 assignees View on GitHub

@D-W- is already working on this.

Since Jan 2, 2024.

enhancement long-term
Dominant language
Python
Stars
11.2k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,
do you plan to add support to define dags using python (instead of flow.dag.yaml)?
So is more similar to airflow or kubeflow
And end to end feels more "pythonic" (whatever that means)

Desired behavior
Current config for hello world flow

$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 pseudo-code equivalent

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)

thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.