promptflow

Форк
0

README.md

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 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

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.