Skip to content

Fix #433, #358, #342. #434

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/Custom/Chat/ChatFinishReason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,12 @@ public enum ChatFinishReason
/// </remarks>
[CodeGenMember("FunctionCall")]
FunctionCall,

/// <summary>
/// Indicates that the model returns unknown finish reason (or null).
/// We interpret this as a stop sequence.
/// </summary>
[CodeGenMember("Stop")]
Unknown

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ private void SerializeArgumentsValue(Utf8JsonWriter writer, ModelReaderWriterOpt
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void DeserializeArgumentsValue(JsonProperty property, ref BinaryData arguments, ModelReaderWriterOptions options = null)
{
arguments = BinaryData.FromString(property.Value.GetString());
//for a tool calls without arguments there will be an Object instead of String.
var obj = property.Value.GetObject();
if (obj is string s)
{
arguments = BinaryData.FromString(s);
}
else
{
arguments = BinaryData.FromString(string.Empty);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ private static void DeserializeArgumentsValue(JsonProperty property, ref BinaryD
{
return;
}
arguments = BinaryData.FromString(property.Value.GetString());

//for a tool calls without arguments there will be an Object instead of String.
var obj = property.Value.GetObject();
if (obj is string s)
{
arguments = BinaryData.FromString(s);
}
else
{
arguments = BinaryData.FromString(string.Empty);
}
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/ChatFinishReason.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ChatFinishReason ToChatFinishReason(this string value)
{
return ChatFinishReason.FunctionCall;
}
throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatFinishReason value.");
return ChatFinishReason.Unknown;
}
}
}