Skip to content

Commit

Permalink
Update M.E.AI to 9.1.0-preview.1.25064.3
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jan 15, 2025
1 parent 7fd09c9 commit 115b181
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion OpenAI.SDK/Betalgo.Ranul.OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<PackageReference Include="System.Net.Http.Json" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.1.0-preview.1.25064.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>
16 changes: 5 additions & 11 deletions OpenAI.SDK/Managers/OpenAIChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private ChatCompletionCreateRequest CreateRequest(IList<ChatMessage> chatMessage
JsonSchema = new()
{
Name = json.SchemaName ?? "JsonSchema",
Schema = JsonSerializer.Deserialize<PropertyDefinition>(json.Schema),
Schema = json.Schema.Value.Deserialize<PropertyDefinition>(),
Description = json.SchemaDescription
}
};
Expand Down Expand Up @@ -353,33 +353,27 @@ private static UsageDetails GetUsageDetails(UsageResponse usage)

if (usage.PromptTokensDetails is { } promptDetails)
{
Dictionary<string, object?> d = new(StringComparer.OrdinalIgnoreCase);
(details.AdditionalProperties ??= [])[nameof(usage.PromptTokensDetails)] = d;

if (promptDetails.CachedTokens is int cachedTokens)
{
d[nameof(promptDetails.CachedTokens)] = cachedTokens;
(details.AdditionalCounts ??= [])[$"{nameof(usage.PromptTokensDetails)}.{nameof(promptDetails.CachedTokens)}"] = cachedTokens;
}

if (promptDetails.AudioTokens is int audioTokens)
{
d[nameof(promptDetails.AudioTokens)] = audioTokens;
(details.AdditionalCounts ??= [])[$"{nameof(usage.PromptTokensDetails)}.{nameof(promptDetails.AudioTokens)}"] = audioTokens;
}
}

if (usage.CompletionTokensDetails is { } completionDetails)
{
Dictionary<string, object?> d = new(StringComparer.OrdinalIgnoreCase);
(details.AdditionalProperties ??= [])[nameof(usage.CompletionTokensDetails)] = d;

if (completionDetails.ReasoningTokens is int reasoningTokens)
{
d[nameof(completionDetails.ReasoningTokens)] = reasoningTokens;
(details.AdditionalCounts ??= [])[$"{nameof(usage.CompletionTokensDetails)}.{nameof(completionDetails.ReasoningTokens)}"] = reasoningTokens;
}

if (completionDetails.AudioTokens is int audioTokens)
{
d[nameof(promptDetails.AudioTokens)] = audioTokens;
(details.AdditionalCounts ??= [])[$"{nameof(usage.CompletionTokensDetails)}.{nameof(completionDetails.AudioTokens)}"] = audioTokens;
}
}

Expand Down

0 comments on commit 115b181

Please sign in to comment.