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

Update latest from main #10635

Closed
wants to merge 5 commits into from
Closed
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
6 changes: 3 additions & 3 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AWSSDK.BedrockAgent" Version="3.7.416.4" />
<PackageVersion Include="AWSSDK.BedrockAgentRuntime" Version="3.7.418.3" />
<PackageVersion Include="AWSSDK.BedrockAgent" Version="4.0.0-preview.5" />
<PackageVersion Include="AWSSDK.BedrockAgentRuntime" Version="4.0.0-preview.5" />
<PackageVersion Include="AWSSDK.BedrockRuntime" Version="4.0.0-preview.5" />
<PackageVersion Include="AWSSDK.Core" Version="4.0.0-preview.5" />
<PackageVersion Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
<PackageVersion Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.0-preview.5" />
<PackageVersion Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageVersion Include="Azure.AI.Inference" Version="1.0.0-beta.2" />
<PackageVersion Include="Azure.AI.OpenAI" Version="[2.2.0-beta.1]" />
Expand Down
4 changes: 2 additions & 2 deletions dotnet/nuget/nuget-package.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project>
<PropertyGroup>
<!-- Central version prefix - applies to all nuget packages. -->
<VersionPrefix>1.37.0</VersionPrefix>
<VersionPrefix>1.38.0</VersionPrefix>
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>

<Configurations>Debug;Release;Publish</Configurations>
<IsPackable>true</IsPackable>

<!-- Package validation. Baseline Version should be the latest version available on NuGet. -->
<PackageValidationBaselineVersion>1.36.1</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion>1.37.0</PackageValidationBaselineVersion>
<!-- Validate assembly attributes only for Publish builds -->
<NoWarn Condition="'$(Configuration)' != 'Publish'">$(NoWarn);CP0003</NoWarn>
<!-- Do not validate reference assemblies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

namespace Agents;

Expand All @@ -23,7 +22,7 @@ public async Task UseAutoFunctionInvocationFilterWithAgentInvocationAsync()
{
Instructions = "Answer questions about the menu.",
Kernel = CreateKernelWithFilter(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

KernelPlugin plugin = KernelPluginFactory.CreateFromType<MenuPlugin>();
Expand Down Expand Up @@ -70,7 +69,7 @@ public async Task UseAutoFunctionInvocationFilterWithAgentChatAsync()
{
Instructions = "Answer questions about the menu.",
Kernel = CreateKernelWithFilter(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

KernelPlugin plugin = KernelPluginFactory.CreateFromType<MenuPlugin>();
Expand Down Expand Up @@ -111,7 +110,7 @@ public async Task UseAutoFunctionInvocationFilterWithStreamingAgentInvocationAsy
{
Instructions = "Answer questions about the menu.",
Kernel = CreateKernelWithFilter(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

KernelPlugin plugin = KernelPluginFactory.CreateFromType<MenuPlugin>();
Expand Down Expand Up @@ -174,7 +173,7 @@ public async Task UseAutoFunctionInvocationFilterWithStreamingAgentChatAsync()
{
Instructions = "Answer questions about the menu.",
Kernel = CreateKernelWithFilter(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

KernelPlugin plugin = KernelPluginFactory.CreateFromType<MenuPlugin>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

namespace Agents;
/// <summary>
Expand All @@ -24,7 +23,7 @@ public async Task SerializeAndRestoreAgentGroupChatAsync()
Instructions = HostInstructions,
Name = HostName,
Kernel = this.CreateKernelWithChatCompletion(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

// Initialize plugin and add to the agent's Kernel (same as direct Kernel usage).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

namespace Agents;

Expand All @@ -29,15 +28,15 @@ public async Task UseServiceSelectionWithChatCompletionAgentAsync()
new()
{
Kernel = kernel,
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { ServiceId = ServiceKeyGood }),
Arguments = new KernelArguments(new PromptExecutionSettings() { ServiceId = ServiceKeyGood }),
};

// Define the agent targeting ServiceId = ServiceKeyBad
ChatCompletionAgent agentBad =
new()
{
Kernel = kernel,
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { ServiceId = ServiceKeyBad }),
Arguments = new KernelArguments(new PromptExecutionSettings() { ServiceId = ServiceKeyBad }),
};

// Define the agent with no explicit ServiceId defined
Expand All @@ -57,21 +56,21 @@ public async Task UseServiceSelectionWithChatCompletionAgentAsync()

// Invoke agent with override arguments where ServiceId = ServiceKeyGood: Expect agent response
Console.WriteLine("\n[Bad Agent: Good ServiceId Override]");
await InvokeAgentAsync(agentBad, new(new OpenAIPromptExecutionSettings() { ServiceId = ServiceKeyGood }));
await InvokeAgentAsync(agentBad, new(new PromptExecutionSettings() { ServiceId = ServiceKeyGood }));

// Invoke agent with override arguments where ServiceId = ServiceKeyBad: Expect failure due to invalid service key
Console.WriteLine("\n[Good Agent: Bad ServiceId Override]");
await InvokeAgentAsync(agentGood, new(new OpenAIPromptExecutionSettings() { ServiceId = ServiceKeyBad }));
await InvokeAgentAsync(agentGood, new(new PromptExecutionSettings() { ServiceId = ServiceKeyBad }));
Console.WriteLine("\n[Default Agent: Bad ServiceId Override]");
await InvokeAgentAsync(agentDefault, new(new OpenAIPromptExecutionSettings() { ServiceId = ServiceKeyBad }));
await InvokeAgentAsync(agentDefault, new(new PromptExecutionSettings() { ServiceId = ServiceKeyBad }));

// Invoke agent with override arguments with no explicit ServiceId: Expect agent response
Console.WriteLine("\n[Good Agent: No ServiceId Override]");
await InvokeAgentAsync(agentGood, new(new OpenAIPromptExecutionSettings()));
await InvokeAgentAsync(agentGood, new(new PromptExecutionSettings()));
Console.WriteLine("\n[Bad Agent: No ServiceId Override]");
await InvokeAgentAsync(agentBad, new(new OpenAIPromptExecutionSettings()));
await InvokeAgentAsync(agentBad, new(new PromptExecutionSettings()));
Console.WriteLine("\n[Default Agent: No ServiceId Override]");
await InvokeAgentAsync(agentDefault, new(new OpenAIPromptExecutionSettings()));
await InvokeAgentAsync(agentDefault, new(new PromptExecutionSettings()));

// Local function to invoke agent and display the conversation messages.
async Task InvokeAgentAsync(ChatCompletionAgent agent, KernelArguments? arguments = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

namespace Agents;

Expand Down Expand Up @@ -50,7 +49,7 @@ public async Task UseStreamingChatCompletionAgentWithPluginAsync()
Name = "Host",
Instructions = MenuInstructions,
Kernel = this.CreateKernelWithChatCompletion(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

// Initialize plugin and add to the agent's Kernel (same as direct Kernel usage).
Expand Down
8 changes: 5 additions & 3 deletions dotnet/samples/Concepts/Agents/ChatCompletion_Templating.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ await InvokeChatCompletionAgentWithTemplateAsync(
"""
Write a one verse poem on the requested topic in the style of {{$style}}.
Always state the requested style of the poem.
""");
""",
PromptTemplateConfig.SemanticKernelTemplateFormat,
new KernelPromptTemplateFactory());
}

[Fact]
Expand Down Expand Up @@ -79,8 +81,8 @@ Always state the requested style of the poem.

private async Task InvokeChatCompletionAgentWithTemplateAsync(
string instructionTemplate,
string? templateFormat = null,
IPromptTemplateFactory? templateFactory = null)
string templateFormat,
IPromptTemplateFactory templateFactory)
{
// Define the agent
PromptTemplateConfig templateConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task NestedChatWithAggregatorAgentAsync()
Console.WriteLine($"! {Model}");

OpenAIPromptExecutionSettings jsonSettings = new() { ResponseFormat = ChatResponseFormat.CreateJsonObjectFormat() };
OpenAIPromptExecutionSettings autoInvokeSettings = new() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() };
PromptExecutionSettings autoInvokeSettings = new() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() };

ChatCompletionAgent internalLeaderAgent = CreateAgent(InternalLeaderName, InternalLeaderInstructions);
ChatCompletionAgent internalGiftIdeaAgent = CreateAgent(InternalGiftIdeaAgentName, InternalGiftIdeaAgentInstructions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ await InvokeAssistantAgentWithTemplateAsync(
"""
Write a one verse poem on the requested topic in the styles of {{$style}}.
Always state the requested style of the poem.
""");
""",
PromptTemplateConfig.SemanticKernelTemplateFormat,
new KernelPromptTemplateFactory());
}

[Fact]
Expand Down
3 changes: 2 additions & 1 deletion dotnet/samples/GettingStartedWithAgents/Step01_Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ public async Task UseTemplateForChatCompletionAgentAsync()
// Define the agent
string generateStoryYaml = EmbeddedResource.Read("GenerateStory.yaml");
PromptTemplateConfig templateConfig = KernelFunctionYaml.ToPromptTemplateConfig(generateStoryYaml);
KernelPromptTemplateFactory templateFactory = new();

// Instructions, Name and Description properties defined via the config.
ChatCompletionAgent agent =
new(templateConfig)
new(templateConfig, templateFactory)
{
Kernel = this.CreateKernelWithChatCompletion(),
Arguments =
Expand Down
8 changes: 4 additions & 4 deletions dotnet/samples/GettingStartedWithAgents/Step02_Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Plugins;
using Resources;

Expand Down Expand Up @@ -53,11 +52,12 @@ public async Task UseChatCompletionWithTemplateExecutionSettingsAsync()
// Read the template resource
string autoInvokeYaml = EmbeddedResource.Read("AutoInvokeTools.yaml");
PromptTemplateConfig templateConfig = KernelFunctionYaml.ToPromptTemplateConfig(autoInvokeYaml);
KernelPromptTemplateFactory templateFactory = new();

// Define the agent:
// Execution-settings with auto-invocation of plubins defined via the config.
// Execution-settings with auto-invocation of plugins defined via the config.
ChatCompletionAgent agent =
new(templateConfig)
new(templateConfig, templateFactory)
{
Kernel = this.CreateKernelWithChatCompletion()
};
Expand All @@ -82,7 +82,7 @@ private ChatCompletionAgent CreateAgentWithPlugin(
Instructions = instructions,
Name = name,
Kernel = this.CreateKernelWithChatCompletion(),
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
};

// Initialize plugin and add to the agent's Kernel (same as direct Kernel usage).
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/Agents/Abstractions/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class Agent
protected internal abstract IEnumerable<string> GetChannelKeys();

/// <summary>
/// Produce the an <see cref="AgentChannel"/> appropriate for the agent type.
/// Produce an <see cref="AgentChannel"/> appropriate for the agent type.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>An <see cref="AgentChannel"/> appropriate for the agent type.</returns>
Expand All @@ -78,7 +78,7 @@ public abstract class Agent
protected internal abstract Task<AgentChannel> CreateChannelAsync(CancellationToken cancellationToken);

/// <summary>
/// Produce the an <see cref="AgentChannel"/> appropriate for the agent type based on the provided state.
/// Produce an <see cref="AgentChannel"/> appropriate for the agent type based on the provided state.
/// </summary>
/// <param name="channelState">The channel state, as serialized</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Expand Down
8 changes: 4 additions & 4 deletions dotnet/src/Agents/Abstractions/AgentChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class AgentChannel
protected internal abstract string Serialize();

/// <summary>
/// Receive the conversation messages. Used when joining a conversation and also during each agent interaction..
/// Receive the conversation messages. Used when joining a conversation and also during each agent interaction.
/// </summary>
/// <param name="history">The chat history at the point the channel is created.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Expand All @@ -37,7 +37,7 @@ public abstract class AgentChannel
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <remarks>
/// The channel wont' be reused; rather, it will be discarded and a new one created.
/// The channel won't be reused; rather, it will be discarded and a new one created.
/// </remarks>
protected internal abstract Task ResetAsync(CancellationToken cancellationToken = default);

Expand Down Expand Up @@ -86,7 +86,7 @@ protected internal abstract IAsyncEnumerable<StreamingChatMessageContent> Invoke
public abstract class AgentChannel<TAgent> : AgentChannel where TAgent : Agent
{
/// <summary>
/// Process a discrete incremental interaction between a single <see cref="Agent"/> an a <see cref="AgentChat"/>.
/// Process a discrete incremental interaction between a single <see cref="Agent"/> and a <see cref="AgentChat"/>.
/// </summary>
/// <param name="agent">The agent actively interacting with the chat.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Expand All @@ -112,7 +112,7 @@ public abstract class AgentChannel<TAgent> : AgentChannel where TAgent : Agent
return this.InvokeAsync((TAgent)agent, cancellationToken);
}
/// <summary>
/// Process a discrete incremental interaction between a single <see cref="Agent"/> an a <see cref="AgentChat"/>.
/// Process a discrete incremental interaction between a single <see cref="Agent"/> and a <see cref="AgentChat"/>.
/// </summary>
/// <param name="agent">The agent actively interacting with the chat.</param>
/// <param name="messages">The receiver for the completed messages generated</param>
Expand Down
6 changes: 3 additions & 3 deletions dotnet/src/Agents/Abstractions/AgentChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class AgentChat

/// <summary>
/// Gets a value that indicates whether a chat operation is active. Activity is defined as
/// any the execution of any public method.
/// any execution of a public method.
/// </summary>
public bool IsActive => Interlocked.CompareExchange(ref this._isActive, 1, 1) > 0;

Expand Down Expand Up @@ -197,7 +197,7 @@ public void AddChatMessages(IReadOnlyList<ChatMessageContent> messages)
}

/// <summary>
/// Processes a discrete incremental interaction between a single <see cref="Agent"/> an a <see cref="AgentChat"/>.
/// Processes a discrete incremental interaction between a single <see cref="Agent"/> and a <see cref="AgentChat"/>.
/// </summary>
/// <param name="agent">The agent actively interacting with the chat.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Expand Down Expand Up @@ -256,7 +256,7 @@ protected async IAsyncEnumerable<ChatMessageContent> InvokeAgentAsync(
}

/// <summary>
/// Processes a discrete incremental interaction between a single <see cref="Agent"/> an a <see cref="AgentChat"/>.
/// Processes a discrete incremental interaction between a single <see cref="Agent"/> and a <see cref="AgentChat"/>.
/// </summary>
/// <param name="agent">The agent actively interacting with the chat.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SemanticKernel.Core\SemanticKernel.Core.csproj" />
<ProjectReference Include="..\..\SemanticKernel.Abstractions\SemanticKernel.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ internal sealed class BroadcastQueue
private readonly Dictionary<string, QueueReference> _queues = [];

/// <summary>
/// Defines the yield duration when waiting on a channel-queue to synchronize.
/// to drain.
/// Defines the yield duration when waiting on a channel-queue to synchronize
/// and drain.
/// </summary>
public TimeSpan BlockDuration { get; set; } = TimeSpan.FromSeconds(0.1);

Expand Down
Loading
Loading