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

OpenAI-DotNet 7.7.3 #252

Merged
merged 1 commit into from
Feb 27, 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
2 changes: 1 addition & 1 deletion OpenAI-DotNet-Tests/TestServices/WeatherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal enum WeatherUnit
[Function("Get the current weather in a given location.")]
public static async Task<string> GetCurrentWeatherAsync(
[FunctionParameter("The location the user is currently in.")] string location,
[FunctionParameter("The units the use has requested temperature in. Typically this is based on the users location.")] WeatherUnit unit)
[FunctionParameter("The units the user has requested temperature in. Typically this is based on the users location.")] WeatherUnit unit)
{
var temp = new Random().Next(-10, 40);

Expand Down
11 changes: 6 additions & 5 deletions OpenAI-DotNet/Chat/ChatRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public ChatRequest(
string user = null)
: this(messages, model, frequencyPenalty, logitBias, maxTokens, number, presencePenalty, responseFormat, seed, stops, temperature, topP, topLogProbs, user)
{
var tooList = tools?.ToList();
var toolList = tools?.ToList();

if (tooList != null && tooList.Any())
if (toolList != null && toolList.Any())
{
if (string.IsNullOrWhiteSpace(toolChoice))
{
Expand All @@ -43,8 +43,9 @@ public ChatRequest(
if (!toolChoice.Equals("none") &&
!toolChoice.Equals("auto"))
{
var tool = tooList.FirstOrDefault(t => t.Function.Name.Contains(toolChoice));
ToolChoice = tool ?? throw new ArgumentException($"The specified tool choice '{toolChoice}' was not found in the list of tools");
var tool = toolList.FirstOrDefault(t => t.Function.Name.Contains(toolChoice)) ??
throw new ArgumentException($"The specified tool choice '{toolChoice}' was not found in the list of tools");
ToolChoice = new { type = "function", function = new { name = tool.Function.Name } };
}
else
{
Expand All @@ -53,7 +54,7 @@ public ChatRequest(
}
}

Tools = tooList?.ToList();
Tools = toolList?.ToList();
}

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion OpenAI-DotNet/OpenAI-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet-
<AssemblyOriginatorKeyFile>OpenAI-DotNet.pfx</AssemblyOriginatorKeyFile>
<IncludeSymbols>True</IncludeSymbols>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<Version>7.7.2</Version>
<Version>7.7.3</Version>
<PackageReleaseNotes>
Version 7.7.3
- Updated ChatRequest toolChoice to only send type and name of function, reducing token usage
Version 7.7.2
- Added FunctionParameterAttribute to help better inform the feature how to format the Function json
Version 7.7.1
Expand Down