Skip to content

Commit

Permalink
Merge pull request #310 from betalgo/dev
Browse files Browse the repository at this point in the history
Dev v7.1.1 beta
  • Loading branch information
kayhantolga authored Jun 22, 2023
2 parents 1603e31 + 9080eb4 commit 012af71
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion OpenAI.SDK/Managers/OpenAIChatCompletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void Process(ChatCompletionCreateResponse block)
if (firstChoice == null) { return; } // not a valid state? nothing to do

var isStreamingFnCall = IsStreamingFunctionCall();
var justStarted = false;

// If we're not yet assembling, and we just got a streaming block that has a function_call segment,
// this is the beginning of a function call assembly.
Expand All @@ -116,10 +117,12 @@ public void Process(ChatCompletionCreateResponse block)
{
FnCall = firstChoice.Message.FunctionCall;
firstChoice.Message.FunctionCall = null;
justStarted = true;
}

// As long as we're assembling, keep on appending those args
if (IsFnAssemblyActive)
// (Skip the first one, because it was already processed in the block above)
if (IsFnAssemblyActive && !justStarted)
{
FnCall.Arguments += ExtractArgsSoFar();
}
Expand Down
6 changes: 5 additions & 1 deletion OpenAI.SDK/ObjectModels/RequestModels/ChatMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public static ChatMessage FromAssistant(string content, string? name = null)
{
return new ChatMessage(StaticValues.ChatMessageRoles.Assistant, content, name);
}

public static ChatMessage FromFunction(string content, string? name = null)
{
return new ChatMessage(StaticValues.ChatMessageRoles.Function, content, name);
}
public static ChatMessage FromUser(string content, string? name = null)
{
return new ChatMessage(StaticValues.ChatMessageRoles.User, content, name);
Expand Down Expand Up @@ -169,6 +172,7 @@ public class FunctionParameterPropertyValue
/// <summary>
/// Optional. List of allowed values for this argument.
/// </summary>
[JsonPropertyName("enum")]
public IList<string>? Enum { get; set; }
}

Expand Down
1 change: 1 addition & 0 deletions OpenAI.SDK/ObjectModels/StaticValueHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public static class ChatMessageRoles
public static string System => "system";
public static string User => "user";
public static string Assistant => "assistant";
public static string Function => "function";
}
}
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 @@
<PackageProjectUrl>https://openai.com/</PackageProjectUrl>
<PackageIcon>OpenAI-Betalgo.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>7.1.0-beta</Version>
<Version>7.1.2-beta</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
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ I will always be using the latest libraries, and future releases will frequently
I am incredibly busy. If I forgot your name, please accept my apologies and let me know so I can add it to the list.

## Changelog
### 7.1.2-beta
- Bugfix https://github.com/betalgo/openai/pull/302
- Added support for Function role https://github.com/betalgo/openai/issues/303
### 7.1.0-beta
- Function Calling: We're releasing this version to bring in a new feature that lets you call functions faster. But remember, this version might not be perfectly stable and we might change it a lot later. A big shout-out to @rzubek for helping us add this feature. Although I liked his work, I didn't have enough time to look into it thoroughly. Still, the tests I did showed it was working, so I decided to add his feature to our code. This lets everyone use it now. Even though I'm busy moving houses and didn't have much time, seeing @rzubek's help made things a lot easier for me.
- Support for New Models: This update also includes support for new models that OpenAI recently launched. I've also changed the naming style to match OpenAI's. Model names will no longer start with 'chat'; instead, they'll start with 'gpt_3_5' and so on.
Expand Down

0 comments on commit 012af71

Please sign in to comment.