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

Update M.E.AI to 9.0.1-preview.1.24570.5 #686

Merged
merged 3 commits into from
Dec 4, 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.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.0-preview.9.24525.1" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>
8 changes: 3 additions & 5 deletions OpenAI.SDK/Managers/OpenAIChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public partial class OpenAIService : IChatClient
ChatClientMetadata IChatClient.Metadata => _chatMetadata ??= new(nameof(OpenAIService), _httpClient.BaseAddress, _defaultModelId);

/// <inheritdoc />
TService? IChatClient.GetService<TService>(object? key) where TService : class
{
return this as TService;
}
object? IChatClient.GetService(Type serviceType, object? serviceKey) =>
serviceKey is null && serviceType?.IsInstanceOfType(this) is true ? this : null;

/// <inheritdoc />
void IDisposable.Dispose()
Expand Down Expand Up @@ -155,14 +153,14 @@ private ChatCompletionCreateRequest CreateRequest(IList<ChatMessage> chatMessage
request.TopP = options.TopP;
request.FrequencyPenalty = options.FrequencyPenalty;
request.PresencePenalty = options.PresencePenalty;
request.Seed = (int?)options.Seed;
request.StopAsList = options.StopSequences;

// Non-strongly-typed properties from additional properties
request.LogitBias = options.AdditionalProperties?.TryGetValue(nameof(request.LogitBias), out var logitBias) is true ? logitBias : null;
request.LogProbs = options.AdditionalProperties?.TryGetValue(nameof(request.LogProbs), out bool logProbs) is true ? logProbs : null;
request.N = options.AdditionalProperties?.TryGetValue(nameof(request.N), out int n) is true ? n : null;
request.ParallelToolCalls = options.AdditionalProperties?.TryGetValue(nameof(request.ParallelToolCalls), out bool parallelToolCalls) is true ? parallelToolCalls : null;
request.Seed = options.AdditionalProperties?.TryGetValue(nameof(request.Seed), out int seed) is true ? seed : null;
request.ServiceTier = options.AdditionalProperties?.TryGetValue(nameof(request.ServiceTier), out string? serviceTier) is true ? serviceTier : null!;
request.User = options.AdditionalProperties?.TryGetValue(nameof(request.User), out string? user) is true ? user : null!;
request.TopLogprobs = options.AdditionalProperties?.TryGetValue(nameof(request.TopLogprobs), out int topLogprobs) is true ? topLogprobs : null;
Expand Down
7 changes: 5 additions & 2 deletions OpenAI.SDK/Managers/OpenAIEmbeddingGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ public partial class OpenAIService : IEmbeddingGenerator<string, Embedding<float
{
private EmbeddingGeneratorMetadata? _embeddingMetadata;

/// <inheritdoc />
EmbeddingGeneratorMetadata IEmbeddingGenerator<string, Embedding<float>>.Metadata =>
_embeddingMetadata ??= new(nameof(OpenAIService), _httpClient.BaseAddress, _defaultModelId);

TService? IEmbeddingGenerator<string, Embedding<float>>.GetService<TService>(object? key) where TService : class =>
this as TService;
/// <inheritdoc />
object? IEmbeddingGenerator<string, Embedding<float>>.GetService(Type serviceType, object? serviceKey) =>
serviceKey is null && serviceType?.IsInstanceOfType(this) is true ? this : null;

/// <inheritdoc />
async Task<GeneratedEmbeddings<Embedding<float>>> IEmbeddingGenerator<string, Embedding<float>>.GenerateAsync(IEnumerable<string> values, EmbeddingGenerationOptions? options, CancellationToken cancellationToken)
{
var response = await this.Embeddings.CreateEmbedding(new()
Expand Down