mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-12 04:15:18 -05:00
* Update FunctionCallTemplate.tt
changed the desscription assigning to handle double quotes in comments and prevent the generated code from breaking.
* Added the necessary changes
Fixed handling of double quotes in descriptions within FunctionCallTemplate.tt.
Standardized newline characters to ensure consistency.
Updated test cases in FunctionCallTemplateEncodingTests to verify correct encoding of double quotes in descriptions.
Cleaned up unnecessary using directives in FunctionCallTemplateEncodingTests.
Aligned the template with the approved test output.
* test cases passing
Test cases passing like `Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 9, Skipped: 0, Total: 9, Duration: 66 ms - AutoGen.SourceGenerator.Tests.dll (net8.0)`
* Delete FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt
Deleted the ApprovalTests/FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt successfully!
* Revert "Delete FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt"
This reverts commit 7a6ea9cf0d.
---------
Co-authored-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
72 lines
2.2 KiB
Plaintext
72 lines
2.2 KiB
Plaintext
//----------------------
|
|
// <auto-generated>
|
|
// This code was generated by a tool.
|
|
// </auto-generated>
|
|
//----------------------
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading.Tasks;
|
|
using System;
|
|
using AutoGen.Core;
|
|
using AutoGen.OpenAI.Extension;
|
|
|
|
namespace AutoGen.SourceGenerator.Tests
|
|
{
|
|
public partial class FunctionExamples
|
|
{
|
|
|
|
private class AddAsyncSchema
|
|
{
|
|
[JsonPropertyName(@"a")]
|
|
public System.Int32 a {get; set;}
|
|
[JsonPropertyName(@"b")]
|
|
public System.Int32 b {get; set;}
|
|
}
|
|
|
|
public System.Threading.Tasks.Task`1[System.String] AddAsyncWrapper(string arguments)
|
|
{
|
|
var schema = JsonSerializer.Deserialize<AddAsyncSchema>(
|
|
arguments,
|
|
new JsonSerializerOptions
|
|
{
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
|
});
|
|
|
|
return AddAsync(schema.a, schema.b);
|
|
}
|
|
|
|
public FunctionContract AddAsyncFunctionContract
|
|
{
|
|
get => new FunctionContract
|
|
{
|
|
Name = @"AddAsync",
|
|
Description = @"Add two numbers.",
|
|
ReturnType = typeof(System.Threading.Tasks.Task`1[System.String]),
|
|
Parameters = new global::AutoGen.Core.FunctionParameterContract[]
|
|
{
|
|
new FunctionParameterContract
|
|
{
|
|
Name = @"a",
|
|
Description = @"The first number.",
|
|
ParameterType = typeof(System.Int32),
|
|
IsRequired = true,
|
|
},
|
|
new FunctionParameterContract
|
|
{
|
|
Name = @"b",
|
|
Description = @"The second number.",
|
|
ParameterType = typeof(System.Int32),
|
|
IsRequired = true,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
public global::Azure.AI.OpenAI.FunctionDefinition AddAsyncFunction
|
|
{
|
|
get => this.AddAsyncFunctionContract.ToOpenAIFunctionDefinition();
|
|
}
|
|
}
|
|
}
|
|
|