Azure has recently introduced Open AI extensions to Azure Functions. These extensions enable developers to integrate the functions with Open AI seamlessly using Open AI LLM bindings in Azure Functions.
I am writing a four-part series, and this is the 1st part of the Series which discusses Text Completion API and its implementation.
Pre-Requisites:
1 .NET 8 - VS 2022 preferred
2 Azure Isolated Functions Template
Note: Going ahead Azure functions support only isolated mode
3 Open AI API Key from the Open AI portal
OR
i. Azure Open AI Endpoint
ii. Azure Open AI Key
Git hub repo link: https://github.com/prakash-gudipati/Demo.OpenAI.Functions.Extensions
Text completions input binding uses Text Completions API of Open AI that responds which is part of Chat Completions API. It responds with the text for a prompt.
The Azure function below responds with 250 words brief about any city. The city is passed in as a parameter to the Function.
[Function("TextCompletion")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, Route = "citydescription/{city}")] HttpRequestData req,
[TextCompletionInput("Give 250 words brief about {city}")] TextCompletionResponse response)
{
return new OkObjectResult(response.Content);
}
Let's go ahead and test this function in the postman
That's it!!
You can see how simple it is to integrate Open AI extensions with Azure Functions.
Go through the github repo. Let me know how it goes.