3.5 Retrieve Related Knowledge¶
1. Add Chat With Products Script¶
Let's copy over the chat_with_products.py
script into our application source.
1 |
|
2. Understand RAG Workflow¶
This script is the core orchestrator for our RAG workflow, executing the following steps:
- Create an Azure AI Project client (with connection string)
- Retrieve the inference client for chat completions model
- Use incoming user messages to retrieve related products
- Use this knowledge to populate a grounded chat template
- Call the chat completions client with this prompt template
Click to expand and view Chat With Products script (segment)
src/api/chat_with_products.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
In the next section, we'll look at the prompt template and run a test with a sample query.
3. Run Chat With Products Script¶
Before we can run this script, we need to create the Grounded Chat Prompt template for step 4. Let's do that next.