Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trimming/NativeAOT support #20

Open
HavenDV opened this issue Jun 7, 2024 · 1 comment · May be fixed by #21
Open

Trimming/NativeAOT support #20

HavenDV opened this issue Jun 7, 2024 · 1 comment · May be fixed by #21
Labels
enhancement New feature or request

Comments

@HavenDV
Copy link
Contributor

HavenDV commented Jun 7, 2024

According this article: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0

Now there are such warnings:

1>InternalListHelpers.cs(34,9): Warning IL2091 Trim analysis: OpenAI.InternalListHelpers.GetPageFromProtocol<TInstance,UInternalList>(ClientResult): 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in 'System.ClientModel.Primitives.ModelReaderWriter.Read<T>(BinaryData, ModelReaderWriterOptions)'. The generic parameter 'UInternalList' of 'OpenAI.InternalListHelpers.GetPageFromProtocol<TInstance,UInternalList>(ClientResult)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
1>System.Memory.Data.dll: Warning IL2104 : Assembly 'System.Memory.Data' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries

If I use the preview version of System.Memory.Data, the following warnings appear here

1>ModerationClient.cs(77,9): Warning IL2026 Trim analysis: OpenAI.Moderations.ModerationClient.<ClassifyTextInputAsync>d__4.MoveNext(): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>ModerationClient.cs(110,9): Warning IL2026 Trim analysis: OpenAI.Moderations.ModerationClient.<ClassifyTextInputsAsync>d__6.MoveNext(): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(84,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.<GenerateEmbeddingAsync>d__4.MoveNext(): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(120,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.<GenerateEmbeddingsAsync>d__6.MoveNext(): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(157,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.<GenerateEmbeddingsAsync>d__8.MoveNext(): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(102,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.GenerateEmbedding(String, EmbeddingGenerationOptions): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(139,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.GenerateEmbeddings(IEnumerable<String>, EmbeddingGenerationOptions): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>EmbeddingClient.cs(175,9): Warning IL2026 Trim analysis: OpenAI.Embeddings.EmbeddingClient.GenerateEmbeddings(IEnumerable<IEnumerable<Int32>>, EmbeddingGenerationOptions): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>ModerationClient.cs(93,9): Warning IL2026 Trim analysis: OpenAI.Moderations.ModerationClient.ClassifyTextInput(String): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>ModerationClient.cs(126,9): Warning IL2026 Trim analysis: OpenAI.Moderations.ModerationClient.ClassifyTextInputs(IEnumerable<String>): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
1>OpenAIModelFactory.cs(33,9): Warning IL2026 Trim analysis: OpenAI.OpenAIModelFactory.Embedding(ReadOnlyMemory<Single>, Int32): Using member 'System.BinaryData.FromObjectAsJson<T>(T, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed.
@HavenDV HavenDV linked a pull request Jun 7, 2024 that will close this issue
@trrwilson
Copy link
Collaborator

@HavenDV, thanks for the prompt discovery of this and even getting a comprehensive change prepared! Trimming support is a topic under investigation with the System.ClientModel team (where the result collections originate from) and we'll follow up ASAP based on that conversation.

@trrwilson trrwilson added the enhancement New feature or request label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants