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

1362 Коммитов

Автор SHA1 Сообщение Дата
Stephen Toub 4f95e7e1aa
Backport M.E.AI commits to release/9.0 (#5673) 2024-11-20 17:29:30 -05:00
Eirik Tsarpalis 7f2d9003f8 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 16:52:07 -05:00
Stephen Toub 1f47a84f52 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 15:01:25 -05:00
Stephen Toub 5293e22f73 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 15:01:16 -05:00
Stephen Toub e985af6c85 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 15:01:05 -05:00
Stephen Toub e12f1d76e4 Tweak CachingHelpers.GetCacheKey to clean up better on failure (#5654) 2024-11-19 17:09:42 -05:00
Steve Sanderson d6ba3d045e Add OpenAIRealtimeExtensions with ToConversationFunctionTool (#5666) 2024-11-19 17:08:41 -05:00
Eirik Tsarpalis 63d537804b Backport JsonSchemaExporter bugfix. (#5671)
* Backport JsonSchemaExporter bugfix.

* Address feedback.
2024-11-19 17:08:28 -05:00
Stephen Toub 32fd4f2d59 Add anonymous delegating clients / generators (#5650) 2024-11-19 17:08:18 -05:00
Stephen Toub 8d00ebe68e Reverse order of services/inner in Use methods (#5664) 2024-11-19 17:08:03 -05:00
Stephen Toub d70d900dfc Reduce a bit of LINQ in M.E.AI (#5663) 2024-11-19 17:07:53 -05:00
Stephen Toub 655cc50105 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-19 17:07:43 -05:00
Stephen Toub 58b5f9f1b6 Augment XML comments for AIFunctionFactory.Create (#5658)
* Augment XML comments for AIFunctionFactory.Create

* Add JSON serialization comments
2024-11-19 17:07:33 -05:00
Stephen Toub 81d188e7e6 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-19 17:07:23 -05:00
Stephen Toub 4dc4db6fdb Fix M.E.AI argument tests to validate argument names (#5653) 2024-11-19 17:07:10 -05:00
Stephen Toub 8a4db54b41 Annotate private DebuggerDisplay props as DebuggerBrowsableState.Never (#5656)
It's just noise.
2024-11-19 17:07:01 -05:00
Stephen Toub 581ae37fb5 Add a [DebuggerDisplay] to GeneratedEmbeddings (#5657) 2024-11-19 17:06:52 -05:00
Steve Sanderson d009fe0ee9 EmbeddingGeneratorBuilder API updates (#5647) 2024-11-19 17:06:42 -05:00
Steve Sanderson 1f8ae147e5 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-19 17:06:32 -05:00
Genevieve Warren 2de8e89f9e docs updates (#5643) 2024-11-19 17:06:18 -05:00
Stephen Toub 0577c2110a 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-19 17:06:08 -05:00
Eirik Tsarpalis a1863ea0b6 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-19 17:05:54 -05:00
Eirik Tsarpalis 3aff2e4d30 Fix linker warning. (#5627) 2024-11-19 17:04:31 -05:00
Stephen Toub 39279193f7 Fix namespace for IServiceCollection extensions (#5620)
We generally put extension methods into the same namespace as the thing they're extending.
2024-11-19 17:04:20 -05:00
Eirik Tsarpalis 1dbecfb6a6 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-19 17:04:11 -05:00
Stephen Toub b84a353b19 Tweak ChatMessage/StreamingChatCompletionUpdate.ToString (#5617)
* Tweak ChatMessage/StreamingChatCompletionUpdate.ToString

Include all text rather than just the first text content.

* Address PR feedback and fix / add tests
2024-11-19 17:04:00 -05:00
Stephen Toub fc7029615a Add DebuggerDisplay for DataContent (#5618) 2024-11-19 17:03:31 -05:00
Stephen Toub 025459db91 Use ToChatCompletion / ToStreamingChatCompletionUpdates in CachingChatClient (#5616)
* Use ToChatCompletion / ToStreamingChatCompletionUpdates in CachingChatClient

Adds a ToStreamingChatCompletionUpdates method that's the counterpart to the recently added ToChatCompletion.

Then uses both from CachingChatClient instead of its now bespoke coalescing implementation. When coalescing is enabled (the default), CachingChatClient caches everything as a ChatCompletion, rather than distinguishing streaming and non-streaming.

* Address PR feedback
2024-11-19 17:03:20 -05:00
Stephen Toub 8c65205206 Use ToChatCompletion in OpenTelemetryChatClient (#5614) 2024-11-19 17:03:08 -05:00
Genevieve Warren b06615488f Docs improvements (#5613)
* docs improvements

* small addition

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2024-11-19 17:02:55 -05:00
Stephen Toub 1faf6b4b3a Add ToChatCompletion{Async} methods for combining StreamingChatCompleteUpdates (#5605) 2024-11-19 17:02:42 -05:00
Stephen Toub 7f7c2985c8 Update M.E.AI CHANGELOG.mds for latest preview (#5609) 2024-11-19 17:02:22 -05:00
Stephen Toub d7c32f84ec Add logging/activities to FunctionInvokingChatClient (#5596)
* Add logging/activities to FunctionInvokingChatClient

* Change FunctionInvokingChatClient to use ActivitySource from OpenTelemetryChatClient
2024-11-19 17:01:28 -05:00
Stephen Toub ca7d3f28fb Make IChatClient/IEmbeddingGenerator.GetService non-generic (#5608) 2024-11-19 17:01:10 -05:00
Stephen Toub 4f775a0b0e Rework UseChatOptions as ConfigureOptions (#5606)
* Update README to include a section on UseChatOptions

* Rework UseChat/EmbeddingGenerationOptions to always clone

The callbacks now configure the supplied instance.
2024-11-19 17:00:55 -05:00
Jose Perez Rodriguez f9edff24a9
Merge internal changes (#5631) 2024-11-12 14:19:45 -08:00
Jose Perez Rodriguez c94cd35e54 Merge internal branch changes 2024-11-12 13:44:03 -08:00
Jose Perez Rodriguez 16acdbf144 Merged PR 44778: Merging branch release/9.0 into internal/release/9.0 2024-11-06 22:12:31 +00:00
Jose Perez Rodriguez d468173295
[release/9.0] Merging changes from main into release branch for November release (#5602) 2024-11-06 09:38:41 -08:00
Stephen Toub f902047c64 Set DisableNETStandardCompatErrors for M.E.AI projects (#5603) 2024-11-06 08:49:32 -05:00
Marc Gravell 80c9263380 HybridCache stability and logging improvements (#5467)
* - handle serialization failures
- enforce payload quota
- enforce key validity
- add proper logging (infrastructure failure: needs attn)

# Conflicts:
#	src/Libraries/Microsoft.Extensions.Caching.Hybrid/Microsoft.Extensions.Caching.Hybrid.csproj

* - add "callback" to .dic
- log deserialization failures
- expose serialization failures
- tests for serialization logging scenarios

* support and tests for stability despite unreliable L2

* nit

* Compile for NS2.0

* include enabled check in our log output

* add event-source tracing and counters

* explicitly specify event-source guid

* satisfy the stylebot overloads

* nix SDT

* fix failing CI test

* limit to net462

* PR feedback (all except event tests)

* naming

* add event source tests

* fix redundant comment

* add clarification

* more clarifications

* dance for our robot overlords

* drop Microsoft.Extensions.Telemetry.Abstractions package-ref

* fix glitchy L2 test

* better tracking for invalid event-source state

* reserve non-printable characters from keys, to prevent L2 abuse

* improve test output for ETW

* tyop

* ETW tests: allow longer if needed

* whitespace

* more ETW fixins

---------

Co-authored-by: Jose Perez Rodriguez <joperezr@microsoft.com>
2024-11-05 10:27:25 -08:00
Stephen Toub 228a96dcda Add UseEmbeddingGenerationOptions (#5594)
* Add UseEmbeddingGenerationOptions

Counterpart to UseChatOptions

* Document/test null options returned from callback
2024-11-05 10:27:14 -08:00
Stephen Toub 32505677dc Improve AdditionalPropertiesDictionary (#5593)
- Add a strongly-typed Enumerator
- Add a TryAdd method
- Add a DebuggerDisplay for Count
- Add a DebuggerTypeProxy for the collection of properties
2024-11-05 10:27:03 -08:00
Eirik Tsarpalis 23b073207f Improve JsonSchemaExporter trimmer safety. (#5591)
* Improve JsonSchemaExporter trimmer safety.

* Remove var

* Address feedback.

* Remove DynamicallyAccessedMemberTypes.All

* Extract reflection helpers into separate file and remove a number of warning suppressions.

* Re-enable failing tests that were patched in .NET 9
2024-11-05 10:26:51 -08:00
Eirik Tsarpalis ce9a807d4b Plug JsonSchemaExporter test data to the AIJsonUtilities tests (#5590)
* Plug JsonSchemaExporter test data to the AIJsonUtilities tests

* Update src/LegacySupport/DiagnosticAttributes/README.md

* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.cs

* Address feedback.
2024-11-05 10:26:39 -08:00
Eirik Tsarpalis 365f33ce1f Lower `AIJsonUtilities` to STJv8 and move to Abstractions library. (#5582)
* Lower AIJsonUtilities to STJv8 and move to Abstractions library.

* Add README.md
2024-11-05 10:26:25 -08:00
Stephen Toub cd9da61b84 Add ChatOptions.Seed (#5587) 2024-11-05 10:26:15 -08:00
Stephen Toub fe9e5bf9a9 Add ImageContent integration test (#5586) 2024-11-05 10:26:05 -08:00
Eirik Tsarpalis 7f60bea106 fix exception when generating boolean schemas (#5585) 2024-11-05 10:25:42 -08:00
Stephen Toub e90c1fa05e Fix AzureAIInferenceEmbeddingGenerator to respect EmbeddingGenerationOptions.Dimensions (#5575)
Merge conflict blip.
2024-11-05 10:25:05 -08:00