MLearning.ai
Published in

MLearning.ai

Azure Open AI with Power Apps

Let’s build a Power App to use Azure Open AI for various use cases.

What’s needed.

Create a Power App

Power Flow

https://resourcename.openai.azure.com/openai/deployments/davinci003/completions?api-version=2022-12-01
{
"prompt": @{triggerBody()['Initializevariable_Value']},
"max_tokens": 100,
"temperature": 1
}
{
"id": "cmpl-xxxxxxxxxxx",
"object": "text_completion",
"created": 1640707195,
"model": "davinci:2020-05-03",
"choices": [
{
"text": " really bright. You can see it in the sky at night.\nJupiter is the third brightest thing in the sky, after the Moon and Venus.\n",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
]
}
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"created": {
"type": "integer"
},
"model": {
"type": "string"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"index": {
"type": "integer"
},
"logprobs": {},
"finish_reason": {
"type": "string"
}
},
"required": [
"text",
"index",
"logprobs",
"finish_reason"
]
}
}
}
}
{
"type": "object",
"properties": {
"text": {
"type": "string"
},
"index": {
"type": "integer"
},
"finish_reason": {
"type": "string"
},
"logprobs": {}
}
}

Power Apps

Note: this process can be applied to any HTTP REST enabled actions needed to be invoked by Power Apps
openaitext
UpdateContext({openaitext: "A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.
Tl;dr"})
UpdateContext({openaitext: "### Postgres SQL tables, with their properties:
#
# Employee(id, name, department_id)
# Department(id, name, address)
# Salary_Payments(id, employee_id, amount, date)
#
### A query to list the names of the departments which employed more than 10 employees in the last 3 months
SELECT"})
UpdateContext({openaitext:"Classify the following news article into 1 of the following categories: categories: [Business, Tech, Politics, Sport, Entertainment]
news article: Donna Steffensen Is Cooking Up a New Kind of Perfection. The Internet’s most beloved cooking guru has a buzzy new book and a fresh new perspective:Classified category:"})
UpdateContext({openaitext:"There are many fruits that were found on the recently discovered planet Goocrux. There are neoskizzles that grow there, which are purple and taste like candy. There are also loheckles, which are a grayish blue fruit and are very tart, a little bit like a lemon. Pounits are a bright green color and are more savory than sweet. There are also plenty of loopnovas which are a neon pink flavor and taste like cotton candy. Finally, there are fruits called glowls, which have a very sour and bitter taste which is acidic and caustic, and a pale orange tinge to them.
Please make a table summarizing the fruits from Goocrux
| Fruit | Color | Flavor |
| Neoskizzles | Purple | Sweet |
| Loheckles | Grayish blue | Tart |"})
UpdateContext({openaitext: "The following is a list of companies and the categories they fall into
Facebook: Social media, Technology
LinkedIn: Social media, Technology, Enterprise, Careers
Uber: Transportation, Technology, Marketplace
Unilever: Conglomerate, Consumer Goods
Mcdonalds: Food, Fast Food, Logistics, Restaurants
FedEx:"})
Set(summarytext,Openaisummarization.Run(TextInput1.Text))
summarytext.summarytext

--

--

Data Scientists must think like an artist when finding a solution when creating a piece of code. ⚪️ Artists enjoy working on interesting problems, even if there is no obvious answer ⚪️ linktr.ee/mlearning 🔵 Follow to join our 28K+ Unique DAILY Readers 🟠

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store