Skip to content

Commit

Permalink
Merge pull request #638 from betalgo/bug/tool-definition-strict
Browse files Browse the repository at this point in the history
moved strict paremeter from ToolDefinition to FunctionDefinition
  • Loading branch information
kayhantolga authored Sep 24, 2024
2 parents 7ec9fb1 + 198012e commit 7704d04
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
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

0 comments on commit 7704d04

Please sign in to comment.