Skip to main content

Posts

Showing posts with the label AzureOpenAI

Authenticate your Azure OpenAI Based App Using Microsoft Entra ID

If you’re using Azure OpenAI then you must be aware that the most common and easiest way to authenticate our application is using app-key. The key-based authentication approach is very popular because it is very straightforward. Let's have a quick look at the below code snippet: from openai import AzureOpenAI client = AzureOpenAI ( api_key = 'KEY_GOES_HERE' , api_version = "2024-02-01" , azure_endpoint = 'ENDPOINT_GOES_HERE' ) response = client . completions . create ( model = 'MODEL_GOES_HERE' , prompt = 'Tell me a joke' , max_tokens = 80 ) print ( "\n ##########" ) print ( response . choices [ 0 ] . text ) The above code snippet constructs the AzureOpenAI client object using api-key,api-version, and endpoint. Then, this object makes a call to the completion endpoint with the required parameters. Of course, app key works very well for the experimentation purpose and is not very well suited for ente...

Generate The Streamed Response Using Semantic Kernel

Semantic Kernel , a powerful tool for integrating large language models into your applications, now supports streaming responses. In this blog post, we’ll explore how to leverage this feature to obtain streamed results from LLMs like AzureOpenAI and OpenAI. Why Streamed Responses Matter When working with language models, especially in conversational scenarios, streaming responses offer several advantages: Real-time Interaction: Streaming allows you to receive partial responses as they become available, enabling more interactive and dynamic conversations. Reduced Latency: Instead of waiting for the entire response, you can start processing and displaying content incrementally, reducing overall latency. Efficient Resource Usage: Streaming conserves memory and resources by handling data in smaller chunks. How to Use Streaming Responses I've published a complete video on how to generate this using Python and that can be found on my YouTube channel named Shweta Lodha . Here, I'm jus...