promptflow
promptflow copied to clipboard
[BUG] pf flow serve is broken in promptflow==1.10.0 (NotADirectoryError)
Clearly state that you are going to take on implementing it, if that's the case. You can request that the issue be assigned to you.
I'm happy to implement this seems straightforward (possible solution provided below, please confirm if this is the expected behaviour)
Describe the bug
Serving the interactive chat UI appears to have broken. Flask app 'promptflow.core._serving.app' does not start successfully, resulting in an exception and the local app server doesn't open in a browser.
How To Reproduce the bug
Using the following flow.dag.yaml
:
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
inputs:
question:
type: string
is_chat_input: true
nodes:
- name: parrot
type: python
source:
type: code
path: ./parrot.py
inputs:
question: ${inputs.question}
outputs:
answer:
type: string
reference: ${parrot.output}
is_chat_output: true
and parrot.py
(both files in the same source directory):
from promptflow.core import tool
@tool
def print_hi(question: str):
return question.upper()
To reproduce the error, run any of the following pf
commands below:
pf flow serve --source ./
pf flow serve --source .
pf flow serve --source flow.dag.yaml
Exception raised:
File "/Users/oliver.frost/.pyenv/versions/3.11.4/lib/python3.11/site-packages/promptflow/_sdk/_utils/serve_utils.py", line 112, in serve_python_flow
os.chdir(flow_dir)
NotADirectoryError: [Errno 20] Not a directory: '/Users/oliver.frost/PycharmProjects/pf-bug-example/flow.dag.yaml'
Issue resolves when you adjust _resolve_python_flow_additional_includes()
to return the parent of the source instead, included below:
def _resolve_python_flow_additional_includes(source) -> Path:
# Resolve flow additional includes
from promptflow.client import load_flow
flow = load_flow(source)
from promptflow._sdk.operations import FlowOperations
with FlowOperations._resolve_additional_includes(flow.path) as resolved_flow_path:
if resolved_flow_path == flow.path:
# HERE
return source.parent
Expected behavior
Flask app 'promptflow.core._serving.app' serves successfully and a browser window opens:
Screenshots
Running Information(please complete the following information):
- Promptflow == 1.10.0
- Operating System: Mac OS X 14.4.1 (23E224)
- Python Version 3.11.4
@asos-oliverfrost Thanks for reporting this! We will fix this asap in the postfix 1.10.1.
Thanks for the reply! I was hoping to take a crack at this, as we've worked a lot with promptflow and I was hoping to become more active as a contributor :)
Haha, thank you, we are fixing this here #3070 because this related to some code refine works not so long ago, and this breaks 1.10.0 so it's a little hurry to ship the fix in 1.10.1, I believe you've been our contributor by reporting this, really appreciate it, and contribute code changes will not be too far for you 😆, thanks again. @asos-oliverfrost