Skip to content

Commit be355d2

Browse files
Simplify the model classes for the declarative agent definition
1 parent 03ed80f commit be355d2

File tree

5 files changed

+21
-207
lines changed

5 files changed

+21
-207
lines changed

dotnet/src/Agents/Abstractions/Definition/AgentDefinition.cs

+12-123
Original file line numberDiff line numberDiff line change
@@ -14,171 +14,60 @@ public sealed class AgentDefinition
1414
/// <summary>
1515
/// Gets or sets the version of the schema being used.
1616
/// </summary>
17-
public string? Version
18-
{
19-
get => this._version;
20-
set
21-
{
22-
Verify.NotNull(value);
23-
this._version = value;
24-
}
25-
}
17+
public string? Version { get; set; }
2618

2719
/// <summary>
2820
/// Gets or sets the id of the deployed agent.
2921
/// </summary>
30-
public string? Id
31-
{
32-
get => this._id;
33-
set
34-
{
35-
Verify.NotNull(value);
36-
this._id = value;
37-
}
38-
}
22+
public string? Id { get; set; }
3923

4024
/// <summary>
4125
/// Gets or sets the type of the agent.
4226
/// </summary>
43-
public string? Type
44-
{
45-
get => this._type;
46-
set
47-
{
48-
Verify.NotNull(value);
49-
this._type = value;
50-
}
51-
}
27+
public string? Type { get; set; }
5228

5329
/// <summary>
5430
/// Gets or sets the name of the agent.
5531
/// </summary>
56-
public string? Name
57-
{
58-
get => this._name;
59-
set
60-
{
61-
Verify.NotNull(value);
62-
this._name = value;
63-
}
64-
}
32+
public string? Name { get; set; }
6533

6634
/// <summary>
6735
/// Gets or sets the description of the agent.
6836
/// </summary>
69-
public string? Description
70-
{
71-
get => this._description;
72-
set
73-
{
74-
Verify.NotNull(value);
75-
this._description = value;
76-
}
77-
}
37+
public string? Description { get; set; }
7838

7939
/// <summary>
8040
/// Gets or sets the instructions for the agent to use.
8141
/// </summary>
82-
public string? Instructions
83-
{
84-
get => this._instructions;
85-
set
86-
{
87-
Verify.NotNull(value);
88-
this._instructions = value;
89-
}
90-
}
42+
public string? Instructions { get; set; }
9143

9244
/// <summary>
9345
/// Gets or sets the metadata associated with the agent.
9446
/// </summary>
95-
public IDictionary<string, object?>? Metadata
96-
{
97-
get => this._metadata;
98-
set
99-
{
100-
Verify.NotNull(value);
101-
this._metadata = value;
102-
}
103-
}
47+
public IDictionary<string, object?>? Metadata { get; set; }
10448

10549
/// <summary>
10650
/// Gets or sets the model used by the agent.
10751
/// </summary>
108-
public ModelDefinition? Model
109-
{
110-
get => this._model;
111-
set
112-
{
113-
Verify.NotNull(value);
114-
this._model = value;
115-
}
116-
}
52+
public ModelDefinition? Model { get; set; }
11753

11854
/// <summary>
11955
/// Gets or sets the collection of input variables used by the agent.
12056
/// </summary>
121-
public IList<InputVariable> Inputs
122-
{
123-
get => this._inputs ??= [];
124-
set
125-
{
126-
Verify.NotNull(value);
127-
this._inputs = value;
128-
}
129-
}
57+
public IList<InputVariable>? Inputs { get; set; }
13058

13159
/// <summary>
13260
/// Gets or sets the collection of output variables supported by the agent.
13361
/// </summary>
134-
public IList<OutputVariable> Outputs
135-
{
136-
get => this._outputs ??= [];
137-
set
138-
{
139-
Verify.NotNull(value);
140-
this._outputs = value;
141-
}
142-
}
62+
public IList<OutputVariable>? Outputs { get; set; }
14363

14464
/// <summary>
14565
/// Gets or sets the template options used by the agent.
14666
/// </summary>
147-
public TemplateOptions? Template
148-
{
149-
get => this._template;
150-
set
151-
{
152-
Verify.NotNull(value);
153-
this._template = value;
154-
}
155-
}
67+
public TemplateOptions? Template { get; set; }
15668

15769
/// <summary>
15870
/// Gets or sets the collection of tools used by the agent.
15971
/// </summary>
160-
public IList<AgentToolDefinition> Tools
161-
{
162-
get => this._tools ??= [];
163-
set
164-
{
165-
Verify.NotNull(value);
166-
this._tools = value;
167-
}
168-
}
169-
170-
#region
171-
private string? _version;
172-
private string? _type;
173-
private string? _id;
174-
private string? _name;
175-
private string? _description;
176-
private string? _instructions;
177-
private IDictionary<string, object?>? _metadata;
178-
private ModelDefinition? _model;
179-
private IList<InputVariable>? _inputs;
180-
private IList<OutputVariable>? _outputs;
181-
private TemplateOptions? _template;
182-
private IList<AgentToolDefinition>? _tools;
183-
#endregion
72+
public IList<AgentToolDefinition>? Tools { get; set; }
18473
}

dotnet/src/Agents/Abstractions/Definition/AgentToolDefinition.cs

+3-33
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,12 @@ public sealed class AgentToolDefinition
1818
/// <remarks>
1919
/// Used to identify which type of tool is being used e.g., code interpreter, openapi, ...
2020
/// </remarks>
21-
public string? Type
22-
{
23-
get => this._type;
24-
set
25-
{
26-
Verify.NotNull(value);
27-
this._type = value;
28-
}
29-
}
21+
public string? Type { get; set; }
3022

3123
/// <summary>
3224
/// The name of the tool.
3325
/// </summary>
34-
public string? Name
35-
{
36-
get => this._name;
37-
set
38-
{
39-
Verify.NotNull(value);
40-
this._name = value;
41-
}
42-
}
26+
public string? Name { get; set; }
4327

4428
/// <summary>
4529
/// Gets or sets the configuration for the tool.
@@ -48,19 +32,5 @@ public string? Name
4832
/// Used to store tool specific configuration e.g., files associated with the tool, etc.
4933
/// </remarks>
5034
[JsonExtensionData]
51-
public IDictionary<string, object?>? Configuration
52-
{
53-
get => this._configuration;
54-
set
55-
{
56-
Verify.NotNull(value);
57-
this._configuration = value;
58-
}
59-
}
60-
61-
#region private
62-
private string? _type;
63-
private string? _name;
64-
private IDictionary<string, object?>? _configuration;
65-
#endregion
35+
public IDictionary<string, object?>? Configuration { get; set; }
6636
}

dotnet/src/Agents/Abstractions/Definition/ModelConfiguration.cs

+2-20
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,12 @@ public sealed class ModelConfiguration
1919
/// Used to identify the type of deployment e.g., azure_openai, openai, ...
2020
/// This type will also be used for configuration hosting.
2121
/// </remarks>
22-
public string? Type
23-
{
24-
get => this._type;
25-
set
26-
{
27-
Verify.NotNull(value);
28-
this._type = value;
29-
}
30-
}
22+
public string? Type { get; set; }
3123

3224
/// <summary>
3325
/// Gets or sets the Service ID of the model configuration.
3426
/// </summary>
35-
public string? ServiceId
36-
{
37-
get => this._serviceId;
38-
set
39-
{
40-
Verify.NotNull(value);
41-
this._serviceId = value;
42-
}
43-
}
27+
public string? ServiceId { get; set; }
4428

4529
/// <summary>
4630
/// Extra properties that may be included in the serialized model configuration.
@@ -60,8 +44,6 @@ public string? ServiceId
6044
}
6145

6246
#region private
63-
private string? _type;
64-
private string? _serviceId;
6547
private IDictionary<string, object?>? _extensionData;
6648
#endregion
6749
}

dotnet/src/Agents/Abstractions/Definition/ModelDefinition.cs

+3-30
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ public sealed class ModelDefinition
1818
/// <summary>
1919
/// Gets or sets the ID of the model.
2020
/// </summary>
21-
public string? Id
22-
{
23-
get => this._id;
24-
set
25-
{
26-
Verify.NotNull(value);
27-
this._id = value;
28-
}
29-
}
21+
public string? Id { get; set; }
3022

3123
/// <summary>
3224
/// Gets or sets the type of API supported by the model.
@@ -44,33 +36,14 @@ public string Api
4436
/// <summary>
4537
/// Gets or sets the options used by the model.
4638
/// </summary>
47-
public PromptExecutionSettings? Options
48-
{
49-
get => this._options;
50-
set
51-
{
52-
Verify.NotNull(value);
53-
this._options = value;
54-
}
55-
}
39+
public PromptExecutionSettings? Options { get; set; }
5640

5741
/// <summary>
5842
/// Gets or sets the options used by the model.
5943
/// </summary>
60-
public ModelConfiguration? Configuration
61-
{
62-
get => this._configuration;
63-
set
64-
{
65-
Verify.NotNull(value);
66-
this._configuration = value;
67-
}
68-
}
44+
public ModelConfiguration? Configuration { get; set; }
6945

7046
#region
71-
private string? _id;
7247
private string? _api;
73-
private PromptExecutionSettings? _options;
74-
private ModelConfiguration? _configuration;
7548
#endregion
7649
}

dotnet/src/Agents/Abstractions/Extensions/AgentDefinitionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static KernelArguments GetDefaultKernelArguments(this AgentDefinition age
1818
Verify.NotNull(agentDefinition);
1919

2020
var arguments = new KernelArguments(agentDefinition?.Model?.Options);
21-
if (agentDefinition is not null)
21+
if (agentDefinition is not null && agentDefinition.Inputs is not null)
2222
{
2323
// Add default arguments for the agent
2424
foreach (var input in agentDefinition.Inputs)

0 commit comments

Comments
 (0)