forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAgentDefinitionExtensionsTests.cs
99 lines (88 loc) · 2.7 KB
/
AgentDefinitionExtensionsTests.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
// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using Microsoft.SemanticKernel.Agents;
using Xunit;
namespace SemanticKernel.Agents.UnitTests.Core.Extensions;
/// <summary>
/// Unit tests for <see cref="AgentDefinitionExtensions"/>.
/// </summary>
public class AgentDefinitionExtensionsTests
{
/// <summary>
/// Verify GetDefaultKernelArguments
/// </summary>
[Fact]
public void VerifyGetDefaultKernelArguments()
{
// Arrange
AgentDefinition agentDefinition = new()
{
Inputs = new Dictionary<string, AgentInput>
{
["Input1"] = new() { Name = "Input1", Required = false, Default = "Default1" },
["Input2"] = new() { Name = "Input2", Required = true, Default = "Default2" }
},
};
// Act
var defaultArgs = agentDefinition.GetDefaultKernelArguments();
// Assert
Assert.NotNull(defaultArgs);
Assert.Equal(2, defaultArgs.Count);
Assert.Equal("Default1", defaultArgs["Input1"]);
Assert.Equal("Default2", defaultArgs["Input2"]);
}
/// <summary>
/// Verify GetFirstToolDefinition
/// </summary>
[Fact]
public void VerifyGetFirstToolDefinition()
{
// Arrange
AgentDefinition agentDefinition = new()
{
Tools =
[
new AgentToolDefinition { Type = "code_interpreter", Name = "Tool1" },
new AgentToolDefinition { Type = "file_search", Name = "Tool2" },
],
};
// Act & Assert
Assert.NotNull(agentDefinition.GetFirstToolDefinition("code_interpreter"));
Assert.NotNull(agentDefinition.GetFirstToolDefinition("file_search"));
Assert.Null(agentDefinition.GetFirstToolDefinition("openai"));
}
/// <summary>
/// Verify HasToolType
/// </summary>
[Fact]
public void VerifyIsEnableCodeInterpreter()
{
// Arrange
AgentDefinition agentDefinition = new()
{
Tools =
[
new AgentToolDefinition { Type = "code_interpreter", Name = "Tool1" },
],
};
// Act & Assert
Assert.True(agentDefinition.HasToolType("code_interpreter"));
}
/// <summary>
/// Verify IsEnableFileSearch
/// </summary>
[Fact]
public void VerifyIsEnableFileSearch()
{
// Arrange
AgentDefinition agentDefinition = new()
{
Tools =
[
new AgentToolDefinition { Type = "file_search", Name = "Tool2" },
],
};
// Act & Assert
Assert.True(agentDefinition.HasToolType("file_search"));
}
}