Hi Jasmeet Singh!
Welcome to Microsoft Q&A Forum, thank you for posting your query here.
Not sure on Portal UI way, but you can definitely check respective Python SDK for the API to send Get and Post requests to API to get desired queries which can be used as prompt_query in OpenAI get completion response or embedding.
Once you complete testing the SDK, you can use them in flask api to deploy them through Azure webapp.
Attached sample code for chat completion and documents for reference.
import os
import requests
from openai import AzureOpenAI
# Set up Azure OpenAI client
client = AzureOpenAI(
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-02-01"
)
# Function to fetch data from the API
def fetch_api_data():
api_key = "YOUR_API_KEY"
endpoint = "API_ENDPOINT"
headers = {"Authorization": f"Bearer {api_key}"}
response = requests.get(endpoint, headers=headers)
return response.json()
# Fetch data from the API
data = fetch_api_data()
# Prepare the prompt with API data
prompt = f"Given the following data: {data}, answer the question: 'Do other Azure AI services support customer managed keys?'"
# Get the response from Azure OpenAI
response = client.chat.completions.create(
model="gpt-35-turbo", # model = "deployment_name"
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Does Azure OpenAI support customer managed keys?"},
{"role": "assistant", "content": "Yes, customer managed keys are supported by Azure OpenAI."},
{"role": "user", "content": prompt}
]
)
# Print the response
print(response.choices[0].message.content)
import requests
api_key = "YOUR_API_KEY"
endpoint = "API_ENDPOINT"
headers = {"Authorization": f"Bearer {api_key}"}
response = requests.get(endpoint, headers=headers)
data = response.json()
#parse the json to get desired text which can be used a prompt to openai agent
#use the parse data in your prompt flow
from azure.ai.openai import OpenAI
openai_client = OpenAI(api_key="YOUR_OPENAI_API_KEY")
#data from above api call has been used in the prompt below
prompt = f"Given the following data: {data}, answer the question: 'What is the key insight?'"
response = openai_client.chat.Completion.create(engine="text-davinci-002", prompt=prompt)
print(response.choices[0].text.strip())
Kindly refer below for detailed SDK usage.
Please don't forget to upvote this answer if it helped.
Thank you.