Skip to content

Commit 6ae09b8

Browse files
Remove title and description keywords from root-level schemas in AIFunctionFactory. (#6465)
1 parent b53b505 commit 6ae09b8

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ private ReflectionAIFunctionDescriptor(DescriptorKey key, JsonSerializerOptions
692692
JsonSerializerOptions = serializerOptions;
693693
JsonSchema = AIJsonUtilities.CreateFunctionJsonSchema(
694694
key.Method,
695-
Name,
696-
Description,
697-
serializerOptions,
698-
schemaOptions);
695+
title: string.Empty, // Forces skipping of the title keyword
696+
description: string.Empty, // Forces skipping of the description keyword
697+
serializerOptions: serializerOptions,
698+
inferenceOptions: schemaOptions);
699699
}
700700

701701
public string Name { get; }

test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public static void CreateFunctionJsonSchema_ReturnsExpectedValue()
304304

305305
Assert.NotNull(func.UnderlyingMethod);
306306

307-
JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: func.Name);
307+
JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty);
308308
AssertDeepEquals(resolvedSchema, func.JsonSchema);
309309
}
310310

@@ -333,8 +333,6 @@ public static void CreateFunctionJsonSchema_OptionalParameters(bool requireAllPr
333333

334334
JsonElement expected = JsonDocument.Parse($$"""
335335
{
336-
"title": "get_weather",
337-
"description": "Gets the current weather for a current location",
338336
"type": "object",
339337
"properties": {
340338
"city": {
@@ -369,11 +367,7 @@ public static void CreateFunctionJsonSchema_OptionalParameters(bool requireAllPr
369367
Assert.NotNull(func.UnderlyingMethod);
370368
AssertDeepEquals(expected, func.JsonSchema);
371369

372-
JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(
373-
func.UnderlyingMethod,
374-
title: func.Name,
375-
description: func.Description,
376-
inferenceOptions: inferenceOptions);
370+
JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty, description: string.Empty, inferenceOptions: inferenceOptions);
377371
AssertDeepEquals(expected, resolvedSchema);
378372
}
379373

0 commit comments

Comments
 (0)