mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.Net: Adding ChatOptions configuration to the Agent level (#75)
* Adding ChatOptions configuration to the Agent level * fix warnings * Address Copilot Feedback * Add UT for new AgentExtensions * Add UnitTests for ChatOptions merging behavior * Fix warning * Address PR Feedback * Update dotnet/src/Microsoft.Agents/ChatCompletion/ChatClientAgent.cs Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> --------- Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
293cdb1846
commit
16cbc44611
@@ -15,23 +15,22 @@ public sealed class Step02_UsingTools(ITestOutputHelper output) : AgentSample(ou
|
||||
using var chatClient = base.GetOpenAIChatClient();
|
||||
|
||||
// Define the agent
|
||||
var menuTools = new MenuTools();
|
||||
ChatClientAgent agent =
|
||||
new(chatClient, new()
|
||||
{
|
||||
Name = "Host",
|
||||
Instructions = "Answer questions about the menu.",
|
||||
ChatOptions = new()
|
||||
{
|
||||
Tools = [
|
||||
AIFunctionFactory.Create(menuTools.GetMenu),
|
||||
AIFunctionFactory.Create(menuTools.GetSpecials),
|
||||
AIFunctionFactory.Create(menuTools.GetItemPrice)
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
var menuTools = new MenuTools();
|
||||
var chatOptions = new ChatOptions
|
||||
{
|
||||
Tools = [
|
||||
AIFunctionFactory.Create(menuTools.GetMenu),
|
||||
AIFunctionFactory.Create(menuTools.GetSpecials),
|
||||
AIFunctionFactory.Create(menuTools.GetItemPrice),
|
||||
],
|
||||
};
|
||||
|
||||
// Create the chat history thread to capture the agent interaction.
|
||||
var thread = agent.GetNewThread();
|
||||
|
||||
@@ -44,7 +43,7 @@ public sealed class Step02_UsingTools(ITestOutputHelper output) : AgentSample(ou
|
||||
async Task InvokeAgentAsync(string input)
|
||||
{
|
||||
this.WriteUserMessage(input);
|
||||
var response = await agent.RunAsync(input, thread, chatOptions: chatOptions);
|
||||
var response = await agent.RunAsync(input, thread);
|
||||
this.WriteResponseOutput(response);
|
||||
}
|
||||
}
|
||||
@@ -56,23 +55,22 @@ public sealed class Step02_UsingTools(ITestOutputHelper output) : AgentSample(ou
|
||||
using var chatClient = base.GetOpenAIChatClient();
|
||||
|
||||
// Define the agent
|
||||
var menuTools = new MenuTools();
|
||||
ChatClientAgent agent =
|
||||
new(chatClient, new()
|
||||
{
|
||||
Name = "Host",
|
||||
Instructions = "Answer questions about the menu.",
|
||||
ChatOptions = new()
|
||||
{
|
||||
Tools = [
|
||||
AIFunctionFactory.Create(menuTools.GetMenu),
|
||||
AIFunctionFactory.Create(menuTools.GetSpecials),
|
||||
AIFunctionFactory.Create(menuTools.GetItemPrice)
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
var menuTools = new MenuTools();
|
||||
var chatOptions = new ChatOptions
|
||||
{
|
||||
Tools = [
|
||||
AIFunctionFactory.Create(menuTools.GetMenu),
|
||||
AIFunctionFactory.Create(menuTools.GetSpecials),
|
||||
AIFunctionFactory.Create(menuTools.GetItemPrice),
|
||||
],
|
||||
};
|
||||
|
||||
// Create the chat history thread to capture the agent interaction.
|
||||
var thread = agent.GetNewThread();
|
||||
|
||||
@@ -85,7 +83,7 @@ public sealed class Step02_UsingTools(ITestOutputHelper output) : AgentSample(ou
|
||||
async Task InvokeAgentAsync(string input)
|
||||
{
|
||||
this.WriteUserMessage(input);
|
||||
await foreach (var update in agent.RunStreamingAsync(input, thread, chatOptions: chatOptions))
|
||||
await foreach (var update in agent.RunStreamingAsync(input, thread))
|
||||
{
|
||||
this.WriteAgentOutput(update);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user