Skip to content

Commit 22cbd15

Browse files
committed
fb
1 parent 435f35e commit 22cbd15

26 files changed

+153
-534
lines changed

src/Custom/Chat/ChatClient.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public virtual ClientResult<ChatCompletion> GetChatCompletion(string completionI
394394
}
395395

396396
[Experimental("OPENAI001")]
397-
public virtual ClientResult<ChatCompletionResult> GetChatCompletion(GetChatCompletionOptions options, CancellationToken cancellationToken = default)
397+
public virtual ClientResult<ChatCompletionResult> GetChatCompletion(GetCompletionOptions options, CancellationToken cancellationToken = default)
398398
{
399399
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
400400

@@ -403,7 +403,7 @@ public virtual ClientResult<ChatCompletionResult> GetChatCompletion(GetChatCompl
403403
}
404404

405405
[Experimental("OPENAI001")]
406-
public virtual async Task<ClientResult<ChatCompletionResult>> GetChatCompletionAsync(GetChatCompletionOptions options, CancellationToken cancellationToken = default)
406+
public virtual async Task<ClientResult<ChatCompletionResult>> GetChatCompletionAsync(GetCompletionOptions options, CancellationToken cancellationToken = default)
407407
{
408408
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
409409

@@ -413,29 +413,29 @@ public virtual async Task<ClientResult<ChatCompletionResult>> GetChatCompletionA
413413

414414
[Experimental("OPENAI001")]
415415
[OverloadResolutionPriority(2)]
416-
public virtual ClientResult<ChatCompletionMessageCollection> GetChatCompletionMessages(GetChatCompletionMessageOptions options, CancellationToken cancellationToken = default)
416+
public virtual ClientResult<CompletionMessageCollection> GetChatCompletionMessages(GetCompletionMessageOptions options, CancellationToken cancellationToken = default)
417417
{
418418
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
419419

420420
PipelineMessage message = CreateGetChatCompletionMessagesRequest(options.CompletionId, options.After, options.Limit, options.Order, cancellationToken.ToRequestOptions());
421421
ClientResult result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, cancellationToken.ToRequestOptions()));
422-
return ClientResult.FromValue((ChatCompletionMessageCollection)result, result.GetRawResponse());
422+
return ClientResult.FromValue((CompletionMessageCollection)result, result.GetRawResponse());
423423
}
424424

425425
[Experimental("OPENAI001")]
426426
[OverloadResolutionPriority(2)]
427-
public virtual async Task<ClientResult<ChatCompletionMessageCollection>> GetChatCompletionMessagesAsync(GetChatCompletionMessageOptions options, CancellationToken cancellationToken = default)
427+
public virtual async Task<ClientResult<CompletionMessageCollection>> GetChatCompletionMessagesAsync(GetCompletionMessageOptions options, CancellationToken cancellationToken = default)
428428
{
429429
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
430430

431431
PipelineMessage message = CreateGetChatCompletionMessagesRequest(options.CompletionId, options.After, options.Limit, options.Order, cancellationToken.ToRequestOptions());
432432
ClientResult result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, cancellationToken.ToRequestOptions()).ConfigureAwait(false));
433-
return ClientResult.FromValue((ChatCompletionMessageCollection)result, result.GetRawResponse());
433+
return ClientResult.FromValue((CompletionMessageCollection)result, result.GetRawResponse());
434434
}
435435

436436
[Experimental("OPENAI001")]
437437
[OverloadResolutionPriority(1)]
438-
public virtual CollectionResult GetChatCompletionMessages(GetChatCompletionMessageOptions options, RequestOptions requestOptions = null)
438+
public virtual CollectionResult GetChatCompletionMessages(GetCompletionMessageOptions options, RequestOptions requestOptions = null)
439439
{
440440
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
441441

@@ -450,7 +450,7 @@ public virtual CollectionResult GetChatCompletionMessages(GetChatCompletionMessa
450450

451451
[Experimental("OPENAI001")]
452452
[OverloadResolutionPriority(1)]
453-
public virtual AsyncCollectionResult GetChatCompletionMessagesAsync(GetChatCompletionMessageOptions options, RequestOptions requestOptions = null)
453+
public virtual AsyncCollectionResult GetChatCompletionMessagesAsync(GetCompletionMessageOptions options, RequestOptions requestOptions = null)
454454
{
455455
Argument.AssertNotNullOrEmpty(options.CompletionId, nameof(options.CompletionId));
456456

@@ -515,25 +515,25 @@ public virtual ClientResult<ChatCompletionDeletionResult> DeleteChatCompletion(s
515515

516516
[Experimental("OPENAI001")]
517517
[OverloadResolutionPriority(2)]
518-
public virtual ClientResult<ChatCompletionCollection> GetChatCompletions(GetChatCompletionsOptions options, CancellationToken cancellationToken = default)
518+
public virtual ClientResult<CompletionCollection> GetChatCompletions(ChatCompletionsOptions options, CancellationToken cancellationToken = default)
519519
{
520520
PipelineMessage message = CreateGetChatCompletionsRequest(options.After, options.Limit, options.Order, options.Metadata, options.Model, cancellationToken.ToRequestOptions());
521521
ClientResult result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, cancellationToken.ToRequestOptions()));
522-
return ClientResult.FromValue((ChatCompletionCollection)result, result.GetRawResponse());
522+
return ClientResult.FromValue((CompletionCollection)result, result.GetRawResponse());
523523
}
524524

525525
[Experimental("OPENAI001")]
526526
[OverloadResolutionPriority(2)]
527-
public virtual async Task<ClientResult<ChatCompletionCollection>> GetChatCompletionsAsync(GetChatCompletionsOptions options, CancellationToken cancellationToken = default)
527+
public virtual async Task<ClientResult<CompletionCollection>> GetChatCompletionsAsync(ChatCompletionsOptions options, CancellationToken cancellationToken = default)
528528
{
529529
PipelineMessage message = CreateGetChatCompletionsRequest(options.After, options.Limit, options.Order, options.Metadata, options.Model, cancellationToken.ToRequestOptions());
530530
ClientResult result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, cancellationToken.ToRequestOptions()));
531-
return ClientResult.FromValue((ChatCompletionCollection)result, result.GetRawResponse());
531+
return ClientResult.FromValue((CompletionCollection)result, result.GetRawResponse());
532532
}
533533

534534
[Experimental("OPENAI001")]
535535
[OverloadResolutionPriority(1)]
536-
public virtual CollectionResult GetChatCompletions(GetChatCompletionsOptions options, RequestOptions requestOptions)
536+
public virtual CollectionResult GetChatCompletions(ChatCompletionsOptions options, RequestOptions requestOptions)
537537
{
538538
return new ChatClientGetChatCompletionsCollectionResult(
539539
this,
@@ -547,7 +547,7 @@ public virtual CollectionResult GetChatCompletions(GetChatCompletionsOptions opt
547547

548548
[Experimental("OPENAI001")]
549549
[OverloadResolutionPriority(1)]
550-
public virtual AsyncCollectionResult GetChatCompletionsAsync(GetChatCompletionsOptions options, RequestOptions requestOptions)
550+
public virtual AsyncCollectionResult GetChatCompletionsAsync(ChatCompletionsOptions options, RequestOptions requestOptions)
551551
{
552552
return new ChatClientGetChatCompletionsAsyncCollectionResult(
553553
this,

src/Custom/Chat/ChatClientGetChatCompletionsAsyncCollectionResultOfT.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public override async IAsyncEnumerable<ClientResult> GetRawPagesAsync()
3838
yield return result;
3939

4040
// Plugin customization: add hasMore assignment
41-
bool hasMore = ((ChatCompletionCollection)result).HasMore;
42-
nextToken = ((ChatCompletionCollection)result).LastId;
41+
bool hasMore = ((CompletionCollection)result).HasMore;
42+
nextToken = ((CompletionCollection)result).LastId;
4343
// Plugin customization: add hasMore == false check to pagination condition
4444
if (nextToken == null || !hasMore)
4545
{
@@ -51,7 +51,7 @@ public override async IAsyncEnumerable<ClientResult> GetRawPagesAsync()
5151

5252
public override ContinuationToken GetContinuationToken(ClientResult page)
5353
{
54-
string nextPage = ((ChatCompletionCollection)page).LastId;
54+
string nextPage = ((CompletionCollection)page).LastId;
5555
if (nextPage != null)
5656
{
5757
return ContinuationToken.FromBytes(BinaryData.FromString(nextPage));
@@ -64,7 +64,7 @@ public override ContinuationToken GetContinuationToken(ClientResult page)
6464

6565
protected override async IAsyncEnumerable<ChatCompletionResult> GetValuesFromPageAsync(ClientResult page)
6666
{
67-
foreach (ChatCompletionResult item in ((ChatCompletionCollection)page).Data)
67+
foreach (ChatCompletionResult item in ((CompletionCollection)page).Data)
6868
{
6969
yield return item;
7070
await Task.Yield();

src/Custom/Chat/ChatClientGetChatCompletionsCollectionResultOfT.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public override IEnumerable<ClientResult> GetRawPages()
3737
yield return result;
3838

3939
// Plugin customization: add hasMore assignment
40-
bool hasMore = ((ChatCompletionCollection)result).HasMore;
41-
nextToken = ((ChatCompletionCollection)result).LastId;
40+
bool hasMore = ((CompletionCollection)result).HasMore;
41+
nextToken = ((CompletionCollection)result).LastId;
4242
// Plugin customization: add hasMore == false check to pagination condition
4343
if (nextToken == null || !hasMore)
4444
{
@@ -50,7 +50,7 @@ public override IEnumerable<ClientResult> GetRawPages()
5050

5151
public override ContinuationToken GetContinuationToken(ClientResult page)
5252
{
53-
string nextPage = ((ChatCompletionCollection)page).LastId;
53+
string nextPage = ((CompletionCollection)page).LastId;
5454
if (nextPage != null)
5555
{
5656
return ContinuationToken.FromBytes(BinaryData.FromString(nextPage));
@@ -63,7 +63,7 @@ public override ContinuationToken GetContinuationToken(ClientResult page)
6363

6464
protected override IEnumerable<ChatCompletionResult> GetValuesFromPage(ClientResult page)
6565
{
66-
return ((ChatCompletionCollection)page).Data;
66+
return ((CompletionCollection)page).Data;
6767
}
6868
}
6969
}

src/Custom/Chat/ChatCompletionResponseChoice.Serialization.cs renamed to src/Custom/Chat/ChatCompletionChoice.Serialization.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace OpenAI.Chat
77
{
8-
public partial class ChatCompletionResponseChoice : IJsonModel<ChatCompletionResponseChoice>
8+
public partial class ChatCompletionChoice : IJsonModel<ChatCompletionChoice>
99
{
10-
internal ChatCompletionResponseChoice()
10+
internal ChatCompletionChoice()
1111
{
1212
}
1313

14-
void IJsonModel<ChatCompletionResponseChoice>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
14+
void IJsonModel<ChatCompletionChoice>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
1515
{
1616
writer.WriteStartObject();
1717
JsonModelWriteCore(writer, options);
@@ -54,20 +54,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
5454
Patch.WriteTo(writer);
5555
}
5656

57-
ChatCompletionResponseChoice IJsonModel<ChatCompletionResponseChoice>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
57+
ChatCompletionChoice IJsonModel<ChatCompletionChoice>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
5858

59-
protected virtual ChatCompletionResponseChoice JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
59+
protected virtual ChatCompletionChoice JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
6060
{
61-
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionResponseChoice>)this).GetFormatFromOptions(options) : options.Format;
61+
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionChoice>)this).GetFormatFromOptions(options) : options.Format;
6262
if (format != "J")
6363
{
64-
throw new FormatException($"The model {nameof(ChatCompletionResponseChoice)} does not support reading '{format}' format.");
64+
throw new FormatException($"The model {nameof(ChatCompletionChoice)} does not support reading '{format}' format.");
6565
}
6666
using JsonDocument document = JsonDocument.ParseValue(ref reader);
6767
return DeserializeCreateChatCompletionResponseChoice(document.RootElement, null, options);
6868
}
6969

70-
internal static ChatCompletionResponseChoice DeserializeCreateChatCompletionResponseChoice(JsonElement element, BinaryData data, ModelReaderWriterOptions options)
70+
internal static ChatCompletionChoice DeserializeCreateChatCompletionResponseChoice(JsonElement element, BinaryData data, ModelReaderWriterOptions options)
7171
{
7272
if (element.ValueKind == JsonValueKind.Null)
7373
{
@@ -76,7 +76,7 @@ internal static ChatCompletionResponseChoice DeserializeCreateChatCompletionResp
7676
ChatFinishReason finishReason = default;
7777
int index = default;
7878
ChatCompletionResponseMessage message = default;
79-
ChatCompletionResponseChoiceLogprobs logprobs = default;
79+
ChatCompletionChoiceProbabilities logprobs = default;
8080
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
8181
JsonPatch patch = new JsonPatch(data is null ? ReadOnlyMemory<byte>.Empty : data.ToMemory());
8282
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.ƒ
@@ -105,33 +105,33 @@ internal static ChatCompletionResponseChoice DeserializeCreateChatCompletionResp
105105
logprobs = null;
106106
continue;
107107
}
108-
logprobs = ChatCompletionResponseChoiceLogprobs.DeserializeCreateChatCompletionResponseChoiceLogprobs(prop.Value, prop.Value.GetUtf8Bytes(), options);
108+
logprobs = ChatCompletionChoiceProbabilities.DeserializeCreateChatCompletionResponseChoiceLogprobs(prop.Value, prop.Value.GetUtf8Bytes(), options);
109109
continue;
110110
}
111111
patch.Set([.. "$."u8, .. Encoding.UTF8.GetBytes(prop.Name)], prop.Value.GetUtf8Bytes());
112112
}
113-
return new ChatCompletionResponseChoice(finishReason, index, message, logprobs, patch);
113+
return new ChatCompletionChoice(finishReason, index, message, logprobs, patch);
114114
}
115115

116-
BinaryData IPersistableModel<ChatCompletionResponseChoice>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
116+
BinaryData IPersistableModel<ChatCompletionChoice>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
117117

118118
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options)
119119
{
120-
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionResponseChoice>)this).GetFormatFromOptions(options) : options.Format;
120+
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionChoice>)this).GetFormatFromOptions(options) : options.Format;
121121
switch (format)
122122
{
123123
case "J":
124124
return ModelReaderWriter.Write(this, options, OpenAIContext.Default);
125125
default:
126-
throw new FormatException($"The model {nameof(ChatCompletionResponseChoice)} does not support writing '{options.Format}' format.");
126+
throw new FormatException($"The model {nameof(ChatCompletionChoice)} does not support writing '{options.Format}' format.");
127127
}
128128
}
129129

130-
ChatCompletionResponseChoice IPersistableModel<ChatCompletionResponseChoice>.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
130+
ChatCompletionChoice IPersistableModel<ChatCompletionChoice>.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
131131

132-
protected virtual ChatCompletionResponseChoice PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options)
132+
protected virtual ChatCompletionChoice PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options)
133133
{
134-
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionResponseChoice>)this).GetFormatFromOptions(options) : options.Format;
134+
string format = options.Format == "W" ? ((IPersistableModel<ChatCompletionChoice>)this).GetFormatFromOptions(options) : options.Format;
135135
switch (format)
136136
{
137137
case "J":
@@ -140,10 +140,10 @@ protected virtual ChatCompletionResponseChoice PersistableModelCreateCore(Binary
140140
return DeserializeCreateChatCompletionResponseChoice(document.RootElement, data, options);
141141
}
142142
default:
143-
throw new FormatException($"The model {nameof(ChatCompletionResponseChoice)} does not support reading '{options.Format}' format.");
143+
throw new FormatException($"The model {nameof(ChatCompletionChoice)} does not support reading '{options.Format}' format.");
144144
}
145145
}
146146

147-
string IPersistableModel<ChatCompletionResponseChoice>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
147+
string IPersistableModel<ChatCompletionChoice>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
148148
}
149149
}

src/Custom/Chat/ChatCompletionResponseChoice.cs renamed to src/Custom/Chat/ChatCompletionChoice.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
namespace OpenAI.Chat
66
{
77
[Experimental("OPENAI001")]
8-
public partial class ChatCompletionResponseChoice
8+
public partial class ChatCompletionChoice
99
{
1010
[Experimental("SCME0001")]
1111
private JsonPatch _patch;
1212

13-
internal ChatCompletionResponseChoice(ChatFinishReason finishReason, int index, ChatCompletionResponseMessage message, ChatCompletionResponseChoiceLogprobs logprobs)
13+
internal ChatCompletionChoice(ChatFinishReason finishReason, int index, ChatCompletionResponseMessage message, ChatCompletionChoiceProbabilities logprobs)
1414
{
1515
FinishReason = finishReason;
1616
Index = index;
1717
Message = message;
1818
Logprobs = logprobs;
1919
}
2020

21-
internal ChatCompletionResponseChoice(ChatFinishReason finishReason, int index, ChatCompletionResponseMessage message, ChatCompletionResponseChoiceLogprobs logprobs, in JsonPatch patch)
21+
internal ChatCompletionChoice(ChatFinishReason finishReason, int index, ChatCompletionResponseMessage message, ChatCompletionChoiceProbabilities logprobs, in JsonPatch patch)
2222
{
2323
FinishReason = finishReason;
2424
Index = index;
@@ -33,7 +33,7 @@ internal ChatCompletionResponseChoice(ChatFinishReason finishReason, int index,
3333

3434
public ChatCompletionResponseMessage Message { get; }
3535

36-
public ChatCompletionResponseChoiceLogprobs Logprobs { get; }
36+
public ChatCompletionChoiceProbabilities Logprobs { get; }
3737

3838
[EditorBrowsable(EditorBrowsableState.Never)]
3939
[Experimental("SCME0001")]

0 commit comments

Comments
 (0)