-
Notifications
You must be signed in to change notification settings - Fork 850
Add ReasoningOptions to ChatOptions #7252
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ab97011
Initial plan
Copilot ba4e283
Add ReasoningOptions to ChatOptions with OpenAI implementation
Copilot 676ac5d
Address code review feedback: add Clone method and document ExtraHigh…
Copilot e7f7ce8
Address PR feedback: remove experimental attributes, make Clone inter…
Copilot f459c9c
Address PR feedback: update docs, remove enum values, add tests
Copilot 88c12a3
Rename ReasoningOutput.Detailed to ReasoningOutput.Full
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ReasoningEffort.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Extensions.AI; | ||
|
|
||
| /// <summary> | ||
| /// Specifies the level of reasoning effort that should be applied when generating chat responses. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This value suggests how much computational effort the model should put into reasoning. | ||
| /// Higher values may result in more thoughtful responses but with increased latency and token usage. | ||
| /// The specific interpretation and support for each level may vary between providers or even between models from the same provider. | ||
| /// </remarks> | ||
| public enum ReasoningEffort | ||
| { | ||
| /// <summary> | ||
| /// No reasoning effort. | ||
| /// </summary> | ||
| None, | ||
|
|
||
| /// <summary> | ||
| /// Low reasoning effort. Minimal reasoning for faster responses. | ||
| /// </summary> | ||
| Low, | ||
|
|
||
| /// <summary> | ||
| /// Medium reasoning effort. Balanced reasoning for most use cases. | ||
| /// </summary> | ||
| Medium, | ||
|
|
||
| /// <summary> | ||
| /// High reasoning effort. Extensive reasoning for complex tasks. | ||
| /// </summary> | ||
| High, | ||
|
|
||
| /// <summary> | ||
| /// Extra high reasoning effort. Maximum reasoning for the most demanding tasks. | ||
| /// </summary> | ||
| ExtraHigh, | ||
| } | ||
46 changes: 46 additions & 0 deletions
46
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ReasoningOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Extensions.AI; | ||
|
|
||
| /// <summary> | ||
| /// Represents options for configuring reasoning behavior in chat requests. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// Reasoning options allow control over how much computational effort the model | ||
| /// should put into reasoning about the response, and how that reasoning should | ||
| /// be exposed to the caller. | ||
| /// </para> | ||
| /// <para> | ||
| /// Not all providers support all reasoning options. Implementations should | ||
| /// make a best-effort attempt to map the requested options to the provider's | ||
| /// capabilities. If a provider or model doesn't support reasoning or doesn't support the requested configuration of reasoning, these options may be ignored. | ||
| /// </para> | ||
| /// </remarks> | ||
| public sealed class ReasoningOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the level of reasoning effort to apply. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The reasoning effort level, or <see langword="null"/> to use the provider's default. | ||
| /// </value> | ||
| public ReasoningEffort? Effort { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets how reasoning content should be included in the response. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The reasoning output mode, or <see langword="null"/> to use the provider's default. | ||
| /// </value> | ||
| public ReasoningOutput? Output { get; set; } | ||
|
|
||
| /// <summary>Creates a shallow clone of this <see cref="ReasoningOptions"/> instance.</summary> | ||
| /// <returns>A shallow clone of this instance.</returns> | ||
| internal ReasoningOptions Clone() => new() | ||
| { | ||
| Effort = Effort, | ||
| Output = Output, | ||
| }; | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ReasoningOutput.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Extensions.AI; | ||
|
|
||
| /// <summary> | ||
| /// Specifies how reasoning content should be included in the response. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Some providers support including reasoning or thinking traces in the response. | ||
| /// This setting controls whether and how that reasoning content is exposed. | ||
| /// </remarks> | ||
| public enum ReasoningOutput | ||
| { | ||
| /// <summary> | ||
| /// No reasoning output. Do not include reasoning content in the response. | ||
| /// </summary> | ||
| None, | ||
|
|
||
| /// <summary> | ||
| /// Summary reasoning output. Include a summary of the reasoning process. | ||
| /// </summary> | ||
| Summary, | ||
|
|
||
| /// <summary> | ||
| /// Full reasoning output. Include all reasoning content in the response. | ||
| /// </summary> | ||
| Full, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.