Skip to content

Commit 506f6f2

Browse files
committed
updating standard and merging
2 parents dd2bbdc + bddd7e1 commit 506f6f2

140 files changed

Lines changed: 8737 additions & 1354 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*.user
1010
*.userosscache
1111
*.sln.docstates
12-
* .env
12+
*.env
1313

1414
# User-specific files (MonoDevelop/Xamarin Studio)
1515
*.userprefs
@@ -399,3 +399,4 @@ FodyWeavers.xsd
399399

400400
# JetBrains Rider
401401
*.sln.iml
402+
use-cases/infrastructure-setup/01-connections/your.deployment.parameters.json

doc-samples/agents/c#/project-sdk/README.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

doc-samples/agents/python/azure-ai-agents/.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

doc-samples/agents/python/project-client/bing_grounding.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

doc-samples/getting-started/javascript/quickstart.js

Whitespace-only changes.

doc-samples/agents/c#/azure-ai-agent-sdk/AdditionalMessage.md renamed to samples/microsoft/csharp/getting-started-agents/AdditionalMessage.md

File renamed without changes.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using Azure;
2+
using Azure.AI.Agents.Persistent;
3+
using Azure.Identity;
4+
using Microsoft.Extensions.Configuration;
5+
6+
IConfigurationRoot configuration = new ConfigurationBuilder()
7+
.SetBasePath(AppContext.BaseDirectory)
8+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
9+
.Build();
10+
11+
var projectEndpoint = configuration["ProjectEndpoint"];
12+
var modelDeploymentName = configuration["ModelDeploymentName"];
13+
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
14+
15+
PersistentAgent agent = await client.Administration.CreateAgentAsync(
16+
model: modelDeploymentName,
17+
name: "Math Tutor",
18+
instructions: "You are a personal electronics tutor. Write and run code to answer questions.",
19+
tools: [new CodeInterpreterToolDefinition()]);
20+
21+
PersistentAgentThread thread = await client.Threads.CreateThreadAsync();
22+
await client.Messages.CreateMessageAsync(
23+
thread.Id,
24+
MessageRole.User,
25+
"What is the impedance formula?");
26+
27+
ThreadRun run = await client.Runs.CreateRunAsync(
28+
threadId: thread.Id,
29+
agent.Id,
30+
additionalMessages: [
31+
new ThreadMessageOptions(
32+
role: MessageRole.Agent,
33+
content: "E=mc^2"
34+
),
35+
new ThreadMessageOptions(
36+
role: MessageRole.User,
37+
content: "What is the impedance formula?"
38+
),
39+
]
40+
);
41+
42+
do
43+
{
44+
await Task.Delay(TimeSpan.FromMilliseconds(500));
45+
run = await client.Runs.GetRunAsync(thread.Id, run.Id);
46+
}
47+
while (run.Status == RunStatus.Queued
48+
|| run.Status == RunStatus.InProgress
49+
|| run.Status == RunStatus.RequiresAction);
50+
51+
AsyncPageable<ThreadMessage> messages = client.Messages.GetMessagesAsync(
52+
thread.Id,
53+
order: ListSortOrder.Ascending);
54+
55+
await foreach (ThreadMessage threadMessage in messages)
56+
{
57+
foreach (MessageContent contentItem in threadMessage.ContentItems)
58+
{
59+
if (contentItem is MessageTextContent textItem)
60+
{
61+
Console.WriteLine($"[{threadMessage.Role}]: {textItem.Text}");
62+
}
63+
}
64+
}
65+
66+
await client.Threads.DeleteThreadAsync(threadId: thread.Id);
67+
await client.Administration.DeleteAgentAsync(agentId: agent.Id);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using Azure;
2+
using Azure.AI.Agents.Persistent;
3+
using Azure.Identity;
4+
using Microsoft.Extensions.Configuration;
5+
6+
IConfigurationRoot configuration = new ConfigurationBuilder()
7+
.SetBasePath(AppContext.BaseDirectory)
8+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
9+
.Build();
10+
11+
var projectEndpoint = configuration["ProjectEndpoint"];
12+
var modelDeploymentName = configuration["ModelDeploymentName"];
13+
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
14+
15+
PersistentAgent agent = client.Administration.CreateAgent(
16+
model: modelDeploymentName,
17+
name: "Math Tutor",
18+
instructions: "You are a personal electronics tutor. Write and run code to answer questions.",
19+
tools: [new CodeInterpreterToolDefinition()]);
20+
21+
PersistentAgentThread thread = client.Threads.CreateThread();
22+
client.Messages.CreateMessage(
23+
thread.Id,
24+
MessageRole.User,
25+
"What is the impedance formula?");
26+
27+
ThreadRun run = client.Runs.CreateRun(
28+
threadId: thread.Id,
29+
agent.Id,
30+
additionalMessages: [
31+
new ThreadMessageOptions(
32+
role: MessageRole.Agent,
33+
content: "E=mc^2"
34+
),
35+
new ThreadMessageOptions(
36+
role: MessageRole.User,
37+
content: "What is the impedance formula?"
38+
),
39+
]
40+
);
41+
42+
do
43+
{
44+
Thread.Sleep(TimeSpan.FromMilliseconds(500));
45+
run = client.Runs.GetRun(thread.Id, run.Id);
46+
}
47+
while (run.Status == RunStatus.Queued
48+
|| run.Status == RunStatus.InProgress
49+
|| run.Status == RunStatus.RequiresAction);
50+
51+
Pageable<ThreadMessage> messages = client.Messages.GetMessages(
52+
thread.Id,
53+
order: ListSortOrder.Ascending);
54+
55+
foreach (ThreadMessage threadMessage in messages)
56+
{
57+
foreach (MessageContent contentItem in threadMessage.ContentItems)
58+
{
59+
if (contentItem is MessageTextContent textItem)
60+
{
61+
Console.WriteLine($"[{threadMessage.Role}]: {textItem.Text}");
62+
}
63+
}
64+
}
65+
66+
client.Threads.DeleteThread(threadId: thread.Id);
67+
client.Administration.DeleteAgent(agentId: agent.Id);

doc-samples/agents/c#/azure-ai-agent-sdk/AzureFunctionCalling.md renamed to samples/microsoft/csharp/getting-started-agents/AzureFunctionCalling.md

File renamed without changes.

doc-samples/agents/c#/azure-ai-agent-sdk/Basics.md renamed to samples/microsoft/csharp/getting-started-agents/Basics.md

File renamed without changes.

0 commit comments

Comments
 (0)