Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Starting v0.1.0 for Microsoft.Azure.WebJobs.Extensions.OpenAI.AzureAISearch, it
- Updated Azure.AI.OpenAI from 1.0.0-beta.15 to 2.1.0
- Updated Azure.Data.Tables from 12.9.1 to 12.10.0, Azure.Identity from 1.12.1 to 1.13.2, Microsoft.Extensions.Azure from 1.7.5 to 1.10.0

### Added

- Introduced experimental `isReasoningModel` property to support reasoning models. Setting of max_completion_tokens and reasoning_effort is not supported with current underlying Azure.AI.OpenAI

## v0.18.0 - 2024/10/08

### Changed
Expand Down
4 changes: 4 additions & 0 deletions java-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Update azure-ai-openai from 1.0.0-beta.11 to 1.0.0-beta.16

### Added

- Introduced experimental `isReasoningModel` property to support reasoning models. Setting of max_completion_tokens and reasoning_effort is not supported with current underlying Azure.AI.OpenAI

## v0.4.0 - 2024/10/08

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,11 @@
* @return The maxTokens value.
*/
String maxTokens() default "100";

/**
* Indicates whether the assistant uses a reasoning model.
*
* @return {@code true} if the assistant is based on a reasoning model; {@code false} otherwise.
*/
boolean isReasoningModel() default false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,11 @@ String systemPrompt() default "You are a helpful assistant. You are responding t
* @return The maxTokens value.
*/
String maxTokens() default "2048";

/**
* Indicates whether the assistant uses a reasoning model.
*
* @return {@code true} if the assistant is based on a reasoning model; {@code false} otherwise.
*/
boolean isReasoningModel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@
*/
String maxTokens() default "100";

/**
* Indicates whether the assistant uses a reasoning model.
*
* @return {@code true} if the assistant is based on a reasoning model; {@code false} otherwise.
*/
boolean isReasoningModel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,12 @@ public AssistantPostInputAttribute(string id, string userMessage)
/// Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
/// </remarks>
public string? MaxTokens { get; set; } = "100";

/// <summary>
/// Gets or sets a value indicating whether the model is a reasoning model.
/// </summary>
/// <remarks>
/// Warning: This is experimental and associated with the reasoning model until all models have parity in the expected properties.
/// </remarks>
public bool IsReasoningModel { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,12 @@ The following is a list of documents that you can refer to when answering questi
/// Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
/// </remarks>
public string? MaxTokens { get; set; } = "2048";

/// <summary>
/// Gets or sets a value indicating whether the model is a reasoning model.
/// </summary>
/// <remarks>
/// Warning: This is experimental and associated with the reasoning model until all models have parity in the expected properties.
/// </remarks>
public bool IsReasoningModel { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,12 @@ public TextCompletionInputAttribute(string prompt)
/// Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
/// </remarks>
public string? MaxTokens { get; set; } = "100";

/// <summary>
/// Gets or sets a value indicating whether the model is a reasoning model.
/// </summary>
/// <remarks>
/// Warning: This is experimental and associated with the reasoning model until all models have parity in the expected properties.
/// </remarks>
public bool IsReasoningModel { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public class AssistantBaseAttribute : Attribute
[AutoResolve]
public string? TopP { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the model is a reasoning model.
/// </summary>
/// <remarks>
/// Warning: This is experimental and associated with the reasoning model until all models have parity in the expected properties.
/// </remarks>
public bool IsReasoningModel { get; set; }

/// <summary>
/// Gets or sets the maximum number of tokens to output in the completion. Default value = 100.
/// </summary>
Expand All @@ -76,21 +84,39 @@ public class AssistantBaseAttribute : Attribute
internal ChatCompletionOptions BuildRequest()
{
ChatCompletionOptions request = new();
if (int.TryParse(this.MaxTokens, out int maxTokens))
if (float.TryParse(this.TopP, out float topP))
{
request.MaxOutputTokenCount = maxTokens;
request.TopP = topP;
}

if (float.TryParse(this.Temperature, out float temperature))
if (this.IsReasoningModel)
{
request.Temperature = temperature;
this.MaxTokens = null;
this.Temperature = null; // property not supported for reasoning model.
}

if (float.TryParse(this.TopP, out float topP))
else
{
request.TopP = topP;
if (int.TryParse(this.MaxTokens, out int maxTokens))
{
request.MaxOutputTokenCount = maxTokens;
}

if (float.TryParse(this.Temperature, out float temperature))
{
request.Temperature = temperature;
}
}

// ToDo: SetNewMaxCompletionTokensPropertyEnabled() has a bug in the current version
// of the Azure.AI.OpenAI SDK but is fixed in the next preview.
//
// This method doesn't swap max_tokens with max_completion_tokens and throws errors
// if max_tokens is set. max_completion_tokens is not configurable due to this bug.
//
// Hence, setting max_tokens to null for reasoning models until the fixed SDK version
// can be adopted.
// request.SetNewMaxCompletionTokensPropertyEnabled(this.IsReasoningModel);

return request;
}
}