From the course: Azure OpenAI in .NET
Integrate OpenAI models into your applications - .NET Tutorial
From the course: Azure OpenAI in .NET
Integrate OpenAI models into your applications
- [Instructor] Welcome to the second chapter of the training, Azure OpenAI for .NET Developer. And now that we've already dealt in the first chapter with basic information about OpenAI and how OpenAI models can be made available on Azure, it's time to continue in this chapter with information how we can integrate these models into our own applications, maybe in a brand new application, a groundbreaking, AI-infused application, or in existing applications where we maybe just want to enrich existing functionality with AI. And therefore, I would like to introduce two different interfaces that make it easy for us as .NET developers to communicate with the deployed LLM. The first and most rudimentary option is to communicate with the REST API of the LLM, and each OpenAI model provides a corresponding REST endpoint for this. The second option I would like to introduce is the .NET Azure OpenAI SDK, which makes it, from my perspective, much easier for us .NET developers to send requests to the LLM as it provides a more simple way to interact with the LLM, from my perspective again, in a straightforward way, using objects to provide information to the LLM and getting objects back as a response from questions from communications with the LLM instead of the raw JSON information that we have to prepare. when we talk to the LLM using REST API endpoints or the pure, raw JSON information that we get back from those calls. How can we now integrate OpenAI models into our own applications? And let's start here with the REST API endpoints that every deployment entails. So we start, as we have seen in the previous recordings, with the deployment of an Azure Cognitive Service, and then deploy the respective models in this instance of the Cognitive Service. This can be OpenAI models, but they can also be other models offered by Microsoft as part of the Azure Cognitive Services offering, such as vision models or maybe anomaly detection models, which, by the way, can detect anomalies in time-series data. Well, these models now, or more precisely, the instances of these models, provide a dedicated REST endpoint that we can easily access from our own application. And let us have now look how communication with these endpoints is working in the following sample. In this sample now, we don't ask the LLM a question. This time, we want the LLM to create a summary of a longer text provided on a web server, and we ask the LLM to do exactly this for us. This means that we maybe want to download information from Wikipedia and would like to summarize and significantly shorten the information for further processing without losing the core messages of the unstructured data from the web server. And remember, we've already done something similar because in a previous video, I've copied information from a Wikipedia article to help the LLM answer the question, who won the Super Bowl in 2023? What I've done was I've copied in this sample a whole paragraph from Wikipedia, which might not be, from a cost-perspective, a good thing, Stay with me. We will learn more how Microsoft charges the usage of LLM models, but for the moment, just have in mind that the more information we send into the LLM, the more expensive the call is. So summarizing information without losing the core information is an often used method to reduce costs.