// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.ChatClient;
///
/// Provides extension methods for building a from a .
///
public static class ChatClientBuilderExtensions
{
///
/// Build a from the pipeline described by this .
///
/// A builder for creating pipelines of .
///
/// Optional system instructions that guide the agent's behavior. These instructions are provided to the
/// with each invocation to establish the agent's role and behavior.
///
///
/// Optional name for the agent. This name is used for identification and logging purposes.
///
///
/// Optional human-readable description of the agent's purpose and capabilities.
/// This description can be useful for documentation and agent discovery scenarios.
///
///
/// Optional collection of tools that the agent can invoke during conversations.
/// These tools augment any tools that may be provided to the agent via when
/// the agent is run.
///
///
/// Optional logger factory for creating loggers used by the agent and its components.
///
///
/// Optional service provider for resolving dependencies required by AI functions and other agent components.
/// This is particularly important when using custom tools that require dependency injection.
///
/// A new instance.
public static ChatClientAgent BuildAIAgent(
this ChatClientBuilder builder,
string? instructions = null,
string? name = null,
string? description = null,
IList? tools = null,
ILoggerFactory? loggerFactory = null,
IServiceProvider? services = null) =>
Throw.IfNull(builder).Build(services).CreateAIAgent(
instructions: instructions,
name: name,
description: description,
tools: tools,
loggerFactory: loggerFactory,
services: services);
///
/// Creates a new instance.
///
/// A builder for creating pipelines of .
///
/// Configuration options that control all aspects of the agent's behavior, including chat settings,
/// message store factories, context provider factories, and other advanced configurations.
///
///
/// Optional logger factory for creating loggers used by the agent and its components.
///
///
/// Optional service provider for resolving dependencies required by AI functions and other agent components.
/// This is particularly important when using custom tools that require dependency injection.
///
/// A new instance.
public static ChatClientAgent BuildAIAgent(
this ChatClientBuilder builder,
ChatClientAgentOptions? options,
ILoggerFactory? loggerFactory = null,
IServiceProvider? services = null) =>
Throw.IfNull(builder).Build(services).CreateAIAgent(
options: options,
loggerFactory: loggerFactory,
services: services);
}