mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
33f84f9ed2
* Improve fidelity of OpenAI Responses server and add Conversations * Merge * nit * Undo prior change * Undo prior change * Review feedback * Review feedback * Fix test * Use simpler JsonDocument approach for polymorphic deserialization * More review feedback * dotnet format
57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using Microsoft.Agents.AI;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Microsoft.Extensions.Hosting;
|
|
|
|
/// <summary>
|
|
/// Extension methods for <see cref="IHostApplicationBuilder"/> to configure OpenAI support.
|
|
/// </summary>
|
|
public static class MicrosoftAgentAIHostingOpenAIHostApplicationBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds support for exposing <see cref="AIAgent"/> instances via OpenAI ChatCompletions.
|
|
/// </summary>
|
|
/// <param name="builder">The <see cref="IHostApplicationBuilder"/> to configure.</param>
|
|
/// <returns>The <see cref="IHostApplicationBuilder"/> for method chaining.</returns>
|
|
public static IHostApplicationBuilder AddOpenAIChatCompletions(this IHostApplicationBuilder builder)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(builder);
|
|
|
|
builder.Services.AddOpenAIChatCompletions();
|
|
|
|
return builder;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds support for exposing <see cref="AIAgent"/> instances via OpenAI Responses.
|
|
/// </summary>
|
|
/// <param name="builder">The <see cref="IHostApplicationBuilder"/> to configure.</param>
|
|
/// <returns>The <see cref="IHostApplicationBuilder"/> for method chaining.</returns>
|
|
public static IHostApplicationBuilder AddOpenAIResponses(this IHostApplicationBuilder builder)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(builder);
|
|
|
|
builder.Services.AddOpenAIResponses();
|
|
|
|
return builder;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds support for exposing <see cref="AIAgent"/> instances via OpenAI Responses.
|
|
/// </summary>
|
|
/// <param name="builder">The <see cref="IHostApplicationBuilder"/> to configure.</param>
|
|
/// <returns>The <see cref="IHostApplicationBuilder"/> for method chaining.</returns>
|
|
public static IHostApplicationBuilder AddOpenAIConversations(this IHostApplicationBuilder builder)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(builder);
|
|
|
|
builder.Services.AddOpenAIConversations();
|
|
|
|
return builder;
|
|
}
|
|
}
|