avatarShweta Lodha

Summary

The article provides a guide on creating, updating, and testing Azure Prompt Flows locally using Visual Studio Code and its extensions, along with code snippets for connecting and testing the flow on a local machine.

Abstract

The article "Create, Update & Test Azure Prompt Flow Locally — Part 2" by Shweta Lodha is a continuation of her previous work on Azure Prompt Flows. It details the process of setting up Visual Studio Code with the necessary extension to work with Azure Prompt Flows on a local machine. The author emphasizes the benefits of visualizing the entire flow within VS Code and provides step-by-step instructions on how to install the required extension, connect the flow to the local machine, and test it with code examples. The article also includes screenshots for visual guidance and concludes with a recommendation to watch a video for a more comprehensive understanding of the process.

Opinions

  • The author believes that having the "Prompt flow for VS Code" extension is beneficial, though not mandatory, as it aids in visualizing the entire flow within Visual Studio Code.
  • The article suggests that setting up VS Code for local development of Azure Prompt Flows is a seamless process.
  • Shweta Lodha recommends watching a video she has created for a complete understanding of the underlying processes, implying that visual and written content combined offer the best learning experience.
  • The author's use of the phrase "Happy prompting!" indicates an enthusiastic and encouraging attitude towards readers who are engaging with Azure Prompt Flows.

Create, Update & Test Azure Prompt Flow Locally — Part 2

In my previous article on ‘Getting Started With Azure Prompt Flow’, I explained about creating standard Azure Prompt Flow using portal and how we can test it. In continuation to that, this article focuses on how we can do the same thing locally, aka on our local machine.

So, to replicate existing Azure Prompt Flow or to create a new one, we need to setup Visual Studio Code.

Setting Up VS Code

To play seamlessly with Prompt Flow locally, we need to install an extension named Prompt flow for VS Code.

It is not mandatory to install extension but good to have as it will help us to visualize entire flow in VS Code.

Once the extension is installed, you will see a new icon on your left toolbar:

And clicking on flow.dag.yaml file, you would be able to visualize your flow:

Connecting Flow From VS Code On Local Machine

Once we have the setup ready, we need to write few lines of code to connect our flow to local machine and that can eb done using this:

Install Dependencies

from promptflow import PFClient
from promptflow.connections import AzureOpenAIConnection
pf_client = PFClient()

Grab Connection Settings For LLM

con_name = "sh-aoai-con"
conn = pf_client.connections.get(name=con_name)

Test Flow

flow_path = "Flow-created-on-1-22"
flow_input = {"topic":"book"}
flow_result = pf_client.test(flow=flow_path,inputs=flow_input)
flow_result

Executing above lines will give you below output in VS Code:

Conclusion

I didn’t explain every single thing here as I’ve a very well drafted video for this. I would recommend you watch the recoding for complete understanding of what is going on under the hood:

Happy prompting!

Azure
Prompt
AI
OpenAI
Llm
Recommended from ReadMedium