Skip to content

Commit

Permalink
Merge pull request #686 from stephentoub/upgrademeai
Browse files Browse the repository at this point in the history
Update M.E.AI to 9.0.1-preview.1.24570.5
  • Loading branch information
kayhantolga authored Dec 4, 2024
2 parents 0a97483 + 6622468 commit 7dce0d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 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.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

0 comments on commit 7dce0d3

Please sign in to comment.