forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAgentDefinitionYamlTests.cs
116 lines (108 loc) · 3.58 KB
/
AgentDefinitionYamlTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.SemanticKernel.Agents;
using Xunit;
namespace SemanticKernel.Agents.UnitTests.Yaml;
/// <summary>
/// Unit tests for <see cref="AgentDefinitionYaml"/>.
/// </summary>
public class AgentDefinitionYamlTests
{
/// <summary>
/// Verify can create an instance of <see cref="AgentDefinition"/> from YAML text.
/// </summary>
[Fact]
public void VerifyAgentDefinitionFromYaml()
{
// Arrange
var text =
"""
version: 1.0.0
type: chat_completion_agent
name: My Agent
description: Description of My Agent
instructions: Instructions for how My Agent works
metadata:
authors:
- Bob
- Ted
- Alice
tags:
- red
- green
- blue
created: 2025-02-21
model:
id: gpt-4o-mini
options:
temperature: 0.4
function_choice_behavior:
type: auto
configuration:
type: azureai
inputs:
input1:
description: input1 description
required: true
default: input1 default
sample: input1 sample
input2:
description: input2 description
required: false
default: input2 default
sample: input2 sample
outputs:
- description: output1 description
template:
format: liquid
parser: semantic-kernel
tools:
- name: tool1
type: code_interpreter
- name: tool2
type: file_search
""";
// Act
var agentDefinition = AgentDefinitionYaml.FromYaml(text);
// Assert
Assert.NotNull(agentDefinition);
}
/// <summary>
/// Verify can create an instance of <see cref="AgentDefinition"/> from YAML text.
/// </summary>
[Fact]
public void VerifyAgentDefinitionMetadataPropertiesFromYaml()
{
// Arrange
var text =
"""
version: 1.0.0
type: chat_completion_agent
name: My Agent
description: Description of My Agent
instructions: Instructions for how My Agent works
metadata:
authors:
- Bob
- Ted
- Alice
tags:
- red
- green
- blue
created: 2025-02-21
""";
// Act
var agentDefinition = AgentDefinitionYaml.FromYaml(text);
// Assert
Assert.NotNull(agentDefinition);
Assert.Equal("1.0.0", agentDefinition.Version);
Assert.Equal("chat_completion_agent", agentDefinition.Type);
Assert.Equal("My Agent", agentDefinition.Name);
Assert.Equal("Description of My Agent", agentDefinition.Description);
Assert.Equal("Instructions for how My Agent works", agentDefinition.Instructions);
Assert.NotNull(agentDefinition.Metadata);
Assert.Equal(3, agentDefinition.Metadata.Authors?.Count);
Assert.Equal(3, agentDefinition.Metadata.Tags?.Count);
Assert.Equal("2025-02-21", agentDefinition.Metadata.ExtensionData["created"]);
}
}