microsoft / microsoft/promptflow
add support for dag definition in python
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.