Skip to content

Commit ac69967

Browse files
authored
Merge pull request #386 from deepgram/fix/mips_opt_out
fix: fixes mip_opt_out placement
2 parents 2241627 + 3f0bb8f commit ac69967

File tree

3 files changed

+67
-37
lines changed

3 files changed

+67
-37
lines changed

Deepgram.Tests/UnitTests/ClientTests/AgentClientTests.cs

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -202,45 +202,45 @@ public void InjectUserMessageSchema_ToString_Should_Return_Valid_Json()
202202
#region MipOptOut Tests
203203

204204
[Test]
205-
public void Agent_MipOptOut_Should_Have_Default_Value_False()
205+
public void SettingsSchema_MipOptOut_Should_Have_Default_Value_False()
206206
{
207207
// Arrange & Act
208-
var agent = new Agent();
208+
var settings = new SettingsSchema();
209209

210210
// Assert
211211
using (new AssertionScope())
212212
{
213-
agent.MipOptOut.Should().BeFalse();
213+
settings.MipOptOut.Should().BeFalse();
214214
}
215215
}
216216

217217
[Test]
218-
public void Agent_MipOptOut_Should_Be_Settable()
218+
public void SettingsSchema_MipOptOut_Should_Be_Settable()
219219
{
220220
// Arrange & Act
221-
var agent = new Agent
221+
var settings = new SettingsSchema
222222
{
223223
MipOptOut = true
224224
};
225225

226226
// Assert
227227
using (new AssertionScope())
228228
{
229-
agent.MipOptOut.Should().BeTrue();
229+
settings.MipOptOut.Should().BeTrue();
230230
}
231231
}
232232

233233
[Test]
234-
public void Agent_MipOptOut_Should_Serialize_To_Snake_Case()
234+
public void SettingsSchema_MipOptOut_Should_Serialize_To_Snake_Case()
235235
{
236236
// Arrange
237-
var agent = new Agent
237+
var settings = new SettingsSchema
238238
{
239239
MipOptOut = true
240240
};
241241

242242
// Act
243-
var result = agent.ToString();
243+
var result = settings.ToString();
244244

245245
// Assert
246246
using (new AssertionScope())
@@ -256,16 +256,16 @@ public void Agent_MipOptOut_Should_Serialize_To_Snake_Case()
256256
}
257257

258258
[Test]
259-
public void Agent_MipOptOut_False_Should_Serialize_Correctly()
259+
public void SettingsSchema_MipOptOut_False_Should_Serialize_Correctly()
260260
{
261261
// Arrange
262-
var agent = new Agent
262+
var settings = new SettingsSchema
263263
{
264264
MipOptOut = false
265265
};
266266

267267
// Act
268-
var result = agent.ToString();
268+
var result = settings.ToString();
269269

270270
// Assert
271271
using (new AssertionScope())
@@ -281,16 +281,16 @@ public void Agent_MipOptOut_False_Should_Serialize_Correctly()
281281
}
282282

283283
[Test]
284-
public void Agent_MipOptOut_Null_Should_Not_Serialize()
284+
public void SettingsSchema_MipOptOut_Null_Should_Not_Serialize()
285285
{
286286
// Arrange
287-
var agent = new Agent
287+
var settings = new SettingsSchema
288288
{
289289
MipOptOut = null
290290
};
291291

292292
// Act
293-
var result = agent.ToString();
293+
var result = settings.ToString();
294294

295295
// Assert
296296
using (new AssertionScope())
@@ -305,45 +305,50 @@ public void Agent_MipOptOut_Null_Should_Not_Serialize()
305305
}
306306

307307
[Test]
308-
public void Agent_With_MipOptOut_Should_Serialize_With_Other_Properties()
308+
public void SettingsSchema_With_MipOptOut_Should_Serialize_With_Other_Properties()
309309
{
310310
// Arrange
311-
var agent = new Agent
311+
var settings = new SettingsSchema
312312
{
313-
Language = "en",
314-
Greeting = "Hello, I'm your agent",
315-
MipOptOut = true
313+
Experimental = true,
314+
MipOptOut = true,
315+
Agent = new Agent
316+
{
317+
Language = "en",
318+
Greeting = "Hello, I'm your agent"
319+
}
316320
};
317321

318322
// Act
319-
var result = agent.ToString();
323+
var result = settings.ToString();
320324

321325
// Assert
322326
using (new AssertionScope())
323327
{
324328
result.Should().NotBeNull();
325-
result.Should().Contain("language");
326-
result.Should().Contain("greeting");
329+
result.Should().Contain("experimental");
327330
result.Should().Contain("mip_opt_out");
331+
result.Should().Contain("agent");
328332

329333
// Verify it's valid JSON by parsing it
330334
var parsed = JsonDocument.Parse(result);
331-
parsed.RootElement.GetProperty("language").GetString().Should().Be("en");
332-
parsed.RootElement.GetProperty("greeting").GetString().Should().Be("Hello, I'm your agent");
335+
parsed.RootElement.GetProperty("experimental").GetBoolean().Should().BeTrue();
333336
parsed.RootElement.GetProperty("mip_opt_out").GetBoolean().Should().BeTrue();
337+
parsed.RootElement.GetProperty("agent").GetProperty("language").GetString().Should().Be("en");
338+
parsed.RootElement.GetProperty("agent").GetProperty("greeting").GetString().Should().Be("Hello, I'm your agent");
334339
}
335340
}
336341

337342
[Test]
338-
public void Agent_MipOptOut_Schema_Should_Match_API_Specification()
343+
public void SettingsSchema_MipOptOut_Schema_Should_Match_API_Specification()
339344
{
340345
// Arrange - Test both default (false) and explicit true values
341-
var agentDefault = new Agent();
342-
var agentOptOut = new Agent { MipOptOut = true };
346+
var settingsDefault = new SettingsSchema();
347+
var settingsOptOut = new SettingsSchema { MipOptOut = true };
343348

344349
// Act
345-
var defaultResult = agentDefault.ToString();
346-
var optOutResult = agentOptOut.ToString();
350+
var defaultResult = settingsDefault.ToString();
351+
var optOutResult = settingsOptOut.ToString();
347352

348353
// Assert
349354
using (new AssertionScope())
@@ -358,5 +363,30 @@ public void Agent_MipOptOut_Schema_Should_Match_API_Specification()
358363
}
359364
}
360365

366+
[Test]
367+
public void Agent_Should_Not_Have_MipOptOut_Property()
368+
{
369+
// Arrange
370+
var agent = new Agent
371+
{
372+
Language = "en",
373+
Greeting = "Hello, I'm your agent"
374+
};
375+
376+
// Act
377+
var result = agent.ToString();
378+
379+
// Assert
380+
using (new AssertionScope())
381+
{
382+
result.Should().NotBeNull();
383+
result.Should().NotContain("mip_opt_out");
384+
385+
// Verify it's valid JSON by parsing it
386+
var parsed = JsonDocument.Parse(result);
387+
parsed.RootElement.TryGetProperty("mip_opt_out", out _).Should().BeFalse();
388+
}
389+
}
390+
361391
#endregion
362392
}

Deepgram/Models/Agent/v2/WebSocket/Agent.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ public record Agent
3232
[JsonPropertyName("greeting")]
3333
public string? Greeting { get; set; }
3434

35-
/// <summary>
36-
/// To opt out of Deepgram Model Improvement Program
37-
/// </summary>
38-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
39-
[JsonPropertyName("mip_opt_out")]
40-
public bool? MipOptOut { get; set; } = false;
41-
4235
/// <summary>
4336
/// Override ToString method to serialize the object
4437
/// </summary>

Deepgram/Models/Agent/v2/WebSocket/Settings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ public class SettingsSchema
2020
[JsonPropertyName("experimental")]
2121
public bool? Experimental { get; set; }
2222

23+
/// <summary>
24+
/// To opt out of Deepgram Model Improvement Program
25+
/// </summary>
26+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
27+
[JsonPropertyName("mip_opt_out")]
28+
public bool? MipOptOut { get; set; } = false;
29+
2330
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2431
[JsonPropertyName("audio")]
2532
public Audio Audio { get; set; } = new Audio();

0 commit comments

Comments
 (0)