Граф коммитов

1410 Коммитов

Автор SHA1 Сообщение Дата
Eirik Tsarpalis f846de668b
Expose a schema transformer on AIJsonSchemaCreateOptions. (#5677)
* Expose a schema transformer on AIJsonSchemaCreateOptions.

* Address feedback

* Disable caching if a transformer is specified.

* Remove `FilterDisallowedKeywords`.

* Document caching.

* Apply suggestions from code review
2024-11-20 21:46:16 +00:00
Stephen Toub 042b4e6a44
Change UseLogging to accept an ILoggerFactory instead of ILogger (#5682)
Fits better with DI, and makes it consistent with UseFunctionInvocation and UseOpenTelemetry.
2024-11-20 14:57:06 -05:00
Stephen Toub 1a4a54f107
Fix a few FunctionInvocationChatClient streaming issues (#5680)
- The non-streaming path explicitly throws if the response contains multiple choices. The streaming path wasn't doing the same and was instead silently producing bad results.
- The streaming path was yielding function call content _and_ adding them to the chat history. It should only have been doing the latter.

This fixes both issues. We also had close to zero test coverage in our FunctionInvocationChatClient tests for streaming, only for non-streaming. This also fixes that.
2024-11-20 14:06:53 -05:00
Stephen Toub 7ebb34d4b5
Ensure non-streaming usage data from function calling is in history (#5676)
It's already yielded during streaming, but it's not being surfaced for non-streaming. Do so by manufacturing a new UsageContent for the UsageDetails and adding that to the response message that's added to the history.
2024-11-20 10:27:18 -05:00
Stephen Toub 476a196058
Tweak CachingHelpers.GetCacheKey to clean up better on failure (#5654) 2024-11-19 22:07:49 +00:00
Steve Sanderson f802390fbb
Add OpenAIRealtimeExtensions with ToConversationFunctionTool (#5666) 2024-11-19 16:45:31 -05:00
Eirik Tsarpalis 9cfd5ff4d5
Backport JsonSchemaExporter bugfix. (#5671)
* Backport JsonSchemaExporter bugfix.

* Address feedback.
2024-11-19 13:41:33 -05:00
Amadeusz Lechniak 9b61daa94f
Update documentation SynchronizationContext in FakeTimeProvider (#5665)
* Update documentation SynchronizationContext in FakeTimeProvider

* Fix lint error

* Update documentation
2024-11-19 14:49:07 +01:00
Stephen Toub 8b9dc1d688
Add anonymous delegating clients / generators (#5650) 2024-11-18 18:53:35 -05:00
Stephen Toub d551bb113a
Reverse order of services/inner in Use methods (#5664) 2024-11-18 16:42:37 +00:00
Stephen Toub 5982f6abc3
Reduce a bit of LINQ in M.E.AI (#5663) 2024-11-18 10:52:08 -05:00
Stephen Toub 930af05f2b
Add AsBuilder extensions for IChatClient and IEmbeddingGenerator (#5652)
* Add ToBuilder extensions for IChatClient and IEmbeddingGenerator

Enables a fluent style of construction of a pipeline from a client/generator, and not having to specify the generic type parameters for the embedding generator builder.

* Rename ToBuilder to AsBuilder
2024-11-18 10:12:30 -05:00
dotnet-maestro[bot] c4689473f5
Update dependencies from https://github.com/dotnet/arcade build 20241112.13 (#5662)
[main] Update dependencies from dotnet/arcade
2024-11-18 14:45:48 +00:00
Stephen Toub b29e149b85
Augment XML comments for AIFunctionFactory.Create (#5658)
* Augment XML comments for AIFunctionFactory.Create

* Add JSON serialization comments
2024-11-18 09:37:32 -05:00
Stephen Toub 06edb3cf05
Remove duplicate GetCacheKey methods (#5651)
* Remove duplicate GetCacheKey methods

Consolidate to only the `ReadOnlySpan<object>`-based method.

* Update XML comments to say that the values are serialized
2024-11-18 09:20:47 -05:00
Stephen Toub f085689eb2
Fix M.E.AI argument tests to validate argument names (#5653) 2024-11-18 07:48:19 -05:00
Stephen Toub e0f354a386
Annotate private DebuggerDisplay props as DebuggerBrowsableState.Never (#5656)
It's just noise.
2024-11-18 07:44:27 -05:00
Stephen Toub 475f317bc5
Add a [DebuggerDisplay] to GeneratedEmbeddings (#5657) 2024-11-18 07:44:10 -05:00
Nathanael Marchand 2977765f23
Make ActivityBaggageLogScopeWrapper implements IEnumerable<KeyValuePair<string, object?>> (#5589)
Make ActivityBaggageLogScopeWrapper implement IEnumerable<KeyValuePair<string, object?>>
2024-11-18 12:21:12 +01:00
Darius Letterman 38e7a1a45d
Allow logging of body without modifying the actual response (#5628)
Allow logging of body without modifying the actual response
2024-11-18 10:24:41 +00:00
Amadeusz Lechniak 7c398375c2
Update WaiterRemovedAfterDispose to check waitersCount first (#5646)
Co-authored-by: EUROPE\alechniak <alechniak@microsoft.com>
2024-11-15 20:49:02 -05:00
Steve Sanderson 09094aebc2
EmbeddingGeneratorBuilder API updates (#5647) 2024-11-15 07:47:41 -08:00
dotnet-maestro[bot] aa6e8f0bbe
[main] Update dependencies from dotnet/aspnetcore (#5645)
[main] Update dependencies from dotnet/aspnetcore
- Coherency Updates:
  - Microsoft.Bcl.TimeProvider: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Caching.Abstractions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Caching.Memory: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Configuration.Abstractions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Configuration.Binder: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Configuration.Json: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Configuration: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.DependencyInjection.Abstractions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.DependencyInjection: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Hosting.Abstractions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Diagnostics: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Hosting: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Http: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Logging.Abstractions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Logging.Configuration: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Logging.Console: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Logging: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Options.ConfigurationExtensions: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Extensions.Options: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.NETCore.App.Ref: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.Bcl.AsyncInterfaces: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Net.Http.Json: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - Microsoft.NETCore.App.Runtime.win-x64: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Collections.Immutable: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Configuration.ConfigurationManager: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Diagnostics.DiagnosticSource: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Diagnostics.PerformanceCounter: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.IO.Hashing: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.IO.Pipelines: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Security.Cryptography.Pkcs: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Security.Cryptography.Xml: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Text.Encodings.Web: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Text.Json: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)
  - System.Runtime.Caching: from 9.0.0 to 9.0.0 (parent: Microsoft.AspNetCore.App.Runtime.win-x64)

 - Add missing feed

 - Fix versions
2024-11-15 07:43:00 +00:00
Steve Sanderson 56e720c688
Change ChatClientBuilder to register singletons and support lambda-less chaining (#5642)
* Change ChatClientBuilder to register singletons and support lambda-less chaining

* Add generic keyed version

* Improve XML doc

* Update README files

* Remove generic DI registration methods
2024-11-14 08:36:08 -05:00
Genevieve Warren d39bf3dfec
docs updates (#5643) 2024-11-14 00:06:04 -05:00
Stephen Toub 430065ce56
Rework cache key handling in caching client / generator (#5641)
* Rework cache key handling in caching client / generator

- Expose the default cache key helper so that customization doesn't require re-implementing the whole thing.
- Make it easy to incorporate additional state into the cache key.
- Avoid serializing all of the values for the key into a new byte[], at least on .NET 8+. There, we can serialize directly into a stream that targets an IncrementalHash.
- Include Chat/EmbeddingGenerationOptions in the cache key by default.

* Update test/Libraries/Microsoft.Extensions.AI.Tests/Embeddings/DistributedCachingEmbeddingGeneratorTest.cs

Co-authored-by: Shyam N <shyamnamboodiripad@users.noreply.github.com>

---------

Co-authored-by: Shyam N <shyamnamboodiripad@users.noreply.github.com>
2024-11-14 00:05:51 -05:00
Eirik Tsarpalis 73962c60f1
Replace STJ boilerplate in the leaf clients with AIJsonUtilities calls. (#5630)
* Replace STJ boilerplate in the leaf clients with AIJsonUtilities calls.

* Address feedback.

* Address feedback.

* Remove redundant using
2024-11-13 18:35:39 +00:00
Jose Perez Rodriguez ad3b5d0338
Merge branch release/9.0 into main (#5632) 2024-11-13 09:52:50 -08:00
Eric Erhardt 1073446964
Publish the AotCompatibility.TestApp project as part of PR validation (#5622)
- Remove AI in Microsoft.Extensions.AI.AotCompatibility.TestApp so it can be used for all projects
    - Analyze all libraries except the ones that have current warnings
- Publish the app from the AzDO pipeline
- Clean up the AotCompatibility.TestApp
    - Remove unnecessary code in Program.cs by turning off ReferenceTrimmer
    - Make the project publishable without passing in a TFM by only targeting a single TFM
- Fix part of Compliance.Redaction trimming issues by reenabling the Config Binder source generator.
2024-11-12 22:28:07 -06:00
Eric Erhardt 4cd0228eeb Change TrimmerRootAssembly to use FileName to be correct. 2024-11-12 18:17:16 -06:00
Jose Perez Rodriguez d79192cc67 Merge branch release/9.0 into main 2024-11-12 15:08:57 -08:00
Eric Erhardt 30dae3db7a Remove testing cruft from TestApp project 2024-11-12 16:46:21 -06:00
Jose Perez Rodriguez f9edff24a9
Merge internal changes (#5631) 2024-11-12 14:19:45 -08:00
Eric Erhardt e690bbf4b7 try running during BuildAndTest.yml 2024-11-12 16:00:54 -06:00
Eric Erhardt 0a4bbeed0e Revert "Temporarily disable the test to figure out what is causing the code coverage errors."
This reverts commit 47beb96689.
2024-11-12 15:53:09 -06:00
Jose Perez Rodriguez c94cd35e54 Merge internal branch changes 2024-11-12 13:44:03 -08:00
Eric Erhardt 47beb96689 Temporarily disable the test to figure out what is causing the code coverage errors. 2024-11-12 14:10:49 -06:00
Eric Erhardt 5b339698af Remove MS.Ext.AI now that the issue is resolved. 2024-11-12 11:09:16 -06:00
Eric Erhardt f228df9b24 Merge remote-tracking branch 'upstream/main' into AotCI 2024-11-12 10:58:15 -06:00
Eric Erhardt 9c675f1913 Remove cleaning from publish 2024-11-12 10:58:04 -06:00
Eirik Tsarpalis 6487428046
Fix linker warning. (#5627) 2024-11-12 16:37:57 +00:00
Haipz 7d554db60c Cache current process object to avoid performance hit (#5597)
* Read working set from Environment in ProcessInfo since it has better performance.

* Add unit test for ProcessInfo.

* Remove OSSkipCondition tag from process info unit test since it's cross-platform.

* Use Environment.WorkingSet in GetMemoryUsageInBytes.
2024-11-12 10:26:59 -06:00
Stephen Toub c77e368808
Fix namespace for IServiceCollection extensions (#5620)
We generally put extension methods into the same namespace as the thing they're extending.
2024-11-12 11:02:32 -05:00
Haipz 4b8dad5587
Cache current process object to avoid performance hit (#5597)
* Read working set from Environment in ProcessInfo since it has better performance.

* Add unit test for ProcessInfo.

* Remove OSSkipCondition tag from process info unit test since it's cross-platform.

* Use Environment.WorkingSet in GetMemoryUsageInBytes.
2024-11-12 08:46:47 +01:00
Eric Erhardt 12b8949512 Exclude Microsoft.Extensions.AI as well, since it hits the warnings in #5626 2024-11-11 21:56:23 -06:00
Eric Erhardt ff0bf8ca50 Add an exclusion for Microsoft.Extensions.AI.Abstractions 2024-11-11 18:15:40 -06:00
Eric Erhardt 5b2b7a2bb4 Merge remote-tracking branch 'upstream/main' into AotCI 2024-11-11 18:11:18 -06:00
Eric Erhardt fbf2866b34 Add tracking issue links for OpenAI and Azure.AI.Inference trim/AOT compatibility. 2024-11-11 16:53:21 -06:00
Eirik Tsarpalis 95a80ccd84
Expose options for making schema generation conformant with the subset accepted by OpenAI. (#5619)
* Expose options for making schema generation conformant with the subset accepted by OpenAI.

* Uses the same set of defaults in all layers.
2024-11-11 21:54:33 +00:00
Eric Erhardt 9fbc27c38e - Add tracing issues.
- Ensure clean uses the same configuration as publish
- Fix part of Compliance.Redaction trimming issues by reenabling the Config Binder source generator.
2024-11-11 15:52:35 -06:00