Skip to content
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-DotNet/Extensions/ResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static async Task<string> ReadAsStringAsync(this HttpResponseMessage res

if (@event.Data != null)
{
@object[ServerSentEventKind.Data.ToString().ToLower()] = JsonNode.Parse(@event.Data.ToJsonString());
@object[nameof(ServerSentEventKind.Data).ToLower()] = JsonNode.Parse(@event.Data.ToJsonString());
}

array.Add(@object);
Expand Down
5 changes: 4 additions & 1 deletion OpenAI-DotNet/OpenAI-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet-
<AssemblyOriginatorKeyFile>OpenAI-DotNet.pfx</AssemblyOriginatorKeyFile>
<IncludeSymbols>true</IncludeSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>8.8.3</Version>
<Version>8.8.4</Version>
<PackageReleaseNotes>
Version 8.8.4
- Fix RealtimeSessionConfiguration and CreateResponseRequest model parameter overriding prompt settings
- Fix Threads.MessageResponse.Status not being properly set to Completed
Version 8.8.3
- Fix regression ObjectDisposedException from OpenAIBaseEndpoint refactoring
- Add Azure Blob Batch API compatible fields for CreateBatchRequest
Expand Down
80 changes: 62 additions & 18 deletions OpenAI-DotNet/Realtime/SessionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,85 @@ public SessionConfiguration(
int? maxResponseOutputTokens,
int? expiresAfter)
: this(
model: model,
modalities: modalities,
voice: voice,
instructions: instructions,
inputAudioFormat: inputAudioFormat,
outputAudioFormat: outputAudioFormat,
model,
prompt: null,
instructions,
modalities,
voice,
speed: null,
inputAudioFormat,
outputAudioFormat,
inputAudioNoiseSettings: null,
inputAudioTranscriptionSettings: new(transcriptionModel),
turnDetectionSettings: turnDetectionSettings,
tools: tools,
toolChoice: toolChoice,
temperature: temperature,
maxResponseOutputTokens: maxResponseOutputTokens,
expiresAfter: expiresAfter)
turnDetectionSettings,
tools,
toolChoice,
temperature,
maxResponseOutputTokens,
expiresAfter)
{
}

[Obsolete("Use new ctor overload")]
public SessionConfiguration(
Model model,
Modality modalities,
Voice voice,
string instructions,
RealtimeAudioFormat inputAudioFormat,
RealtimeAudioFormat outputAudioFormat,
InputAudioTranscriptionSettings inputAudioTranscriptionSettings,
IVoiceActivityDetectionSettings turnDetectionSettings,
IEnumerable<Tool> tools,
string toolChoice,
float? temperature,
int? maxResponseOutputTokens,
int? expiresAfter,
NoiseReductionSettings inputAudioNoiseSettings,
float? speed,
Prompt prompt)
: this(
model,
prompt,
instructions,
modalities,
voice,
speed,
inputAudioFormat,
outputAudioFormat,
inputAudioNoiseSettings,
inputAudioTranscriptionSettings,
turnDetectionSettings,
tools,
toolChoice,
temperature,
maxResponseOutputTokens,
expiresAfter)
{
}

public SessionConfiguration(
Model model = null,
Prompt prompt = null,
string instructions = null,
Modality modalities = Modality.Text | Modality.Audio,
Voice voice = null,
string instructions = null,
float? speed = null,
RealtimeAudioFormat inputAudioFormat = RealtimeAudioFormat.PCM16,
RealtimeAudioFormat outputAudioFormat = RealtimeAudioFormat.PCM16,
NoiseReductionSettings inputAudioNoiseSettings = null,
InputAudioTranscriptionSettings inputAudioTranscriptionSettings = null,
IVoiceActivityDetectionSettings turnDetectionSettings = null,
IEnumerable<Tool> tools = null,
string toolChoice = null,
float? temperature = null,
int? maxResponseOutputTokens = null,
int? expiresAfter = null,
NoiseReductionSettings inputAudioNoiseSettings = null,
float? speed = null,
Prompt prompt = null)
int? expiresAfter = null)
{
ClientSecret = new ClientSecret(expiresAfter);
Model = string.IsNullOrWhiteSpace(model?.Id) ? Models.Model.GPT4oRealtime : model;
Model = string.IsNullOrWhiteSpace(model?.Id) && prompt == null
? Models.Model.GPT4oRealtime
: model;
Modalities = modalities;
Voice = string.IsNullOrWhiteSpace(voice?.Id) ? OpenAI.Voice.Alloy : voice;
Instructions = string.IsNullOrWhiteSpace(instructions)
Expand Down Expand Up @@ -153,6 +196,7 @@ internal SessionConfiguration(
/// </summary>
[JsonInclude]
[JsonPropertyName("model")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Model { get; private set; }

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion OpenAI-DotNet/Responses/CreateResponseRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public CreateResponseRequest(
int? topLogProbs = null)
{
Input = input?.ToArray() ?? throw new ArgumentNullException(nameof(input));
Model = string.IsNullOrWhiteSpace(model) ? Models.Model.ChatGPT4o : model;
Model = string.IsNullOrWhiteSpace(model?.Id) && prompt == null
? Models.Model.GPT4oRealtime
: model;
Background = background;
Include = include?.ToList();
Instructions = instructions;
Expand Down Expand Up @@ -214,6 +216,7 @@ public CreateResponseRequest(
/// </summary>
[JsonInclude]
[JsonPropertyName("model")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Model { get; private set; }

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions OpenAI-DotNet/Threads/MessageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ internal void AppendFrom(MessageResponse other)
IncompleteAtUnixTimeSeconds = other.IncompleteAtUnixTimeSeconds;
}

if (Status == 0 &&
other.Status > 0)
if (other.Status > 0)
{
Status = other.Status;
}
Expand Down
Loading