Skip to content

Commit a9c80c4

Browse files
authored
Fix custom code AOT compatibility (#781)
1 parent b06f32a commit a9c80c4

17 files changed

+31
-31
lines changed

src/Custom/Assistants/AssistantResponseFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public override string ToString()
103103
}
104104
else
105105
{
106-
return ModelReaderWriter.Write(this).ToString();
106+
return ModelReaderWriter.Write(this, ModelReaderWriterOptions.Json, OpenAIContext.Default).ToString();
107107
}
108108
}
109109
}

src/Custom/FineTuning/FineTuningClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ internal virtual FineTuningJob CreateJobFromResponse(PipelineResponse response)
217217

218218
internal virtual IEnumerable<FineTuningJob> CreateJobsFromPageResponse(PipelineResponse response)
219219
{
220-
InternalListPaginatedFineTuningJobsResponse jobs = ModelReaderWriter.Read<InternalListPaginatedFineTuningJobsResponse>(response.Content)!;
220+
InternalListPaginatedFineTuningJobsResponse jobs = ModelReaderWriter.Read<InternalListPaginatedFineTuningJobsResponse>(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!;
221221
return jobs.Data.Select(job => new FineTuningJob(Pipeline, _endpoint, job, response));
222222
}
223223
}

src/Custom/FineTuning/FineTuningTrainingMethod.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public static FineTuningTrainingMethod CreateSupervised(
2323
Kind = InternalFineTuneMethodType.Supervised,
2424
Supervised = new() {
2525
Hyperparameters = new() {
26-
_BatchSize = batchSize is not null ? ModelReaderWriter.Write(batchSize) : null,
27-
_NEpochs = epochCount is not null ? ModelReaderWriter.Write(epochCount) : null,
28-
_LearningRateMultiplier = learningRate is not null ? ModelReaderWriter.Write(learningRate) : null,
26+
_BatchSize = batchSize is not null ? ModelReaderWriter.Write(batchSize, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
27+
_NEpochs = epochCount is not null ? ModelReaderWriter.Write(epochCount, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
28+
_LearningRateMultiplier = learningRate is not null ? ModelReaderWriter.Write(learningRate, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
2929
},
3030
},
3131
};
@@ -42,10 +42,10 @@ public static FineTuningTrainingMethod CreateDirectPreferenceOptimization(
4242
Kind = InternalFineTuneMethodType.Dpo,
4343
Dpo = new() {
4444
Hyperparameters = new() {
45-
_Beta = betaFactor is not null ? ModelReaderWriter.Write(betaFactor) : null,
46-
_BatchSize = batchSize is not null ? ModelReaderWriter.Write(batchSize) : null,
47-
_NEpochs = epochCount is not null ? ModelReaderWriter.Write(epochCount) : null,
48-
_LearningRateMultiplier = learningRate is not null ? ModelReaderWriter.Write(learningRate) : null,
45+
_Beta = betaFactor is not null ? ModelReaderWriter.Write(betaFactor, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
46+
_BatchSize = batchSize is not null ? ModelReaderWriter.Write(batchSize, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
47+
_NEpochs = epochCount is not null ? ModelReaderWriter.Write(epochCount, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
48+
_LearningRateMultiplier = learningRate is not null ? ModelReaderWriter.Write(learningRate, ModelReaderWriterOptions.Json, OpenAIContext.Default) : null,
4949
},
5050
},
5151
};

src/Custom/FineTuning/Internal/Pagination/AsyncFineTuningCheckpointCollectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override IAsyncEnumerable<FineTuningCheckpoint> GetValuesFromPageAsync
8181
Argument.AssertNotNull(page, nameof(page));
8282

8383
PipelineResponse response = page.GetRawResponse();
84-
InternalListFineTuningJobCheckpointsResponse list = ModelReaderWriter.Read<InternalListFineTuningJobCheckpointsResponse>(response.Content)!;
84+
InternalListFineTuningJobCheckpointsResponse list = ModelReaderWriter.Read<InternalListFineTuningJobCheckpointsResponse>(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!;
8585
return list.Data.ToAsyncEnumerable(_cancellationToken);
8686
}
8787
}

src/Custom/FineTuning/Internal/Pagination/AsyncFineTuningEventCollectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override IAsyncEnumerable<FineTuningEvent> GetValuesFromPageAsync(Clie
8181
Argument.AssertNotNull(page, nameof(page));
8282

8383
PipelineResponse response = page.GetRawResponse();
84-
InternalListFineTuningJobEventsResponse list = ModelReaderWriter.Read<InternalListFineTuningJobEventsResponse>(response.Content)!;
84+
InternalListFineTuningJobEventsResponse list = ModelReaderWriter.Read<InternalListFineTuningJobEventsResponse>(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!;
8585
return list.Data.ToAsyncEnumerable(_cancellationToken);
8686
}
8787
}

src/Custom/FineTuning/Internal/Pagination/FineTuningCheckpointCollectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected override IEnumerable<FineTuningCheckpoint> GetValuesFromPage(ClientRes
8686
Argument.AssertNotNull(page, nameof(page));
8787

8888
PipelineResponse response = page.GetRawResponse();
89-
InternalListFineTuningJobCheckpointsResponse points = ModelReaderWriter.Read<InternalListFineTuningJobCheckpointsResponse>(response.Content)!;
89+
InternalListFineTuningJobCheckpointsResponse points = ModelReaderWriter.Read<InternalListFineTuningJobCheckpointsResponse>(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!;
9090
return points.Data;
9191
}
9292
}

src/Custom/FineTuning/Internal/Pagination/FineTuningEventCollectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected override IEnumerable<FineTuningEvent> GetValuesFromPage(ClientResult p
8686
Argument.AssertNotNull(page, nameof(page));
8787

8888
PipelineResponse response = page.GetRawResponse();
89-
InternalListFineTuningJobEventsResponse events = ModelReaderWriter.Read<InternalListFineTuningJobEventsResponse>(response.Content)!;
89+
InternalListFineTuningJobEventsResponse events = ModelReaderWriter.Read<InternalListFineTuningJobEventsResponse>(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!;
9090
return events.Data;
9191
}
9292
}

src/Custom/Realtime/ConversationResponseOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public ConversationToolChoice ToolChoice
3535
set
3636
{
3737
_internalToolChoice = value is not null
38-
? ModelReaderWriter.Write(value)
38+
? ModelReaderWriter.Write(value, ModelReaderWriterOptions.Json, OpenAIContext.Default)
3939
: null;
4040
}
4141
}
@@ -48,7 +48,7 @@ public ConversationMaxTokensChoice MaxOutputTokens
4848
get => ConversationMaxTokensChoice.FromBinaryData(_maxResponseOutputTokens);
4949
set
5050
{
51-
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value);
51+
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value, ModelReaderWriterOptions.Json, OpenAIContext.Default);
5252
}
5353
}
5454

src/Custom/Realtime/ConversationSessionOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ConversationToolChoice ToolChoice
3333
set
3434
{
3535
_internalToolChoice = value is not null
36-
? ModelReaderWriter.Write(value)
36+
? ModelReaderWriter.Write(value, ModelReaderWriterOptions.Json, OpenAIContext.Default)
3737
: null;
3838
}
3939
}
@@ -46,7 +46,7 @@ public ConversationMaxTokensChoice MaxOutputTokens
4646
get => ConversationMaxTokensChoice.FromBinaryData(_maxResponseOutputTokens);
4747
set
4848
{
49-
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value);
49+
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value, ModelReaderWriterOptions.Json, OpenAIContext.Default);
5050
}
5151
}
5252

src/Custom/Realtime/Internal/InternalRealtimeResponseSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ConversationMaxTokensChoice MaxResponseOutputTokens
2222
get => ConversationMaxTokensChoice.FromBinaryData(_maxResponseOutputTokens);
2323
set
2424
{
25-
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value);
25+
_maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value, ModelReaderWriterOptions.Json, OpenAIContext.Default);
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)