MeshWeaver.AI.AzureOpenAI 2.3.0

dotnet add package MeshWeaver.AI.AzureOpenAI --version 2.3.0
                    
NuGet\Install-Package MeshWeaver.AI.AzureOpenAI -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MeshWeaver.AI.AzureOpenAI" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MeshWeaver.AI.AzureOpenAI" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="MeshWeaver.AI.AzureOpenAI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MeshWeaver.AI.AzureOpenAI --version 2.3.0
                    
#r "nuget: MeshWeaver.AI.AzureOpenAI, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MeshWeaver.AI.AzureOpenAI@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MeshWeaver.AI.AzureOpenAI&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=MeshWeaver.AI.AzureOpenAI&version=2.3.0
                    
Install as a Cake Tool

MeshWeaver.AI.AzureOpenAI

Overview

MeshWeaver.AI.AzureOpenAI provides Azure OpenAI integration for the MeshWeaver AI framework, enabling AI-powered agent chats using Azure OpenAI's ChatCompletionAgent. This library is designed for stateless chat completion scenarios without persistent assistant storage.

Features

  • Azure OpenAI Integration: Direct integration with Azure OpenAI services
  • ChatCompletionAgent Support: Uses Microsoft Semantic Kernel's ChatCompletionAgent for stateless operations
  • Factory Pattern: Implements the factory pattern for creating and managing agent chats
  • Configuration-Based Setup: Uses AIConfiguration for secure credential management
  • Extensible Architecture: Built on top of MeshWeaver.AI's ChatCompletionAgentChatFactory base class

Installation

This package is part of the MeshWeaver solution and should be referenced as a project dependency:

<ProjectReference Include="..\MeshWeaver.AI.AzureOpenAI\MeshWeaver.AI.AzureOpenAI.csproj" />

Configuration

1. Configure AI Credentials

Add the following configuration to your appsettings.json:

{
  "AI": {
    "Url": "https://your-azure-openai-endpoint.openai.azure.com/",
    "ApiKey": "your-api-key-here",
    "Models": ["gpt-4", "gpt-35-turbo"]
  }
}

2. Register Services

In your Program.cs or service configuration:

using MeshWeaver.AI.AzureOpenAI;

// Configure AI credentials
builder.Services.Configure<AIConfiguration>(
    builder.Configuration.GetSection("AI"));

// Add Azure OpenAI services
builder.Services.AddAzureOpenAI();

Usage

Basic Implementation

public class MyService
{
    private readonly IAgentChatFactory _chatFactory;

    public MyService(IAgentChatFactory chatFactory)
    {
        _chatFactory = chatFactory;
    }

    public async Task<IAgentChat> CreateChatAsync()
    {
        var agentChat = await _chatFactory.CreateAsync();
        return agentChat;
    }
}

Agent Definition

Create custom agents by implementing IAgentDefinition:

public class MyCustomAgent : IAgentDefinition
{
    public string Name => "MyAgent";
    public string Description => "A custom AI agent for specific tasks";
    public string Instructions => "You are a helpful assistant specialized in...";
}

Architecture

Class Hierarchy

ChatCompletionAgentChatFactory (MeshWeaver.AI)
└── AzureOpenAIChatCompletionAgentChatFactory (MeshWeaver.AI.AzureOpenAI)

Key Components

  • AzureOpenAIChatCompletionAgentChatFactory: Main factory class for creating Azure OpenAI-powered agent chats
  • AzureOpenAIExtensions: Extension methods for service registration
  • AIConfiguration: Configuration model for Azure OpenAI credentials

Security Considerations

  • API Key Management: Store API keys securely using Azure Key Vault or similar secure storage
  • Environment Variables: Consider using environment variables for sensitive configuration
  • Network Security: Ensure secure communication with Azure OpenAI endpoints

Dependencies

  • Microsoft.SemanticKernel
  • Microsoft.Extensions.Options
  • Microsoft.Extensions.DependencyInjection.Abstractions
  • MeshWeaver.AI
  • MeshWeaver.Messaging.Hub

Troubleshooting

Common Issues

  1. Missing API Key: Ensure AIConfiguration.ApiKey is properly configured
  2. Invalid Endpoint: Verify the AIConfiguration.Url format
  3. Model Not Available: Check that the specified models exist in your Azure OpenAI deployment

Logging

Enable detailed logging to troubleshoot issues:

builder.Services.AddLogging(logging =>
{
    logging.AddConsole();
    logging.SetMinimumLevel(LogLevel.Debug);
});

Contributing

This project is part of the MeshWeaver ecosystem. Please follow the established patterns and conventions when contributing.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 166 8/4/2025
2.2.0 437 7/21/2025