|
| 1 | +# Chat flow |
| 2 | +Chat flow is designed for conversational application development, building upon the capabilities of standard flow and providing enhanced support for chat inputs/outputs and chat history management. With chat flow, you can easily create a chatbot that handles chat input and output. |
| 3 | + |
| 4 | +## Create connection for LLM tool to use |
| 5 | +You can follow these steps to create a connection required by a LLM tool. |
| 6 | + |
| 7 | +Currently, there are two connection types supported by LLM tool: "AzureOpenAI" and "OpenAI". If you want to use "AzureOpenAI" connection type, you need to create an Azure OpenAI service first. Please refer to [Azure OpenAI Service](https://azure.microsoft.com/en-us/products/cognitive-services/openai-service/) for more details. If you want to use "OpenAI" connection type, you need to create an OpenAI account first. Please refer to [OpenAI](https://platform.openai.com/) for more details. |
| 8 | + |
| 9 | +```bash |
| 10 | +# Override keys with --set to avoid yaml file changes |
| 11 | +# Create OpenAI connection |
| 12 | +pf connection create --file openai.yaml --set api_key=<your_api_key> --name open_ai_connection |
| 13 | + |
| 14 | +# Create azure OpenAI connection |
| 15 | +# pf connection create --file azure_openai.yaml --set api_key=<your_api_key> api_base=<your_api_base> --name open_ai_connection |
| 16 | +``` |
| 17 | + |
| 18 | +Note in [flow.dag.yaml](flow.dag.yaml) we are using connection named `open_ai_connection`. |
| 19 | +```bash |
| 20 | +# show registered connection |
| 21 | +pf connection show --name open_ai_connection |
| 22 | +``` |
| 23 | +Please refer to connections [document](https://promptflow.azurewebsites.net/community/local/manage-connections.html) and [example](https://github.com/microsoft/promptflow/tree/main/examples/connections) for more details. |
| 24 | + |
| 25 | +## Develop a chat flow |
| 26 | + |
| 27 | +The most important elements that differentiate a chat flow from a standard flow are **Chat Input**, **Chat History**, and **Chat Output**. |
| 28 | + |
| 29 | +- **Chat Input**: Chat input refers to the messages or queries submitted by users to the chatbot. Effectively handling chat input is crucial for a successful conversation, as it involves understanding user intentions, extracting relevant information, and triggering appropriate responses. |
| 30 | + |
| 31 | +- **Chat History**: Chat history is the record of all interactions between the user and the chatbot, including both user inputs and AI-generated outputs. Maintaining chat history is essential for keeping track of the conversation context and ensuring the AI can generate contextually relevant responses. Chat History is a special type of chat flow input, that stores chat messages in a structured format. |
| 32 | + |
| 33 | +- **Chat Output**: Chat output refers to the AI-generated messages that are sent to the user in response to their inputs. Generating contextually appropriate and engaging chat outputs is vital for a positive user experience. |
| 34 | + |
| 35 | +A chat flow can have multiple inputs, but Chat History and Chat Input are required inputs in chat flow. |
| 36 | + |
| 37 | +## Interact with chat flow |
| 38 | + |
| 39 | +Promptflow CLI provides a way to start an interactive chat session for chat flow. Customer can use below command to start an interactive chat session: |
| 40 | + |
| 41 | +``` |
| 42 | +pf flow test --flow <flow_folder> --interactive |
| 43 | +``` |
| 44 | + |
| 45 | +After executing this command, customer can interact with the chat flow in the terminal. Customer can press **Enter** to send the message to chat flow. And customer can quit with **ctrl+C**. |
| 46 | +Promptflow CLI will distinguish the output of different roles by color, <span style="color:Green">User input</span>, <span style="color:Gold">Bot output</span>, <span style="color:Blue">Flow script output</span>, <span style="color:Cyan">Node output</span>. |
| 47 | + |
| 48 | +> =========================================<br> |
| 49 | +> Welcome to chat flow, <You-flow-name>.<br> |
| 50 | +> Press Enter to send your message.<br> |
| 51 | +> You can quit with ctrl+C.<br> |
| 52 | +> =========================================<br> |
| 53 | +> <span style="color:Green">User:</span> What types of container software there are<br> |
| 54 | +> <span style="color:Gold">Bot:</span> There are several types of container software available, including:<br> |
| 55 | +> 1. Docker: This is one of the most popular containerization software that allows developers to package their applications into containers and deploy them across different environments.<br> |
| 56 | +> 2. Kubernetes: This is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications.<br> |
| 57 | +> |
| 58 | +> <span style="color:Green">User:</span> What's the different between them<br> |
| 59 | +> <span style="color:Gold">Bot:</span> The main difference between the various container software systems is their functionality and purpose. Here are some key differences between them:<br> |
| 60 | +> 1. Docker is more focused on container packaging and deployment, while Kubernetes is more focused on container orchestration and management.<br> |
| 61 | +> 2. Kubernetes: Kubernetes is a container orchestration tool that helps manage and deploy containers at scale. It automates the deployment, scaling, and management of containerized applications across multiple hosts.<br> |
| 62 | +
|
| 63 | +If customer adds "--verbose" in the pf command, the output of each step will be displayed. |
| 64 | + |
| 65 | +> =========================================<br> |
| 66 | +> Welcome to chat flow, Template Chat Flow.<br> |
| 67 | +> Press Enter to send your message.<br> |
| 68 | +> You can quit with ctrl+C.<br> |
| 69 | +> =========================================<br> |
| 70 | +> <span style="color:Green">User:</span> What types of container software there are<br> |
| 71 | +> <span style="color:Cyan">chat:</span> There are several types of container software available, including:<br> |
| 72 | +> 1. Docker: A popular container platform that is widely used in the industry.<br> |
| 73 | +> 2. Kubernetes: A container orchestration tool that helps manage and deploy containers at scale.<br> |
| 74 | +> |
| 75 | +> <span style="color:Gold">Bot:</span> There are several types of container software available, including:<br> |
| 76 | +> 1. Docker: A popular container platform that is widely used in the industry.<br> |
| 77 | +> 2. Kubernetes: A container orchestration tool that helps manage and deploy containers at scale.<br> |
| 78 | +> |
| 79 | +> <span style="color:Green">User:</span> What's the different between them<br> |
| 80 | +> <span style="color:Cyan">chat:</span> The main differences between container software are in their architecture, feature sets, and use cases. Here are some brief explanations of the differences between the examples I listed:<br> |
| 81 | +> 1. Docker: Docker is a container platform that is widely used for building, packaging, and deploying containerized applications. It is known for its ease of use, portability, and large ecosystem of tools and services.<br> |
| 82 | +> 2. Kubernetes: Kubernetes is a container orchestration tool that helps manage and deploy containers at scale. It automates the deployment, scaling, and management of containerized applications across multiple hosts.<br> |
| 83 | +> |
| 84 | +> <span style="color:Gold">Bot:</span> The main differences between container software are in their architecture, feature sets, and use cases. Here are some brief explanations of the differences between the examples I listed:<br> |
| 85 | +> 1. Docker: Docker is a container platform that is widely used for building, packaging, and deploying containerized applications. It is known for its ease of use, portability, and large ecosystem of tools and services.<br> |
| 86 | +> 2. Kubernetes: Kubernetes is a container orchestration tool that helps manage and deploy containers at scale. It automates the deployment, scaling, and management of containerized applications across multiple hosts.<br> |
0 commit comments