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

Repo sync for protected branch #222

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
648dd7c
Add python process how-to guides
moonbox3 Feb 13, 2025
2b565e2
Improve Python agent learn site samples.
moonbox3 Feb 13, 2025
f1b1b6c
Fix spurious zone-end tag
gewarren Feb 13, 2025
b5eb15b
Ingestion -> injection
gewarren Feb 13, 2025
277688d
Merge pull request #460 from gewarren/patch-3
sophialagerkranspandey Feb 13, 2025
e397edf
Merge pull request #459 from gewarren/patch-2
sophialagerkranspandey Feb 13, 2025
9cbc014
Merge pull request #458 from gewarren/sync
sophialagerkranspandey Feb 13, 2025
00900dc
Merge pull request #461 from MicrosoftDocs/main
sophialagerkranspandey Feb 13, 2025
3465088
Include links to repo code.
moonbox3 Feb 14, 2025
a2d9cd0
Remove fixed locale from link
moonbox3 Feb 14, 2025
40075fb
Fix python sample resource link
moonbox3 Feb 14, 2025
4bea51e
Use site relative links for learn site links. They don't need to be a…
moonbox3 Feb 14, 2025
d635b45
Fix media link
moonbox3 Feb 14, 2025
78ad2e7
Scope link per language
moonbox3 Feb 14, 2025
fa534a9
More cleanup
moonbox3 Feb 14, 2025
7666b33
Add prompt template config import. Remove view from link in Python co…
moonbox3 Feb 16, 2025
c03c058
Updates to callout reserved param names with Python function calling.
moonbox3 Feb 17, 2025
039d3cd
updated filters page
eavanvalkenburg Feb 17, 2025
6ddea4c
Merge pull request #457 from moonbox3/update-py-sample-code
moonbox3 Feb 17, 2025
39f9534
Python: merge Python docs updates from live to main (#464)
moonbox3 Feb 17, 2025
ae1e457
Merge branch 'main' into py-processes-how-to
moonbox3 Feb 17, 2025
84cf4bd
Add Python processes sample code.
moonbox3 Feb 17, 2025
03244ed
fixed headings
eavanvalkenburg Feb 18, 2025
4f90961
removed heading
eavanvalkenburg Feb 18, 2025
fa77efc
added notes on ordering
eavanvalkenburg Feb 18, 2025
26e2b72
try inline zone
eavanvalkenburg Feb 18, 2025
436e9cc
fix bullet
eavanvalkenburg Feb 18, 2025
9c91c54
single line zone
eavanvalkenburg Feb 18, 2025
9d59fc2
small text updates
eavanvalkenburg Feb 18, 2025
4043083
added new sample links
eavanvalkenburg Feb 19, 2025
c408c4f
fix indentation
eavanvalkenburg Feb 19, 2025
7d9f07a
polish
eavanvalkenburg Feb 19, 2025
e70f690
Merge pull request #462 from eavanvalkenburg/filters
sophialagerkranspandey Feb 19, 2025
32f9d84
Merge pull request #466 from MicrosoftDocs/main
sophialagerkranspandey Feb 19, 2025
f0d5d11
Update semantic-kernel/Frameworks/process/examples/example-cycles.md
alliscode Feb 25, 2025
57b1890
Merge pull request #465 from moonbox3/py-processes-how-to
alliscode Feb 25, 2025
b754b73
Update semantic-kernel/Frameworks/process/examples/example-cycles.md
sophialagerkranspandey Feb 25, 2025
1db60e2
Update semantic-kernel/Frameworks/process/examples/example-first-proc…
sophialagerkranspandey Feb 25, 2025
50864c0
Update semantic-kernel/Frameworks/process/examples/example-cycles.md
sophialagerkranspandey Feb 25, 2025
1ba50f2
Merge pull request #467 from MicrosoftDocs/main
sophialagerkranspandey Feb 25, 2025
a97ebdb
OpenAI not Open AI (#468)
eric-urban Feb 26, 2025
20fdca6
Fix unsupported distance functions in samples
westey-m Feb 26, 2025
d7d91a3
updated table
eavanvalkenburg Feb 17, 2025
e5bc203
adding mssing stores
eavanvalkenburg Feb 17, 2025
65270c5
updated a whole bunch
eavanvalkenburg Feb 26, 2025
ed29edc
fixes
eavanvalkenburg Feb 26, 2025
f37d616
initial version of realtime docs
eavanvalkenburg Feb 26, 2025
2891764
extra info in table
eavanvalkenburg Feb 26, 2025
02978db
added link
eavanvalkenburg Feb 26, 2025
fe3433d
Merge pull request #470 from westey-m/fix-distance-func-in-docs
sophialagerkranspandey Feb 26, 2025
558bcd7
Merge pull request #472 from MicrosoftDocs/main
sophialagerkranspandey Feb 26, 2025
26fa909
Update Agent Framework related doc and code samples. Add migration co…
moonbox3 Feb 28, 2025
24962d0
Update Agent Framework related doc and code samples. Add migration co…
moonbox3 Feb 28, 2025
8d59c5c
Update title (#474)
moonbox3 Feb 28, 2025
575b53e
Proper migration guide title
moonbox3 Feb 28, 2025
88646f4
Merge pull request #476 from MicrosoftDocs/merge-live-into-main
moonbox3 Feb 28, 2025
e96632d
Merge main to live: updating Migration Guide title (#477)
moonbox3 Feb 28, 2025
b6343d8
Merge pull request #463 from eavanvalkenburg/memory_python
sophialagerkranspandey Feb 28, 2025
bdb6118
Update semantic-kernel/concepts/vector-store-connectors/out-of-the-bo…
sophialagerkranspandey Feb 28, 2025
3f2fcdb
Update semantic-kernel/concepts/vector-store-connectors/out-of-the-bo…
sophialagerkranspandey Feb 28, 2025
76657f9
Update semantic-kernel/concepts/vector-store-connectors/out-of-the-bo…
sophialagerkranspandey Feb 28, 2025
24c208a
Update semantic-kernel/concepts/vector-store-connectors/out-of-the-bo…
sophialagerkranspandey Feb 28, 2025
91d12bb
Merge pull request #478 from MicrosoftDocs/main
sophialagerkranspandey Feb 28, 2025
4616882
extended docs
eavanvalkenburg Mar 4, 2025
7f46bae
fixed link
eavanvalkenburg Mar 4, 2025
6941538
fixed header
eavanvalkenburg Mar 4, 2025
095cf4c
Merge pull request #471 from eavanvalkenburg/realtime
sophialagerkranspandey Mar 4, 2025
8d55583
Sync fork to branch
crickman Mar 5, 2025
1e2bd83
ChatCompletion tweak
crickman Mar 5, 2025
469b32f
Assistant overview update
crickman Mar 5, 2025
dd3cb77
Update assistant "howto"
crickman Mar 5, 2025
aed7121
Update assistant retrieval with template
crickman Mar 5, 2025
f3e12a0
Merge branch 'main' into repo_sync_working_branch
crickman Mar 5, 2025
092ed5d
Merge pull request #482 from MicrosoftDocs/repo_sync_working_branch
crickman Mar 5, 2025
1d23a87
Merge branch 'main' into agent-framework-updates-shared
crickman Mar 5, 2025
fbaaf72
Update semantic-kernel/concepts/ai-services/realtime.md
sophialagerkranspandey Mar 6, 2025
fcdaeea
Merge pull request #479 from MicrosoftDocs/main
sophialagerkranspandey Mar 6, 2025
fa45498
add some agent language
eavanvalkenburg Mar 6, 2025
eb10199
Improve Python plugin docs part 1
TaoChenOSU Mar 6, 2025
79e8f9c
Updated AzureAIAgent and consistency updates
crickman Mar 6, 2025
588d7a5
Improve Python plugin docs part 2
TaoChenOSU Mar 6, 2025
6dd3777
remove empty line
TaoChenOSU Mar 6, 2025
c001471
Fix errors
crickman Mar 6, 2025
39ef038
Merge pull request #485 from MicrosoftDocs/taochen/improve-python-plu…
sophialagerkranspandey Mar 6, 2025
129c980
Update semantic-kernel/concepts/ai-services/realtime.md
sophialagerkranspandey Mar 6, 2025
6896824
Merge pull request #483 from eavanvalkenburg/realtime_p2
sophialagerkranspandey Mar 6, 2025
108f1b9
Merge pull request #486 from MicrosoftDocs/main
sophialagerkranspandey Mar 6, 2025
b3b3786
Fix link
crickman Mar 7, 2025
fc59523
Cleanup
moonbox3 Mar 7, 2025
3ec294c
update next step actions
moonbox3 Mar 7, 2025
9fd01ca
Update semantic-kernel/Frameworks/agent/agent-templates.md
crickman Mar 7, 2025
34768c3
Update semantic-kernel/Frameworks/agent/chat-completion-agent.md
crickman Mar 7, 2025
6cd0488
Update example namespaces
crickman Mar 7, 2025
21a0f24
Update semantic-kernel/Frameworks/agent/chat-completion-agent.md
crickman Mar 7, 2025
bdcd976
Merge pull request #481 from MicrosoftDocs/agent-framework-updates-sh…
sophialagerkranspandey Mar 7, 2025
b44baf6
Merge pull request #487 from MicrosoftDocs/main
sophialagerkranspandey Mar 7, 2025
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
2 changes: 2 additions & 0 deletions semantic-kernel/Frameworks/agent/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
href: chat-completion-agent.md
- name: OpenAI Assistant Agent
href: assistant-agent.md
- name: Azure AI Agent
href: azure-ai-agent.md
- name: Agent Collaboration
href: agent-chat.md
- name: Create an Agent from a Template
Expand Down
51 changes: 28 additions & 23 deletions semantic-kernel/Frameworks/agent/agent-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ ChatCompletionAgent agent =

::: zone pivot="programming-language-python"
```python
kernel = Kernel()

agent = ChatCompletionAgent(
kernel=kernel,
service=AzureChatCompletion(), # or other supported AI Services
name="StoryTeller",
instructions="Tell a story about {{$topic}} that is {{$length}} sentences long.",
arguments=KernelArguments(topic="Dog", length="2"),
Expand All @@ -100,24 +98,34 @@ Templated instructions are especially powerful when working with an [`OpenAIAssi
::: zone pivot="programming-language-csharp"
```csharp
// Retrieve an existing assistant definition by identifier
OpenAIAssistantAgent agent =
await OpenAIAssistantAgent.RetrieveAsync(
this.GetClientProvider(),
"<stored agent-identifier>",
new Kernel(),
new KernelArguments()
{
{ "topic", "Dog" },
{ "length", "3" },
});
AzureOpenAIClient client = OpenAIAssistantAgent.CreateAzureOpenAIClient(new AzureCliCredential(), new Uri("<your endpoint>"));
AssistantClient assistantClient = client.GetAssistantClient();
Assistant assistant = await client.GetAssistantAsync();
OpenAIAssistantAgent agent = new(assistant, assistantClient, new KernelPromptTemplateFactory(), PromptTemplateConfig.SemanticKernelTemplateFormat)
{
Arguments = new KernelArguments()
{
{ "topic", "Dog" },
{ "length", "3" },
}
}
```
::: zone-end

::: zone pivot="programming-language-python"
```python
agent = await OpenAIAssistantAgent.retrieve(
id=<assistant_id>,
kernel=Kernel(),
# Create the client using Azure OpenAI resources and configuration
client, model = AzureAssistantAgent.setup_resources()

# Retrieve the assistant definition from the server based on the assistant ID
definition = await client.beta.assistants.retrieve(
assistant_id="your-assistant-id",
)

# Create the AzureAssistantAgent instance using the client and the assistant definition
agent = AzureAssistantAgent(
client=client,
definition=definition,
arguments=KernelArguments(topic="Dog", length="3"),
)
```
Expand All @@ -130,10 +138,9 @@ agent = await OpenAIAssistantAgent.retrieve(
::: zone-end


## Agent Definition from a _Prompt Template_

The same _Prompt Template Config_ used to create a _Kernel Prompt Function_ can also be leveraged to define an agent. This allows for a unified approach in managing both prompts and agents, promoting consistency and reuse across different components. By externalizing agent definitions from the codebase, this method simplifies the management of multiple agents, making them easier to update and maintain without requiring changes to the underlying logic. This separation also enhances flexibility, enabling developers to modify agent behavior or introduce new agents by simply updating the configuration, rather than adjusting the code itself.
## Agent Definition from a Prompt Template

The same Prompt Template Config used to create a Kernel Prompt Function can also be leveraged to define an agent. This allows for a unified approach in managing both prompts and agents, promoting consistency and reuse across different components. By externalizing agent definitions from the codebase, this method simplifies the management of multiple agents, making them easier to update and maintain without requiring changes to the underlying logic. This separation also enhances flexibility, enabling developers to modify agent behavior or introduce new agents by simply updating the configuration, rather than adjusting the code itself.
#### YAML Template

```yaml
Expand Down Expand Up @@ -192,7 +199,7 @@ data = yaml.safe_load(generate_story_yaml)
prompt_template_config = PromptTemplateConfig(**data)

agent = ChatCompletionAgent(
kernel=_create_kernel_with_chat_completion(),
service=AzureChatCompletion(), # or other supported AI services
prompt_template_config=prompt_template_config,
arguments=KernelArguments(topic="Dog", length="3"),
)
Expand Down Expand Up @@ -249,10 +256,8 @@ await foreach (ChatMessageContent response in agent.InvokeAsync(chat, overrideAr
::: zone pivot="programming-language-python"

```python
kernel = Kernel()

agent = ChatCompletionAgent(
kernel=kernel,
service=AzureChatCompletion(),
name="StoryTeller",
instructions="Tell a story about {{$topic}} that is {{$length}} sentences long.",
arguments=KernelArguments(topic="Dog", length="2"),
Expand Down
78 changes: 53 additions & 25 deletions semantic-kernel/Frameworks/agent/assistant-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ms.author: crickman
ms.date: 09/13/2024
ms.service: semantic-kernel
---
# Exploring the _Semantic Kernel_ `OpenAIAssistantAgent`
# Exploring the Semantic Kernel `OpenAIAssistantAgent`

> [!IMPORTANT]
> This feature is in the release candidate stage. Features at this stage are nearly complete and generally stable, though they may undergo minor refinements or optimizations before reaching full general availability.
Expand All @@ -17,8 +17,6 @@ Detailed API documentation related to this discussion is available at:

::: zone pivot="programming-language-csharp"
- [`OpenAIAssistantAgent`](/dotnet/api/microsoft.semantickernel.agents.openai.openaiassistantagent)
- [`OpenAIAssistantDefinition`](/dotnet/api/microsoft.semantickernel.agents.openai.openaiassistantdefinition)
- [`OpenAIClientProvider`](/dotnet/api/microsoft.semantickernel.agents.openai.openaiclientprovider)

::: zone-end

Expand All @@ -45,21 +43,55 @@ The _OpenAI Assistant API_ is a specialized interface designed for more advanced
- [Assistant API in Azure](/azure/ai-services/openai/assistants-quickstart)


## Preparing Your Development Environment

To proceed with developing an `OpenAIAIAssistantAgent`, configure your development environment with the appropriate packages.

::: zone pivot="programming-language-csharp"

Add the `Microsoft.SemanticKernel.Agents.OpenAI` package to your project:

```pwsh
dotnet add package Microsoft.SemanticKernel.Agents.AzureAI --prerelease
```

You may also want to include the `Azure.Identity` package:

```pwsh
dotnet add package Azure.Identity
```
::: zone-end

::: zone pivot="programming-language-python"

Install the `semantic-kernel` package with the optional _Azure_ dependencies:

```bash
pip install semantic-kernel[azure]
```

::: zone-end

::: zone pivot="programming-language-java"

> Agents are currently unavailable in Java.

::: zone-end


## Creating an `OpenAIAssistantAgent`

Creating an `OpenAIAssistant` requires invoking a remote service, which is handled asynchronously. To manage this, the `OpenAIAssistantAgent` is instantiated through a static factory method, ensuring the process occurs in a non-blocking manner. This method abstracts the complexity of the asynchronous call, returning a promise or future once the assistant is fully initialized and ready for use.

::: zone pivot="programming-language-csharp"
```csharp
OpenAIAssistantAgent agent =
await OpenAIAssistantAgent.CreateAsync(
OpenAIClientProvider.ForAzureOpenAI(/*<...service configuration>*/),
new OpenAIAssistantDefinition("<model name>")
{
Name = "<agent name>",
Instructions = "<agent instructions>",
},
new Kernel());
AssistantClient client = OpenAIAssistantAgent.CreateAzureOpenAIClient(...).GetAssistantClient();
Assistant assistant =
await this.AssistantClient.CreateAssistantAsync(
"<model name>",
"<agent name>",
instructions: "<agent instructions>");
OpenAIAssistantAgent agent = new(assistant, client);
```
::: zone-end

Expand Down Expand Up @@ -119,11 +151,9 @@ Once created, the identifier of the assistant may be access via its identifier.
For .NET, the agent identifier is exposed as a `string` via the property defined by any agent.

```csharp
OpenAIAssistantAgent agent =
await OpenAIAssistantAgent.RetrieveAsync(
OpenAIClientProvider.ForAzureOpenAI(/*<...service configuration>*/),
"<your agent id>",
new Kernel());
AssistantClient client = OpenAIAssistantAgent.CreateAzureOpenAIClient(...).GetAssistantClient();
Assistant assistant = await this.AssistantClient.GetAssistantAsync("<assistant id>");
OpenAIAssistantAgent agent = new(assistant, client);
```
::: zone-end

Expand Down Expand Up @@ -220,20 +250,18 @@ await agent.delete_thread(thread_id)

## Deleting an `OpenAIAssistantAgent`

Since the assistant's definition is stored remotely, it supports the capability to self-delete. This enables the agent to be removed from the system when it is no longer needed.
Since the assistant's definition is stored remotely, it will persist if not deleted.
Deleting an assistant definition may be performed directly with the `AssistantClient`.

> Note: Attempting to use an agent instance after being deleted results in an exception.
> Note: Attempting to use an agent instance after being deleted will result in a service exception.

::: zone pivot="programming-language-csharp"

For .NET, the agent identifier is exposed as a `string` via the [`Agent.Id`](/dotnet/api/microsoft.semantickernel.agents.agent.id) property defined by any agent.

```csharp
// Perform the deletion
await agent.DeleteAsync();

// Inspect whether an agent has been deleted
bool isDeleted = agent.IsDeleted();
AssistantClient client = OpenAIAssistantAgent.CreateAzureOpenAIClient(...).GetAssistantClient();
Assistant assistant = await this.AssistantClient.DeleteAssistantAsync("<assistant id>");
```
::: zone-end

Expand Down Expand Up @@ -261,5 +289,5 @@ For an end-to-end example for a `OpenAIAssistantAgent`, see:


> [!div class="nextstepaction"]
> [Agent Collaboration in `AgentChat`](./agent-chat.md)
> [Exploring the Azure AI Agent](./azure-ai-agent.md)

Loading