Skip to content

Commit

Permalink
Update a few more failing assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Nov 25, 2024
1 parent bf140f2 commit 88cbfc7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public void ItCanConvertToFunctionDefinitionsWithParameterTypesAndReturnParamete
{ "type": "object",
"required": ["param1", "param2"],
"properties": {
"param1": { "type": "string", "description": "String param 1" },
"param2": { "type": "integer", "description": "Int param 2" } } }
"param1": { "description": "String param 1", "type": "string" },
"param2": { "description": "Int param 2" , "type": "integer"} } }
""";

KernelPlugin plugin = KernelPluginFactory.CreateFromFunctions("Tests", new[]
Expand Down Expand Up @@ -126,8 +126,8 @@ public void ItCanConvertToFunctionDefinitionsWithParameterTypesAndNoReturnParame
{ "type": "object",
"required": ["param1", "param2"],
"properties": {
"param1": { "type": "string", "description": "String param 1" },
"param2": { "type": "integer", "description": "Int param 2" } } }
"param1": { "description": "String param 1", "type": "string" },
"param2": { "description": "Int param 2", "type": "integer"} } }
""";

KernelPlugin plugin = KernelPluginFactory.CreateFromFunctions("Tests", new[]
Expand Down Expand Up @@ -180,7 +180,7 @@ public void ItCanConvertToFunctionDefinitionsWithNoParameterTypesButWithDescript

// Assert
Assert.Equal(
"""{"type":"object","required":[],"properties":{"param1":{"type":"string","description":"something neat"}}}""",
"""{"type":"object","required":[],"properties":{"param1":{"description":"something neat","type":"string"}}}""",
JsonSerializer.Serialize(result.Parameters));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void ItCanCreateValidGeminiFunctionManualForPlugin()
// Assert
Assert.NotNull(result);
Assert.Equal(
"""{"type":"object","required":["parameter1","parameter2","parameter3"],"properties":{"parameter1":{"type":"string","description":"String parameter"},"parameter2":{"type":"string","enum":["Value1","Value2"],"description":"Enum parameter"},"parameter3":{"type":"string","format":"date-time","description":"DateTime parameter"}}}""",
"""{"type":"object","required":["parameter1","parameter2","parameter3"],"properties":{"parameter1":{"description":"String parameter","type":"string"},"parameter2":{"description":"Enum parameter","type":"string","enum":["Value1","Value2"]},"parameter3":{"description":"DateTime parameter","type":"string"}}}""",
JsonSerializer.Serialize(result.Parameters)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void ItCanConvertToFunctionDefinitionWithPluginName()
[Fact]
public void ItCanConvertToFunctionDefinitionsWithParameterTypesAndReturnParameterType()
{
string expectedParameterSchema = """{ "type": "object", "required": ["param1", "param2"], "properties": { "param1": { "type": "string", "description": "String param 1" }, "param2": { "type": "integer", "description": "Int param 2" } } } """;
string expectedParameterSchema = """{ "type": "object", "required": ["param1", "param2"], "properties": { "param1": { "description": "String param 1", "type": "string" }, "param2": { "description": "Int param 2", "type": "integer" } } } """;

KernelPlugin plugin = KernelPluginFactory.CreateFromFunctions("Tests", new[]
{
Expand All @@ -118,7 +118,7 @@ public void ItCanConvertToFunctionDefinitionsWithParameterTypesAndReturnParamete
[Fact]
public void ItCanConvertToFunctionDefinitionsWithParameterTypesAndNoReturnParameterType()
{
string expectedParameterSchema = """{ "type": "object", "required": ["param1", "param2"], "properties": { "param1": { "type": "string", "description": "String param 1" }, "param2": { "type": "integer", "description": "Int param 2" } } } """;
string expectedParameterSchema = """{ "type": "object", "required": ["param1", "param2"], "properties": { "param1": { "description": "String param 1", "type": "string" }, "param2": { "description": "Int param 2", "type": "integer" } } } """;

KernelPlugin plugin = KernelPluginFactory.CreateFromFunctions("Tests", new[]
{
Expand Down Expand Up @@ -174,7 +174,7 @@ public void ItCanConvertToFunctionDefinitionsWithNoParameterTypesButWithDescript
Assert.NotNull(pd.properties);
Assert.Single(pd.properties);
Assert.Equal(
JsonSerializer.Serialize(KernelJsonSchema.Parse("""{ "type":"string", "description":"something neat" }""")),
JsonSerializer.Serialize(KernelJsonSchema.Parse("""{ "description":"something neat", "type":"string" }""")),
JsonSerializer.Serialize(pd.properties.First().Value.RootElement));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void ItCanCreateValidAzureOpenAIFunctionManualForPlugin()
// Assert
Assert.NotNull(result);
Assert.Equal(
"""{"type":"object","required":["parameter1","parameter2","parameter3"],"properties":{"parameter1":{"type":"string","description":"String parameter"},"parameter2":{"type":"string","enum":["Value1","Value2"],"description":"Enum parameter"},"parameter3":{"type":"string","format":"date-time","description":"DateTime parameter"}}}""",
"""{"type":"object","required":["parameter1","parameter2","parameter3"],"properties":{"parameter1":{"description":"String parameter","type":"string"},"parameter2":{"description":"Enum parameter","type":"string","enum":["Value1","Value2"]},"parameter3":{"description":"DateTime parameter","type":"string"}}}""",
result.FunctionParameters.ToString()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void ItCanCreateFromType(JsonSerializerOptions? jsos)

Assert.NotEmpty(metadata1.Parameters);
Assert.NotNull(metadata1.Parameters[0].Schema);
Assert.Equal("""{"type":"string","description":"Description for parameter 1"}""", metadata1.Parameters[0].Schema!.ToString());
Assert.Equal("""{"description":"Description for parameter 1","type":"string"}""", metadata1.Parameters[0].Schema!.ToString());

Assert.NotNull(metadata1.ReturnParameter);
Assert.NotNull(metadata1.ReturnParameter.Schema);
Expand All @@ -50,7 +50,7 @@ public void ItCanCreateFromType(JsonSerializerOptions? jsos)

Assert.NotEmpty(metadata2.Parameters);
Assert.NotNull(metadata2.Parameters[0].Schema);
Assert.Equal("""{"type":"object","properties":{"Value":{"type":["string","null"]}},"description":"Description for parameter 1"}""", metadata2.Parameters[0].Schema!.ToString());
Assert.Equal("""{"description":"Description for parameter 1","type":"object","properties":{"Value":{"type":["string","null"]}}}""", metadata2.Parameters[0].Schema!.ToString());

Assert.NotNull(metadata2.ReturnParameter);
Assert.NotNull(metadata2.ReturnParameter.Schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static async Task AssertPluginAndFunctionsAsync(Kernel kernel, KernelPlu

Assert.NotEmpty(function1.Metadata.Parameters);
Assert.NotNull(function1.Metadata.Parameters[0].Schema);
Assert.Equal("""{"type":"string","description":"Description for parameter 1"}""", function1.Metadata.Parameters[0].Schema!.ToString());
Assert.Equal("""{"description":"Description for parameter 1","type":"string"}""", function1.Metadata.Parameters[0].Schema!.ToString());

Assert.NotNull(function1.Metadata.ReturnParameter);
Assert.NotNull(function1.Metadata.ReturnParameter.Schema);
Expand All @@ -86,7 +86,7 @@ private static async Task AssertPluginAndFunctionsAsync(Kernel kernel, KernelPlu

Assert.NotEmpty(function2.Metadata.Parameters);
Assert.NotNull(function2.Metadata.Parameters[0].Schema);
Assert.Equal("""{"type":"object","properties":{"Value":{"type":["string","null"]}},"description":"Description for parameter 1"}""", function2.Metadata.Parameters[0].Schema!.ToString());
Assert.Equal("""{"description":"Description for parameter 1","type":"object","properties":{"Value":{"type":["string","null"]}}}""", function2.Metadata.Parameters[0].Schema!.ToString());

Assert.NotNull(function2.Metadata.ReturnParameter);
Assert.NotNull(function2.Metadata.ReturnParameter.Schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ public async Task ItCanProduceAIFunctionsThatInvokeKernelFunctions(bool withKern
Assert.NotNull(funcs[1].Metadata.Parameters[0].Schema);
Assert.NotNull(funcs[1].Metadata.Parameters[1].Schema);

Assert.Equal(plugin["Function1"].Metadata.Parameters[0].Schema?.ToString(), funcs[0].Metadata.Parameters[0].Schema?.ToString());
Assert.Equal(plugin["Function2"].Metadata.Parameters[0].Schema?.ToString(), funcs[1].Metadata.Parameters[0].Schema?.ToString());
Assert.Equal(plugin["Function2"].Metadata.Parameters[1].Schema?.ToString(), funcs[1].Metadata.Parameters[1].Schema?.ToString());
Assert.Equal(plugin["Function1"].Metadata.Parameters[0].Schema?.ToString(), JsonSerializer.Serialize(funcs[0].Metadata.Parameters[0].Schema));
Assert.Equal(plugin["Function2"].Metadata.Parameters[0].Schema?.ToString(), JsonSerializer.Serialize(funcs[1].Metadata.Parameters[0].Schema));
Assert.Equal(plugin["Function2"].Metadata.Parameters[1].Schema?.ToString(), JsonSerializer.Serialize(funcs[1].Metadata.Parameters[1].Schema));

using CancellationTokenSource cts = new();

Expand Down

0 comments on commit 88cbfc7

Please sign in to comment.