https://github.com/jodendaal/azure.cognitiveservices.client
Client library for calling Azure Cognitive Services
https://github.com/jodendaal/azure.cognitiveservices.client
Last synced: 7 months ago
JSON representation
Client library for calling Azure Cognitive Services
- Host: GitHub
- URL: https://github.com/jodendaal/azure.cognitiveservices.client
- Owner: jodendaal
- License: mit
- Created: 2023-03-16T17:00:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-25T09:14:16.000Z (over 2 years ago)
- Last Synced: 2025-03-26T01:06:22.471Z (7 months ago)
- Language: C#
- Homepage:
- Size: 316 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Azure.CognitiveServices.Client
Client library for calling Azure Cognitive Services
# Getting started
Install package [Nuget package](https://www.nuget.org/packages/CognitiveServices.AI.Client)
```powershell
Install-Package CognitiveServices.AI.Client
```
Register services using the provided extension methods
```csharp
//Add Azure OpenAI
builder.Services
.AddAzureOpenAIHttpService(httpClientOptions => GetRetryPolicy())
.AddAzureOpenAITextCompletion()
.AddAzureOpenAITextEmbeddings()
.AddAzureOpenAIChatCompletion();
```
## Streaming Method
```csharp
var config = ServiceProvider.GetRequiredService>().Get("chat");
var chatService = ServiceProvider.GetRequiredService();
await foreach (var response in chatService.CreateStream("Say This is a test.", config, options =>
{
options.MaxTokens = 200;
options.N = 1;
options.Temperature = 1;
}))
{
Console.WriteLine(response?.Value?.ToString());
}
```
## Synchronous Method
```csharp
var config = ServiceProvider.GetRequiredService>().Get("chat");
var completionService = ServiceProvider.GetRequiredService();
var completionResponse = await completionService.CreateAsync("Say This is a test.", config, options =>
{
options.MaxTokens = 200;
options.N = 1;
options.Temperature = 1;
});
Console.WriteLine(completionResponse.Value!.ToString());
```
## Examples
### Blazor
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/Azure.CognitiveService.Client.BlazorApp
### API
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/examples/Azure.CognitiveService.API
### Console
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/examples/Azure.CognitiveService.Client.ConsoleApp
### Functions App
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/Azure.CognitiveService.Client.FunctionsApp
### Integration Tests
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/Tests/Azure.CognitiveService.Client.Integration.Tests
## Model References
https://github.com/jodendaal/Azure.CognitiveServices.Client/tree/main/src/Azure.CognitiveServices.Client/Azure.CognitiveServices.Client/OpenAI/Models