e768098d0e
Flake8 Lint / flake8 (push) Waiting to run
Publish Promptflow Doc / Build (push) Waiting to run
Publish Promptflow Doc / Deploy (push) Blocked by required conditions
Spell check CI / Spell_Check (push) Waiting to run
tools_continuous_delivery / Private PyPI main branch release (push) Waiting to run
tools_continuous_delivery / Private PyPI non-main branch release (push) Waiting to run
2.1 KiB
2.1 KiB
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 OpenAI resource follow this instruction and get your
api_keyif you don't have one. -
Setup environment variables
Ensure you have put your azure OpenAI 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 ui
pf 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 run
pf 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 detail
pf run show --name $name
# show output
pf run show-details --name $name
# visualize run in browser
pf run visualize --name $name