Prompting with AI Builder – Graph Generator

Prompting with AI Builder – Graph Generator

The Journey

Ever heard of QuickChart? It’s a really cool API that allows you to render reports in a Canvas app by passing data through its open API. After a great chat with a friend, ideas were born.

Welcome to my Power Platform AI series. This series’ purpose is to help me document my learning journey and share my experience with the community as I progress through it. It is definitely not a series explaining best practices; I promise there will be a lot of mistakes.

So, without further ado, let’s explore.

 

AI Builder

AI Builder has been around for some time now. To sum it up, it’s a cloud-based tool that allows businesses to utilise various types of pre-built and custom AI models and prompts through a low-code, no-code experience. A standout benefit of AI Builder is its ability to form part of a deployable solution, allowing us to package a full Power Platform solution for external deployment. We can also reference these models and prompts through Power Apps, Power Automate, and Copilot Studio.

 

Azure AI

In addition to exploring AI Builder, as Power Platform people, we’re fortunate enough to be within the Microsoft ecosystem! So why not explore the Azure AI Services? Azure AI offers incredible extensibility. Using services like Azure ML studio, we can deploy our custom models directly into AI Builder. Furthermore, using Azure AI Studio, we gain access to dozens of prebuilt models such as GPT-4o, whisper, and more. There are Azure models, OpenAI models, and even Google and Meta models we can deploy. The exciting bit about Azure AI Studio is how we can leverage very powerful LLM models and simply pass prompts from our day-to-day tools like Power Apps and Power Automate through HTTP endpoints. It is a topic I will definitely be exploring more in my coming posts.

 

Building An AI Builder Prompt

The excitement about AI is currently on fire, but many are still misusing it. Prompting is something we should all be learning. It’s not just a skill that allows us to interact with AI more effectively but also helps grow our general communication skills when explaining what we want. Today, I’m building an AI Builder prompt and will be using it in a Power Apps canvas app.

The Prompt

I’ve headed to my developer environment in make.powerapps.com and navigated to the AI Hub.

I’ve selected Prompts and then created a custom prompt with the “Create text with GPT using prompt”.

 

I defined two input parameters that I intend to use in the prompt. The plan is to build a Graph Generator that can generate HTML graphs for inputted data through a canvas app. So my two input parameters are:

  • Report Information: The data and info the prompt needs to be able to build the report.
  • Graph Type: After a lot of trial and error, I figured it would be ideal to define a specific parameter to tell the prompt what type of graph to generate.

 

I also went to settings and updated the model to GPT 4o (preview), as this helped generate better HTML.

 

Now that my settings were defined, it was time for some trial and error. I started with the prompt:

You are a report builder and data analyst. Using HTML and inline css, you are required to build a report to summarise data. The output should be HTML code with inline css where single inverted commas, (‘) are used. Use the below information to generate the report in HTML. Be sure to only provide the HTML and no other text. Below is the report information: Generate me a {Graph Type} using the following Report information: {Report Information} with the title: Report Summary

 

I’ve recently learned that it’s beneficial to tell the GPT what its purpose is. This helps optimise the GPT response. My prompt now looked something like this:

 

As this was my first attempt, the response was not too great. The HTML output looked like this: (At least it did a good job explaining what the report was about .)

 

I then asked the OpenAI GPT to render me a bar graph in HTML following the same guidelines I provided the AI Builder prompt. Using the output, I added the HTML as well as another HTML template for a pie chart to the AI Builder prompt and explained that these were examples of graphs in HTML. To my surprise, this worked a lot better.

 

Now it was time to prompt this from a canvas app.

 

Prompting From A Canvas App

I spun up a quick canvas app and added a templated screen. I then added a dropdown for the graph type, a text input for the report information, and an HTML control to the page. I lastly added my prompt as a Datasource.

 

For the OnSelect in my Generate button, I called my prompt and passed in the two parameters, the report information and the graph type. I then wrapped the action in a Set function so I could pass the response to a global variable called glb_GeneratedReport.

 

//Run graph generator prompt
Set(glb_GeneratedReport,
  'Graph Generator'.Predict(txt_ReportScreen_ReportInfo.Text, drp_ReportScreen_GraphType.SelectedText.Value).Text
);


 

Within the HTML object, I placed the glb_GeneratedReport into the HTMLText property and was ready to play around.

 

The Results

Overall, I made three queries to the prompt, and it did not disappoint. Obviously, for an initial crack at this, I was pleasantly surprised at the prompt’s ability to analyse the data and graph it, even if the info was very basic. The pie chart definitely needed some work.

 

Conclusion

All in all, AI Builder prompts seem to be pretty nifty for small tasks. Would I use it to generate reports like I’ve just done, probably not. But I definitely would like to explore the other pre-built prompts and their capabilities. I did however find that the prompts were very restrictive and at the start, often failed to output the HTML. Even OpenAI’s ChatGPT did not like the idea of generating an HTML pie chart. The GPT said it could not be done. I had to google an example first, then paste the example in and get the result.

I do think you can have a lot of fun with AI Builder in a safe, easy-to-use environment, whereas extending into Azure AI Studio becomes a bit more overwhelming. Hopefully, I’ll get the chance to trial out some Azure AI models in the coming weeks.

Cheers for now

 

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *