Skip to content

Commit

Permalink
feat: error on keyterms when not nova-3
Browse files Browse the repository at this point in the history
  • Loading branch information
naomi-lgbt committed Feb 6, 2025
1 parent 80bd4cd commit 90e95dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Deepgram/Clients/Agent/v2/Websocket/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Deepgram.Models.Agent.v2.WebSocket;
using Common = Deepgram.Models.Common.v2.WebSocket;
using Deepgram.Clients.Interfaces.v2;
using Deepgram.Models.Exceptions.v1;

namespace Deepgram.Clients.Agent.v2.WebSocket;

Expand Down Expand Up @@ -51,6 +52,10 @@ public Client(string? apiKey = null, IDeepgramClientOptions? options = null) : b
public async Task<bool> Connect(SettingsConfigurationSchema options, CancellationTokenSource? cancelToken = null, Dictionary<string, string>? addons = null,
Dictionary<string, string>? headers = null)
{
if (!options.Agent.Listen.Model.StartsWith("nova-3") && options.Agent.Listen.Keyterms?.Count > 0)
{
throw new DeepgramException("Keyterms is only supported in Nova 3 models.");
}
Log.Verbose("AgentWSClient.Connect", "ENTER");
Log.Information("Connect", $"options:\n{JsonSerializer.Serialize(options, JsonSerializeOptions.DefaultOptions)}");
Log.Debug("Connect", $"addons: {addons}");
Expand Down
5 changes: 5 additions & 0 deletions Deepgram/Clients/Listen/v2/WebSocket/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Deepgram.Models.Listen.v2.WebSocket;
using Common = Deepgram.Models.Common.v2.WebSocket;
using Deepgram.Clients.Interfaces.v2;
using Deepgram.Models.Exceptions.v1;

namespace Deepgram.Clients.Listen.v2.WebSocket;

Expand Down Expand Up @@ -49,6 +50,10 @@ public Client(string? apiKey = null, IDeepgramClientOptions? options = null) : b
public async Task<bool> Connect(LiveSchema options, CancellationTokenSource? cancelToken = null, Dictionary<string, string>? addons = null,
Dictionary<string, string>? headers = null)
{
if (!options.Model.StartsWith("nova-3") && options.Keyterms?.Count > 0)
{
throw new DeepgramException("Keyterms is only supported in Nova 3 models.");
}
Log.Verbose("ListenWSClient.Connect", "ENTER");
Log.Information("Connect", $"options:\n{JsonSerializer.Serialize(options, JsonSerializeOptions.DefaultOptions)}");
Log.Debug("Connect", $"addons: {addons}");
Expand Down

0 comments on commit 90e95dd

Please sign in to comment.