Share via

Connecting Real-Time Web Data to Azure OpenAI Models

Zamad Shakil 40 Reputation points
22 Mar 2024, 12:38 am

As a non-technical person, I've been using Azure OpenAi models like gpt-3.5 and gpt-4 by Curl API from Azure OpenAI Studio. However, I would like to connect real-time web access to these models and then use these models with only Curl API. I believe this could be achieved by connecting a web scraper with these models in Prompt Flow(may be), but I'm unsure of the best way to do this and if there's any documentation available.

Note that: I just know only basic Python and Curl API Connector.

My main goal is to use Azure OpenAI Models with web-access by only Curl. How can I do this?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,904 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,331 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,941 Reputation points
    24 Mar 2024, 2:59 am

    @Zamad Shakil

    Thanks for reaching out to us, it seems your goal is connecting real-time web data to Azure OpenAI models using cURL.

    This can be achieved by using a web scraping tool, an API to get the data, and then processing this data through Azure OpenAI models.

    I can provide a high-level overview of the steps you might take, please review it and make changes as your requirement.

    1. Web Scraping: Use a Python library like Beautiful Soup or Scrapy to scrape data from the web. This will involve writing a script to access a webpage, extract the relevant information, and then save this information in a format that can be used by the OpenAI models.
    2. Process Data through Azure OpenAI Models: Once you've obtained the data, you can use cURL to send a POST request to the OpenAI API, which will process the data through the desired model. You will need to format your request according to the OpenAI API documentation. Here's a basic example of how you might send a request to the OpenAI API using cURL: Example as below -
    curl -H "Authorization: Bearer YOUR_OPENAI_KEY" \  
         -H "Content-Type: application/json" \  
         -d '{"model": "text-davinci-002", "prompt": "YOUR_PROMPT", "max_tokens": 60}' \  
         https://api.openai.com/v1/engines/davinci-codex/completions  
    

    In this example, YOUR_OPENAI_KEY is your OpenAI API key, YOUR_PROMPT is the data you obtained from web scraping, and text-davinci-002 is the model you wish to use, you can change it as your requirement.

    1. Interpret the Response: The response from the OpenAI API will be in JSON format. You can parse this response to extract the generated text. Bear in mind that you'll need to adjust these steps according to the specifics of your project.

    As you are a non-technical person, you might need to collaborate with a developer or learn more about Python, web scraping, and working with APIs to accomplish this task. It's a learning process, but with time and practice, you can certainly achieve your goal.

    I hope this ignite some ideas for you.

    Regards,

    Yutong

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.