Skip to content

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Nov 11, 2024

Makes the following changes:

  • Exposes additional configuration settings in the built-in schema generator making it conformant with OpenAI constraints.
  • Adds a SchemaCreateOptions property to the AIFunctionFactoryCreateOptions class for controlling schema generation in AIFunctionFactory.
  • Defaults AIFunctionFactory to using configuration that is conformant with OpenAI restrictions.

Fix #5612.

Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@stephentoub stephentoub added the area-ai Microsoft.Extensions.AI libraries label Nov 11, 2024
@eiriktsarpalis eiriktsarpalis enabled auto-merge (squash) November 11, 2024 21:25
@eiriktsarpalis eiriktsarpalis merged commit 95a80cc into dotnet:main Nov 11, 2024
6 checks passed
@eerhardt
Copy link
Member

eerhardt commented Nov 12, 2024

FYI - this introduces new trim/AOT warnings. I'm enabling the CI check in #5622.

    D:\git\extensions\src\Libraries\Microsoft.Extensions.AI.Abstractions\Utilities\AIJsonUtilities.Schema.cs(305): Trim analysis error IL2026: Microsoft.Extensions.AI.AIJsonUtilities.<>c__DisplayClass15_0.<GetJsonSchemaCore>g__TransformSchemaNode|0(JsonSchemaExporterContext,JsonNode): Using member 'System.Text.Json.Nodes.JsonArray.Add<String>(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating JsonValue instances with non-primitive types is not compatible with trimming. It can result in non-primitive types being serialized, which may have their members trimmed. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
    D:\git\extensions\src\Libraries\Microsoft.Extensions.AI.Abstractions\Utilities\AIJsonUtilities.Schema.cs(305): AOT analysis error IL3050: Microsoft.Extensions.AI.AIJsonUtilities.<>c__DisplayClass15_0.<GetJsonSchemaCore>g__TransformSchemaNode|0(JsonSchemaExporterContext,JsonNode): Using member 'System.Text.Json.Nodes.JsonArray.Add<String>(String)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Creating JsonValue instances with non-primitive types requires generating code at runtime. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]

I've opened #5626 for this.

@eiriktsarpalis eiriktsarpalis deleted the schema-conform-to-openai branch November 12, 2024 09:49
stephentoub pushed a commit to stephentoub/extensions that referenced this pull request Nov 19, 2024
…t accepted by OpenAI. (dotnet#5619)

* Expose options for making schema generation conformant with the subset accepted by OpenAI.

* Uses the same set of defaults in all layers.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Microsoft.Extensions.AI - Use structured output with function calling
3 participants