Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 5 additions & 5 deletions agent-samples/azure/AzureOpenAIAssistants.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response.
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response.
model:
id: =Env.AZURE_OPENAI_DEPLOYMENT_NAME
id: gpt-4o-mini
provider: AzureOpenAI
apiType: Assistants
options:
Expand All @@ -12,14 +12,14 @@ model:
outputSchema:
properties:
language:
kind: string
type: string
required: true
description: The language of the answer.
answer:
kind: string
type: string
required: true
description: The answer text.
type:
kind: string
type: string
required: true
description: The type of the response.
25 changes: 25 additions & 0 deletions agent-samples/azure/AzureOpenAIChat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Chat as the type in your response.
model:
id: gpt-4o-mini
provider: AzureOpenAI
apiType: Chat
options:
temperature: 0.9
topP: 0.95
outputSchema:
properties:
language:
type: string
required: true
description: The language of the answer.
answer:
type: string
required: true
description: The answer text.
type:
type: string
required: true
description: The type of the response.
17 changes: 7 additions & 10 deletions agent-samples/azure/AzureOpenAIResponses.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response.
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response.
model:
id: =Env.AZURE_OPENAI_DEPLOYMENT_NAME
id: gpt-4o-mini
provider: AzureOpenAI
apiType: Responses
options:
text:
verbosity: medium
connection:
kind: remote
endpoint: =Env.AZURE_OPENAI_ENDPOINT
temperature: 0.9
topP: 0.95
outputSchema:
properties:
language:
kind: string
type: string
required: true
description: The language of the answer.
answer:
kind: string
type: string
required: true
description: The answer text.
type:
kind: string
type: string
required: true
description: The type of the response.
6 changes: 3 additions & 3 deletions agent-samples/chatclient/Assistant.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format.
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format.
model:
options:
temperature: 0.9
topP: 0.95
outputSchema:
properties:
language:
kind: string
type: string
required: true
description: The language of the answer.
answer:
kind: string
type: string
required: true
description: The answer text.
2 changes: 2 additions & 0 deletions agent-samples/chatclient/GetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: Helpful assistant
instructions: You are a helpful assistant. You answer questions using the tools provided.
model:
options:
temperature: 0.9
topP: 0.95
allowMultipleToolCalls: true
chatToolMode: auto
tools:
Expand Down
22 changes: 22 additions & 0 deletions agent-samples/foundry/FoundryAgent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format.
model:
id: gpt-4.1-mini
options:
temperature: 0.9
topP: 0.95
connection:
kind: Remote
endpoint: =Env.AZURE_FOUNDRY_PROJECT_ENDPOINT
outputSchema:
properties:
language:
type: string
required: true
description: The language of the answer.
answer:
type: string
required: true
description: The answer text.
14 changes: 6 additions & 8 deletions agent-samples/openai/OpenAIAssistants.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response.
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response.
model:
id: =Env.OPENAI_MODEL
id: gpt-4.1-mini
provider: OpenAI
apiType: Assistants
options:
temperature: 0.9
topP: 0.95
connection:
kind: key
kind: ApiKey
key: =Env.OPENAI_APIKEY
outputSchema:
name: AssistantResponse
description: The response from the assistant.
properties:
language:
kind: string
type: string
required: true
description: The language of the answer.
answer:
kind: string
type: string
required: true
description: The answer text.
type:
kind: string
type: string
required: true
description: The type of the response.
28 changes: 28 additions & 0 deletions agent-samples/openai/OpenAIChat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Chat as the type in your response.
model:
id: gpt-4.1-mini
provider: OpenAI
apiType: Chat
options:
temperature: 0.9
topP: 0.95
connection:
kind: ApiKey
key: =Env.OPENAI_APIKEY
outputSchema:
properties:
language:
type: string
required: true
description: The language of the answer.
answer:
type: string
required: true
description: The answer text.
type:
type: string
required: true
description: The type of the response.
16 changes: 8 additions & 8 deletions agent-samples/openai/OpenAIResponses.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
kind: Prompt
name: Assistant
description: Helpful assistant
instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response.
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response.
model:
id: =Env.OPENAI_MODEL
id: gpt-4.1-mini
provider: OpenAI
apiType: Responses
options:
text:
verbosity: medium
temperature: 0.9
topP: 0.95
connection:
kind: key
kind: ApiKey
key: =Env.OPENAI_APIKEY
outputSchema:
properties:
language:
kind: string
type: string
required: true
description: The language of the answer.
answer:
kind: string
type: string
required: true
description: The answer text.
type:
kind: string
type: string
required: true
description: The type of the response.
1 change: 1 addition & 0 deletions dotnet/agent-framework-dotnet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
<Project Path="src/Microsoft.Agents.AI.AzureAI.Persistent/Microsoft.Agents.AI.AzureAI.Persistent.csproj" />
<Project Path="src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj" />
<Project Path="src/Microsoft.Agents.AI.CopilotStudio/Microsoft.Agents.AI.CopilotStudio.csproj" />
<Project Path="src/Microsoft.Agents.AI.Declarative/Microsoft.Agents.AI.Declarative.csproj" />
<Project Path="src/Microsoft.Agents.AI.DevUI/Microsoft.Agents.AI.DevUI.csproj" />
<Project Path="src/Microsoft.Agents.AI.DurableTask/Microsoft.Agents.AI.DurableTask.csproj" />
<Project Path="src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/Microsoft.Agents.AI.Hosting.A2A.AspNetCore.csproj" />
Expand Down
91 changes: 91 additions & 0 deletions dotnet/src/Microsoft.Agents.AI.Declarative/AgentBotElementYaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.Bot.ObjectModel;
using Microsoft.Bot.ObjectModel.Abstractions;
using Microsoft.Bot.ObjectModel.Yaml;
using Microsoft.Extensions.Configuration;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Agents.AI;

/// <summary>
/// Helper methods for creating <see cref="BotElement"/> from YAML.
/// </summary>
internal static class AgentBotElementYaml
{
/// <summary>
/// Convert the given YAML text to a <see cref="GptComponentMetadata"/> model.
/// </summary>
/// <param name="text">YAML representation of the <see cref="BotElement"/> to use to create the prompt function.</param>
/// <param name="configuration">Optional <see cref="IConfiguration"/> instance which provides environment variables to the template.</param>
[RequiresDynamicCode("Calls YamlDotNet.Serialization.DeserializerBuilder.DeserializerBuilder()")]
public static GptComponentMetadata FromYaml(string text, IConfiguration? configuration = null)
{
Throw.IfNullOrEmpty(text);

using var yamlReader = new StringReader(text);
BotElement rootElement = YamlSerializer.Deserialize<BotElement>(yamlReader) ?? throw new InvalidDataException("Text does not contain a valid agent definition.");

if (rootElement is not GptComponentMetadata promptAgent)
{
throw new InvalidDataException($"Unsupported root element: {rootElement.GetType().Name}. Expected an {nameof(GptComponentMetadata)}.");
}

var botDefinition = WrapPromptAgentWithBot(promptAgent, configuration);

return botDefinition.Descendants().OfType<GptComponentMetadata>().First();
}

#region private
private sealed class AgentFeatureConfiguration : IFeatureConfiguration
{
public long GetInt64Value(string settingName, long defaultValue) => defaultValue;

public string GetStringValue(string settingName, string defaultValue) => defaultValue;

public bool IsEnvironmentFeatureEnabled(string featureName, bool defaultValue) => true;

public bool IsTenantFeatureEnabled(string featureName, bool defaultValue) => defaultValue;
}

public static BotDefinition WrapPromptAgentWithBot(this GptComponentMetadata element, IConfiguration? configuration = null)
{
var botBuilder =
new BotDefinition.Builder
{
Components =
{
new GptComponent.Builder
{
SchemaName = "default-schema",
Metadata = element.ToBuilder(),
}
}
};

if (configuration is not null)
{
foreach (var kvp in configuration.AsEnumerable().Where(kvp => kvp.Value is not null))
{
botBuilder.EnvironmentVariables.Add(new EnvironmentVariableDefinition.Builder()
{
SchemaName = kvp.Key,
Id = Guid.NewGuid(),
DisplayName = kvp.Key,
ValueComponent = new EnvironmentVariableValue.Builder()
{
Id = Guid.NewGuid(),
Value = kvp.Value!,
},
});
}
}

return botBuilder.Build();
}
#endregion
}
Loading
Loading