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

moved strict paremeter from ToolDefinition to FunctionDefinition #638

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 1 deletion OpenAI.SDK/Builders/FunctionDefinitionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public class FunctionDefinitionBuilder
/// </summary>
/// <param name="name">The name of the function</param>
/// <param name="description">The optional description of the function</param>
public FunctionDefinitionBuilder(string name, string? description = null)
/// <param name="strict">Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the function calling guide.</param>
public FunctionDefinitionBuilder(string name, string? description = null, bool? strict =null)
{
_definition = new()
{
Name = name,
Description = description,
Strict = strict,
Parameters = new()
{
Properties = new Dictionary<string, PropertyDefinition>()
Expand Down
9 changes: 9 additions & 0 deletions OpenAI.SDK/ObjectModels/RequestModels/FunctionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ public class FunctionDefinition
/// </summary>
[JsonPropertyName("parameters")]
public PropertyDefinition Parameters { get; set; }


/// <summary>
/// Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow
/// the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true.
/// Learn more about Structured Outputs in the <a href="https://platform.openai.com/docs/api-reference/chat/docs/guides/function-calling">function calling guide</a>.
/// </summary>
[JsonPropertyName("strict")]
public bool? Strict { get; set; }
}
7 changes: 0 additions & 7 deletions OpenAI.SDK/ObjectModels/RequestModels/ToolDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ public class ToolDefinition
[JsonPropertyName("type")]
public string Type { get; set; }

/// <summary>
/// Structured Outputs for function calling can be enabled with a single parameter, just by supplying strict: true.
/// Please note: This field is not mentioned in the API documentation but is referenced in other documents.
/// </summary>
[JsonPropertyName("strict")]
public bool? Strict { get; set; }

/// <summary>
/// Overrides for the file search tool.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenAI.SDK/OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageIcon>Betalgo-Ranul-OpenAI-icon.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>OpenAI SDK by Betalgo</Title>
<Version>8.7.0</Version>
<Version>8.7.1</Version>
<Authors>Tolga Kayhan, Betalgo</Authors>
<Company>Betalgo Up Ltd.</Company>
<Product>OpenAI ChatGPT, Whisper, GPT-4 and DALL·E dotnet SDK</Product>
Expand Down
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Due to time constraints, not all methods have been thoroughly tested or fully do
Needless to say, I cannot accept responsibility for any damage caused by using the library.

## Changelog
### 8.7.1
- moved `strict ` paremeter from `ToolDefinition` to `FunctionDefinition`
### 8.7.0
- Added Support for o1 reasing models (`o1-mini` and `o1-preview`).
- Added `MaxCompletionTokens` for `chat completions`.
Expand Down