promptflow
Minimal chat
A chat flow defined using function with minimal code. It demonstrates the minimal code to have a chat flow.
Prerequisites
Install promptflow sdk and other dependencies in this folder:
pip install -r requirements.txt
What you will learn
In this flow, you will learn
- how to compose a chat flow.
- prompt template format of LLM tool chat api. Message delimiter is a separate line containing role name and colon: "system:", "user:", "assistant:".
See OpenAI Chat for more about message role.
system:You are a chatbot having a conversation with a human.user:{{question}}
Run flow
-
Prepare your Azure Open AI resource follow this instruction and get your
api_key
if you don't have one. -
Setup environment variables
Ensure you have put your azure open ai endpoint key in .env file. You can create one refer to this example file.
cat ../.env
- Run as normal Python file
python flow.py
- Test flow
pf flow test --flow flow:chat --inputs question="What's the capital of France?"
- Test flow: multi turn
# start test in chat uipf flow test --flow flow:chat --ui
- Create run with multiple lines data
pf run create --flow flow:chat --data ./data.jsonl --column-mapping question='${data.question}' --stream
You can also skip providing column-mapping
if provided data has same column name as the flow.
Reference here for default behavior when column-mapping
not provided in CLI.
- List and show run meta
# list created runpf run list
# get a sample run name
name=$(pf run list -r 10 | jq '.[] | select(.name | contains("chat_minimal_")) | .name'| head -n 1 | tr -d '"')# show specific run detailpf run show --name $name
# show outputpf run show-details --name $name
# visualize run in browserpf run visualize --name $name