Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Added an example of OpenAI Realtime API #9662

Merged
merged 8 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dotnet/SK-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Process.IntegrationTests.Re
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OllamaFunctionCalling", "samples\Demos\OllamaFunctionCalling\OllamaFunctionCalling.csproj", "{481A680F-476A-4627-83DE-2F56C484525E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAIRealtime", "samples\Demos\OpenAIRealtime\OpenAIRealtime.csproj", "{6154129E-7A35-44A5-998E-B7001B5EDE14}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1133,6 +1135,12 @@ Global
{481A680F-476A-4627-83DE-2F56C484525E}.Publish|Any CPU.Build.0 = Debug|Any CPU
{481A680F-476A-4627-83DE-2F56C484525E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{481A680F-476A-4627-83DE-2F56C484525E}.Release|Any CPU.Build.0 = Release|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Publish|Any CPU.Build.0 = Debug|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6154129E-7A35-44A5-998E-B7001B5EDE14}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1288,6 +1296,7 @@ Global
{A2D349C4-EA6E-465C-B86D-00C2942E3135} = {0D8C6358-5DAA-4EA6-A924-C268A9A21BC9}
{B35B1DEB-04DF-4141-9163-01031B22C5D1} = {0D8C6358-5DAA-4EA6-A924-C268A9A21BC9}
{481A680F-476A-4627-83DE-2F56C484525E} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
{6154129E-7A35-44A5-998E-B7001B5EDE14} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}
Expand Down
dmytrostruk marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
26 changes: 26 additions & 0 deletions dotnet/samples/Demos/OpenAIRealtime/OpenAIRealtime.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);VSTHRD111,CA2007,CS8618,CS1591,CA1052,SKEXP0001</NoWarn>
<UserSecretsId>5ee045b0-aea3-4f08-8d31-32d1a6f8fed0</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<ProjectReference Include="..\..\..\src\Connectors\Connectors.AzureOpenAI\Connectors.AzureOpenAI.csproj" />
<ProjectReference Include="..\..\..\src\SemanticKernel.Core\SemanticKernel.Core.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Assets\realtime_whats_the_weather_pcm16_24khz_mono.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft. All rights reserved.

namespace OpenAIRealtime;

/// <summary>
/// Configuration for Azure OpenAI service.
/// </summary>
public class AzureOpenAIOptions
{
public const string SectionName = "AzureOpenAI";

/// <summary>
/// Azure OpenAI deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource
/// </summary>
public string DeploymentName { get; set; }

/// <summary>
/// Azure OpenAI deployment URL, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
/// </summary>
public string Endpoint { get; set; }

/// <summary>
/// Azure OpenAI API key, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
/// </summary>
public string ApiKey { get; set; }

public bool IsValid =>
!string.IsNullOrWhiteSpace(this.DeploymentName) &&
!string.IsNullOrWhiteSpace(this.Endpoint) &&
!string.IsNullOrWhiteSpace(this.ApiKey);
}
19 changes: 19 additions & 0 deletions dotnet/samples/Demos/OpenAIRealtime/Options/OpenAIOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft. All rights reserved.

namespace OpenAIRealtime;

/// <summary>
/// Configuration for OpenAI service.
/// </summary>
public class OpenAIOptions
{
public const string SectionName = "OpenAI";

/// <summary>
/// OpenAI API key, see https://platform.openai.com/account/api-keys
/// </summary>
public string ApiKey { get; set; }

public bool IsValid =>
!string.IsNullOrWhiteSpace(this.ApiKey);
}
Loading
Loading