Skip to content
Open
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
13 changes: 7 additions & 6 deletions 04-tool-use/code_samples/04-dotnet-agent-framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Always mention which tools you used so users understand the agent's capabilities
AIAgent agent = openAIClient
.GetChatClient(github_model_id)
.AsIChatClient()
.CreateAIAgent(
.AsAIAgent(
name: AGENT_NAME,
instructions: AGENT_INSTRUCTIONS,
tools: [
Expand All @@ -235,8 +235,9 @@ Always mention which tools you used so users understand the agent's capabilities
]
);

// Create Conversation Thread
AgentThread thread = agent.GetNewThread();
// Create Conversation Session
AgentSession session = await agent.CreateSessionAsync();


// ============================================================================
// DEMONSTRATION 1: Tool Selection - Agent picks the right tool
Expand All @@ -246,7 +247,7 @@ Always mention which tools you used so users understand the agent's capabilities
Console.WriteLine("User: What's the weather like in Tokyo?\n");
Console.WriteLine("Agent Response:");

await foreach (var update in agent.RunStreamingAsync("What's the weather like in Tokyo?", thread))
await foreach (var update in agent.RunStreamingAsync("What's the weather like in Tokyo?", session))
{
await Task.Delay(10);
Console.Write(update);
Expand All @@ -261,7 +262,7 @@ Always mention which tools you used so users understand the agent's capabilities
Console.WriteLine("User: How much would a 5-day luxury trip to Rome cost?\n");
Console.WriteLine("Agent Response:");

await foreach (var update in agent.RunStreamingAsync("How much would a 5-day luxury trip to Rome cost?", thread))
await foreach (var update in agent.RunStreamingAsync("How much would a 5-day luxury trip to Rome cost?", session))
{
await Task.Delay(10);
Console.Write(update);
Expand All @@ -278,7 +279,7 @@ Always mention which tools you used so users understand the agent's capabilities

await foreach (var update in agent.RunStreamingAsync(
"Plan me a complete trip - suggest a destination and give me all the details including weather and costs for a 3-day moderate budget trip.",
thread))
session))
{
await Task.Delay(10);
Console.Write(update);
Expand Down
Loading