From 7aac869d3f12b11e7a3a6a5d0d2ac6fcbf13fffe Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 17:25:41 +0000 Subject: [PATCH 1/9] chore: initialize SDK regeneration branch From 258d2ce7e54386c287adc10f10e4f87897a9e252 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 17:26:27 +0000 Subject: [PATCH 2/9] chore: unfreeze files pending regen --- .fernignore | 66 +- .../com/deepgram/core/ClientOptions.java.bak | 409 ++++ .../ReconnectingWebSocketListener.java.bak | 622 ++++++ .../v1/types/AgentV1AgentAudioDone.java.bak | 83 + .../v1/types/AgentV1ConversationText.java.bak | 317 +++ .../v1/types/AgentV1ForceEndTurn.java.bak | 83 + .../agent/v1/types/AgentV1KeepAlive.java.bak | 83 + .../v1/types/AgentV1ListenUpdated.java.bak | 83 + .../v1/types/AgentV1PromptUpdated.java.bak | 83 + ...ettingsAgentContextListenProvider.java.bak | 224 ++ ...gentV1SettingsAgentListenProvider.java.bak | 224 ++ .../v1/types/AgentV1SettingsApplied.java.bak | 83 + .../v1/types/AgentV1SpeakUpdated.java.bak | 83 + .../v1/types/AgentV1ThinkLiveUpdated.java.bak | 83 + .../v1/types/AgentV1ThinkUpdated.java.bak | 83 + ...AgentV1UpdateListenListenProvider.java.bak | 224 ++ .../types/AgentV1UserStartedSpeaking.java.bak | 83 + .../v1/websocket/V1WebSocketClient.java.bak | 981 +++++++++ .../requests/ListenV1RequestUrl.java.bak | 1932 +++++++++++++++++ ...MediaTranscribeRequestOctetStream.java.bak | 1931 ++++++++++++++++ .../v1/websocket/V1ConnectOptions.java.bak | 1129 ++++++++++ .../v1/websocket/V1WebSocketClient.java.bak | 650 ++++++ .../v2/types/ListenV2CloseStream.java.bak | 83 + .../v2/types/ListenV2ForceEndTurn.java.bak | 83 + .../v2/websocket/V2WebSocketClient.java.bak | 563 +++++ .../v1/websocket/V1WebSocketClient.java.bak | 467 ++++ .../speak/v2/types/SpeakV2Close.java.bak | 83 + .../SpeakV2ConfigureFailureCode.java.bak | 121 ++ .../speak/v2/types/SpeakV2Flush.java.bak | 83 + .../v2/websocket/V2WebSocketClient.java.bak | 630 ++++++ .../com/deepgram/types/DeepgramModel.java.bak | 1081 +++++++++ .../types/DeepgramThinkProvider.java.bak | 248 +++ .../types/DeepgramThinkProviderModel.java.bak | 86 + .../types/ThinkSettingsV1Provider.java.bak | 458 ++++ 34 files changed, 13492 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/deepgram/core/ClientOptions.java.bak create mode 100644 src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/types/DeepgramModel.java.bak create mode 100644 src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak create mode 100644 src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak create mode 100644 src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak diff --git a/.fernignore b/.fernignore index b0b2ff9..38352f8 100644 --- a/.fernignore +++ b/.fernignore @@ -16,7 +16,7 @@ src/main/java/com/deepgram/AsyncDeepgramClientBuilder.java # Fern regen overwrites these with incorrect SDK names and strips the markers. # Fern 4.22.1 closes tracked WebSockets before SDK-owned OkHttp resources; retain that lifecycle behavior while # reapplying only these headers. -src/main/java/com/deepgram/core/ClientOptions.java +src/main/java/com/deepgram/core/ClientOptions.java.bak # Transport abstraction (pluggable transport for SageMaker, etc.) src/main/java/com/deepgram/core/transport/ @@ -30,7 +30,7 @@ src/main/java/com/deepgram/resources/listen/v1/websocket/ListenV1ConfigureFailur # Bug fixes for maxRetries(0) semantics ("connect once, don't retry") and a # configurable connectionTimeoutMs on ReconnectOptions (was hardcoded 4000ms). # Pull this back out once the fixes are upstreamed into the Fern generator. -src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java +src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak # Forward-compat patch: Fern's generated dispatcher routes any unrecognized message # type to the error handler ("Update your SDK version..."), which makes benign new @@ -40,8 +40,8 @@ src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java # NOTE: the listen v2 and speak v2 clients below also carry the streaming query-param patches # (multi-value serialization + the additionalProperties escape hatch) documented lower down — # keep them frozen until those fixes are upstreamed too. -src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java -src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java +src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak +src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak # Streaming query-param patches on the generated WS connect() builders. Two fixes: # (1) Multi-value serialization: array-valued params (listen: keyterm, keywords, replace, search, @@ -55,27 +55,27 @@ src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java # listen v2 and speak v2 clients are frozen above; freeze the listen v1 and speak v1 clients here too # so the fixes survive regen. Re-apply after regen; unfreeze once the generator emits array params as # repeats and serializes additionalProperties on the WS connect path (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java -src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak # Agent V1 forwards raw frames through onMessage(String); suppress generic errors only when a raw # handler is registered, otherwise retain legacy onError delivery for unknown control frames. -src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak # Source and binary compatibility for third-party implementations of generated builder stages. # Generated concrete builders override languageHint; default interface methods preserve existing custom implementations. -src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java -src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java -src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java +src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak +src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak +src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak # Preserve existing AgentV1ConversationText builder implementations after adding conversationalBehavior. -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak # The spec's Deepgram Think/Speak title collision makes Fern use the TTS-shaped Deepgram type for Think. # Restore the distinct Think provider/model types until the spec produces them; retain the Visitor default until Fern does. -src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java -src/main/java/com/deepgram/types/DeepgramThinkProvider.java -src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak +src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak +src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak # Restores the FLUX_RENEE_EN constant that generator 4.18.0 dropped. The voice is live: # POST /v2/speak?model=flux-renee-en returns 200 with valid audio, and the name resolves in the @@ -87,26 +87,26 @@ src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java # changes -- 4.18.0 alone added 25 constants. On the next regen do NOT restore the .bak wholesale: # diff it against the newly generated file, carry forward every new voice, and re-apply only the # FLUX_RENEE_EN touchpoints (constant, Value enum, visit() case, valueOf() case, Visitor method). -src/main/java/com/deepgram/types/DeepgramModel.java +src/main/java/com/deepgram/types/DeepgramModel.java.bak # Manual equals/hashCode contract fix: Fern generates equals() (all instances equal) but no # hashCode() for fields-less message types, violating the Object contract. We add a consistent # hashCode() to each. Unfreeze and drop these patches once the generator emits a matching # equals/hashCode pair for fields-less types (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak # Union default-variant fix (STOPGAP). The agent listen-provider unions declare `version` as an # optional discriminator, so a provider payload without it is valid (and is what 0.7.x emits). Fern @@ -115,13 +115,13 @@ src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # {"provider":null}, silently dropping the caller's provider on the wire. Patched to # defaultImpl = V2Value on each. Guarded by AgentSettingsProviderDefaultTest. Unfreeze and drop once # the generator stops defaulting unions to the empty _UnknownValue (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak # Preserve binary-compatible Visitor implementations from before this generated enum added # CONTROL_COMBINATION_INVALID. The default method routes old visitors through visitUnknown. -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak # Build and project configuration build.gradle diff --git a/src/main/java/com/deepgram/core/ClientOptions.java.bak b/src/main/java/com/deepgram/core/ClientOptions.java.bak new file mode 100644 index 0000000..c3e3eed --- /dev/null +++ b/src/main/java/com/deepgram/core/ClientOptions.java.bak @@ -0,0 +1,409 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final boolean ownsHttpClient; + + private final AtomicBoolean closed; + + private final Set openWebSockets; + + private final int timeout; + + private final int maxRetries; + + private final Optional initialRetryDelayMillis; + + private final Optional maxRetryDelayMillis; + + private final Optional retryJitterFactor; + + private final Optional webSocketFactory; + + private final Optional logging; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + boolean ownsHttpClient, + AtomicBoolean closed, + Set openWebSockets, + int timeout, + int maxRetries, + Optional initialRetryDelayMillis, + Optional maxRetryDelayMillis, + Optional retryJitterFactor, + Optional webSocketFactory, + Optional logging) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.3"); // x-release-please-version + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); + put("X-Fern-SDK-Version", "0.11.3"); // x-release-please-version + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.ownsHttpClient = ownsHttpClient; + this.closed = closed; + this.openWebSockets = openWebSockets; + this.timeout = timeout; + this.maxRetries = maxRetries; + this.initialRetryDelayMillis = initialRetryDelayMillis; + this.maxRetryDelayMillis = maxRetryDelayMillis; + this.retryJitterFactor = retryJitterFactor; + this.webSocketFactory = webSocketFactory; + this.logging = logging; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public int maxRetries() { + return this.maxRetries; + } + + public Optional initialRetryDelayMillis() { + return this.initialRetryDelayMillis; + } + + public Optional maxRetryDelayMillis() { + return this.maxRetryDelayMillis; + } + + public Optional retryJitterFactor() { + return this.retryJitterFactor; + } + + /** + * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's + * dispatcher executor and evicts its connection pool when this client created that + * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the + * caller owns its lifecycle. + *

+ * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later + * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous + * requests may still run. Options derived from this one via + * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either + * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method + * more than once has no further effect. + *

+ * WebSocket clients created from this client that are still connected are disconnected + * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the + * dispatcher goes away. Any WebSocket connect or reconnect attempted afterwards fails with + * an {@code IllegalStateException} explaining that the client has been closed. + */ + public void close() { + if (!this.closed.compareAndSet(false, true)) { + return; + } + for (AutoCloseable webSocket : new ArrayList<>(this.openWebSockets)) { + try { + webSocket.close(); + } catch (Exception e) { + // best effort; keep closing the remaining sockets and the HTTP client + } + } + this.openWebSockets.clear(); + if (!this.ownsHttpClient) { + return; + } + this.httpClient.dispatcher().executorService().shutdown(); + this.httpClient.connectionPool().evictAll(); + } + + /** + * Returns whether {@link #close()} has been called on this client. + */ + public boolean isClosed() { + return this.closed.get(); + } + + /** + * Tracks a connected WebSocket client so that {@link #close()} disconnects it. + * + * @throws IllegalStateException if this client has already been closed + */ + public void registerWebSocket(AutoCloseable webSocket) { + this.openWebSockets.add(webSocket); + if (this.closed.get()) { + this.openWebSockets.remove(webSocket); + throw new IllegalStateException("root client has been closed"); + } + } + + /** + * Stops tracking a WebSocket client that has been disconnected. + */ + public void unregisterWebSocket(AutoCloseable webSocket) { + this.openWebSockets.remove(webSocket); + } + + public Optional webSocketFactory() { + return this.webSocketFactory; + } + + public Optional logging() { + return this.logging; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int maxRetries = 2; + + private Optional initialRetryDelayMillis = Optional.empty(); + + private Optional maxRetryDelayMillis = Optional.empty(); + + private Optional retryJitterFactor = Optional.empty(); + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; + + private boolean ownsHttpClient = true; + + private AtomicBoolean closed; + + private Set openWebSockets; + + private Optional logging = Optional.empty(); + + private Optional webSocketFactory = Optional.empty(); + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + if (value != null) { + this.headers.put(key, value); + } + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { + this.timeout = timeout; + return this; + } + + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + /** + * Override the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. + */ + public Builder initialRetryDelayMillis(long initialRetryDelayMillis) { + this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); + return this; + } + + /** + * Override the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. + */ + public Builder maxRetryDelayMillis(long maxRetryDelayMillis) { + this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); + return this; + } + + /** + * Override the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. + */ + public Builder retryJitterFactor(double retryJitterFactor) { + this.retryJitterFactor = Optional.of(retryJitterFactor); + return this; + } + + /** + * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle: + * close() will not shut down its dispatcher executor or evict its connection pool. + */ + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + this.ownsHttpClient = httpClient == null; + return this; + } + + /** + * Set a custom WebSocketFactory for creating WebSocket connections. + */ + public Builder webSocketFactory(WebSocketFactory webSocketFactory) { + this.webSocketFactory = Optional.of(webSocketFactory); + return this; + } + + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public Builder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + + public ClientOptions build() { + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor( + this.maxRetries, + this.initialRetryDelayMillis, + this.maxRetryDelayMillis, + this.retryJitterFactor)); + } + + Logger logger = Logger.from(this.logging); + httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); + httpClientBuilder.addInterceptor(new ResponseDecompressionInterceptor()); + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + AtomicBoolean closedToUse = this.closed != null ? this.closed : new AtomicBoolean(false); + Set openWebSocketsToUse = + this.openWebSockets != null ? this.openWebSockets : ConcurrentHashMap.newKeySet(); + + return new ClientOptions( + environment, + headers, + headerSuppliers, + httpClient, + this.ownsHttpClient, + closedToUse, + openWebSocketsToUse, + this.timeout.get(), + this.maxRetries, + this.initialRetryDelayMillis, + this.maxRetryDelayMillis, + this.retryJitterFactor, + this.webSocketFactory, + this.logging); + } + + /** + * Create a new Builder initialized with values from an existing ClientOptions + */ + public static Builder from(ClientOptions clientOptions) { + Builder builder = new Builder(); + builder.environment = clientOptions.environment(); + builder.timeout = Optional.of(clientOptions.timeout(null)); + builder.httpClient = clientOptions.httpClient(); + builder.ownsHttpClient = clientOptions.ownsHttpClient; + builder.closed = clientOptions.closed; + builder.openWebSockets = clientOptions.openWebSockets; + builder.headers.putAll(clientOptions.headers); + builder.headerSuppliers.putAll(clientOptions.headerSuppliers); + builder.maxRetries = clientOptions.maxRetries(); + builder.initialRetryDelayMillis = clientOptions.initialRetryDelayMillis(); + builder.maxRetryDelayMillis = clientOptions.maxRetryDelayMillis(); + builder.retryJitterFactor = clientOptions.retryJitterFactor(); + builder.logging = clientOptions.logging(); + return builder; + } + } +} diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak new file mode 100644 index 0000000..b51aacc --- /dev/null +++ b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak @@ -0,0 +1,622 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.core; + +import static java.util.concurrent.TimeUnit.*; + +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; +import java.util.function.Supplier; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import okio.ByteString; + +/** + * WebSocketListener with automatic reconnection, exponential backoff, and message queuing. + * Provides production-ready resilience for WebSocket connections. + */ +public abstract class ReconnectingWebSocketListener extends WebSocketListener { + private volatile ReconnectOptions activeOptions; + + private final int maxEnqueuedMessages; + + private final AtomicInteger retryCount = new AtomicInteger(0); + + private final AtomicBoolean connectLock = new AtomicBoolean(false); + + private final AtomicBoolean shouldReconnect = new AtomicBoolean(true); + + protected volatile WebSocket webSocket; + + private volatile long connectionEstablishedTime = 0L; + + private final ConcurrentLinkedQueue messageQueue = new ConcurrentLinkedQueue<>(); + + private final ConcurrentLinkedQueue binaryMessageQueue = new ConcurrentLinkedQueue<>(); + + private final ScheduledExecutorService reconnectExecutor = Executors.newSingleThreadScheduledExecutor(); + + private final Supplier connectionSupplier; + + private final BooleanSupplier closedCheck; + + /** + * Creates a new reconnecting WebSocket listener. + * + * @param options Reconnection configuration options + * @param connectionSupplier Supplier that creates new WebSocket connections + */ + public ReconnectingWebSocketListener( + ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier) { + this(options, connectionSupplier, () -> false); + } + + /** + * Creates a new reconnecting WebSocket listener. + * + * @param options Reconnection configuration options + * @param connectionSupplier Supplier that creates new WebSocket connections + * @param closedCheck Returns true once the owning client has been closed; connect and + * reconnect attempts made after that point fail with an {@link IllegalStateException} + * instead of being retried + */ + public ReconnectingWebSocketListener( + ReconnectingWebSocketListener.ReconnectOptions options, + Supplier connectionSupplier, + BooleanSupplier closedCheck) { + this.activeOptions = options; + this.maxEnqueuedMessages = options.maxEnqueuedMessages; + this.connectionSupplier = connectionSupplier; + this.closedCheck = closedCheck; + } + + /** + * Replaces option-derived reconnect settings without rebuilding generated clients. + * + * @param options replacement options; {@code null} is a no-op + */ + public void applyOptionsOverride(ReconnectOptions options) { + if (options != null) { + this.activeOptions = options; + } + } + + /** + * Initiates a WebSocket connection with automatic reconnection enabled. + * + * Connection behavior: + * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) + * - Thread-safe via atomic lock (returns immediately if connection in progress) + * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry + * + * Error handling: + * - TimeoutException: Includes retry attempt context + * - InterruptedException: Preserves thread interruption status + * - ExecutionException: Extracts actual cause and adds context + * - Owning client closed: reports an IllegalStateException once and stops reconnecting + */ + public void connect() { + if (!connectLock.compareAndSet(false, true)) { + return; + } + if (closedCheck.getAsBoolean()) { + shouldReconnect.set(false); + connectLock.set(false); + onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); + return; + } + ReconnectOptions options = this.activeOptions; + if (retryCount.get() > options.maxRetries) { + connectLock.set(false); + return; + } + try { + CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); + try { + webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); + } catch (TimeoutException e) { + connectionFuture.cancel(true); + TimeoutException timeoutError = + new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs + + " milliseconds" + + (retryCount.get() > 0 + ? " (retry attempt #" + retryCount.get() + ")" + : " (initial connection attempt)")); + onWebSocketFailure(null, timeoutError, null); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } catch (InterruptedException e) { + connectionFuture.cancel(true); + Thread.currentThread().interrupt(); + InterruptedException interruptError = new InterruptedException("WebSocket connection interrupted" + + (retryCount.get() > 0 + ? " during retry attempt #" + retryCount.get() + : " during initial connection")); + interruptError.initCause(e); + onWebSocketFailure(null, interruptError, null); + } catch (ExecutionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + String context = retryCount.get() > 0 + ? "WebSocket connection failed during retry attempt #" + retryCount.get() + : "WebSocket connection failed during initial attempt"; + RuntimeException wrappedException = new RuntimeException( + context + ": " + cause.getClass().getSimpleName() + ": " + cause.getMessage()); + wrappedException.initCause(cause); + onWebSocketFailure(null, wrappedException, null); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } + } finally { + connectLock.set(false); + } + } + + /** + * Disconnects the WebSocket and disables automatic reconnection. + * + * This method: + * - Disables automatic reconnection + * - Clears queued messages to prevent stale data + * - Closes the WebSocket with standard close code 1000 + * - Properly shuts down the reconnect executor to prevent thread leaks + * - Waits up to 5 seconds for executor termination + */ + public void disconnect() { + shouldReconnect.set(false); + messageQueue.clear(); + binaryMessageQueue.clear(); + if (webSocket != null) { + webSocket.close(1000, "Client disconnecting"); + } + reconnectExecutor.shutdown(); + try { + if (!reconnectExecutor.awaitTermination(5, SECONDS)) { + reconnectExecutor.shutdownNow(); + } + } catch (InterruptedException e) { + reconnectExecutor.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + + /** + * Sends a message or queues it if not connected. + * + * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). + * + * Behavior: + * - If connected: Attempts direct send, queues if buffer full + * - If disconnected: Queues message up to maxEnqueuedMessages limit + * - If queue full: Message is dropped + * + * @param message The message to send + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean send(String message) { + return send(message, null); + } + + /** + * Sends a message or queues it if not connected, exposing the accepting socket. + * + * Behaves like {@link #send(String)}, but additionally invokes {@code onSent} with the + * WebSocket that accepted the message. The callback is only invoked when the message was + * sent directly, never when it was queued or dropped. This lets callers associate a + * protocol-level message with the specific connection it was delivered on, e.g. to decide + * in {@link #shouldReconnectAfterClose(WebSocket, int, String)} whether a later close of that same + * connection was expected. + * + * @param message The message to send + * @param onSent Callback receiving the WebSocket that accepted the message, or null + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean send(String message, Consumer onSent) { + WebSocket ws = webSocket; + if (ws != null) { + boolean sent = ws.send(message); + if (sent && onSent != null) { + onSent.accept(ws); + } + if (!sent && messageQueue.size() < maxEnqueuedMessages) { + messageQueue.offer(message); + return false; + } + return sent; + } else { + if (messageQueue.size() < maxEnqueuedMessages) { + messageQueue.offer(message); + return false; + } + return false; + } + } + + /** + * Sends binary data or queues it if not connected. + * + * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). + * + * Behavior: + * - If connected: Attempts direct send, queues if buffer full + * - If disconnected: Queues data up to maxEnqueuedMessages limit + * - If queue full: Data is dropped + * + * @param data The binary data to send + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean sendBinary(ByteString data) { + return sendBinary(data, null); + } + + /** + * Sends binary data or queues it if not connected, exposing the accepting socket. + * + * Behaves like {@link #sendBinary(ByteString)}, but additionally invokes {@code onSent} with + * the WebSocket that accepted the data. The callback is only invoked when the data was sent + * directly, never when it was queued or dropped. + * + * @param data The binary data to send + * @param onSent Callback receiving the WebSocket that accepted the data, or null + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean sendBinary(ByteString data, Consumer onSent) { + WebSocket ws = webSocket; + if (ws != null) { + boolean sent = ws.send(data); + if (sent && onSent != null) { + onSent.accept(ws); + } + if (!sent && binaryMessageQueue.size() < maxEnqueuedMessages) { + binaryMessageQueue.offer(data); + return false; + } + return sent; + } else { + if (binaryMessageQueue.size() < maxEnqueuedMessages) { + binaryMessageQueue.offer(data); + return false; + } + return false; + } + } + + /** + * Gets the current WebSocket instance. + * Thread-safe method to access the WebSocket connection. + * @return the WebSocket or null if not connected + */ + public WebSocket getWebSocket() { + return webSocket; + } + + /** + * @hidden + */ + @Override + public void onOpen(WebSocket webSocket, Response response) { + this.webSocket = webSocket; + connectionEstablishedTime = System.currentTimeMillis(); + retryCount.set(0); + flushMessageQueue(); + onWebSocketOpen(webSocket, response); + } + + @Override + public void onMessage(WebSocket webSocket, String text) { + onWebSocketMessage(webSocket, text); + } + + @Override + public void onMessage(WebSocket webSocket, ByteString bytes) { + onWebSocketBinaryMessage(webSocket, bytes); + } + + /** + * @hidden + */ + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + this.webSocket = null; + long uptime = 0L; + if (connectionEstablishedTime > 0) { + uptime = System.currentTimeMillis() - connectionEstablishedTime; + if (uptime >= 5000) { + retryCount.set(0); + } + } + connectionEstablishedTime = 0L; + Throwable enhancedError = t; + if (t != null) { + String errorContext = "WebSocket connection failed"; + if (uptime > 0) { + errorContext += " after " + (uptime / 1000) + " seconds"; + } + if (response != null) { + errorContext += " with HTTP " + response.code() + " " + response.message(); + } + enhancedError = + new RuntimeException(errorContext + ": " + t.getClass().getSimpleName() + ": " + t.getMessage()); + enhancedError.initCause(t); + } + onWebSocketFailure(webSocket, enhancedError, response); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } + + /** + * Acknowledges a peer-initiated close so OkHttp can complete the close handshake and + * invoke {@link #onClosed(WebSocket, int, String)}. + * + * Code 1005 is a local "no status received" sentinel reported when the peer sent an empty + * close frame. It is not a valid code to put on the wire, so it is acknowledged with + * the normal closure code 1000 instead. + * + * @hidden + */ + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + webSocket.close(code == 1005 ? 1000 : code, reason); + } + + /** + * @hidden + */ + @Override + public void onClosed(WebSocket webSocket, int code, String reason) { + this.webSocket = null; + if (connectionEstablishedTime > 0) { + long uptime = System.currentTimeMillis() - connectionEstablishedTime; + if (uptime >= 5000) { + retryCount.set(0); + } + } + connectionEstablishedTime = 0L; + onWebSocketClosed(webSocket, code, reason); + if (shouldReconnect.get() && shouldReconnectAfterClose(webSocket, code, reason)) { + scheduleReconnect(); + } + } + + /** + * Decides whether a completed close handshake should trigger a reconnect. + * + * Only consulted when reconnection has not been disabled via {@link #disconnect()}. + * The default treats normal closure (1000) as terminal and reconnects on any + * other code. Subclasses can override this when protocol context establishes that a + * particular close is terminal, for example a no-status close following a message that + * ends the stream. + * + * @param webSocket The WebSocket that was closed + * @param code The close status code reported by OkHttp + * @param reason The close reason sent by the peer, or an empty string + * @return true to schedule a reconnect, false to stay disconnected + */ + protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { + return code != 1000; + } + + /** + * Calculates the next reconnection delay using exponential backoff. + * + * Uses 0-based retry count where: + * - 0 = initial connection (not used by this method) + * - 1 = first retry (returns minReconnectionDelayMs) + * - 2+ = exponential backoff up to maxReconnectionDelayMs + */ + private long getNextDelay() { + if (retryCount.get() == 1) { + return activeOptions.minReconnectionDelayMs; + } + ReconnectOptions options = this.activeOptions; + long delay = (long) + (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); + return Math.min(delay, options.maxReconnectionDelayMs); + } + + /** + * Schedules a reconnection attempt with appropriate delay. + * Increments retry count and uses exponential backoff. + * Does nothing once the owning client has been closed. + */ + private void scheduleReconnect() { + if (closedCheck.getAsBoolean()) { + shouldReconnect.set(false); + return; + } + retryCount.incrementAndGet(); + long delay = getNextDelay(); + reconnectExecutor.schedule(this::connect, delay, MILLISECONDS); + } + + /** + * Sends all queued messages after reconnection. + * + * Thread-safe: Synchronized to prevent race conditions with send() method. + * + * Algorithm: + * 1. Drains queue into temporary list to avoid holding lock during sends + * 2. Attempts to send each message in order + * 3. If any send fails, re-queues that message and all subsequent messages + * 4. Preserves message ordering during re-queueing + * 5. Repeats for binary message queue + */ + private synchronized void flushMessageQueue() { + WebSocket ws = webSocket; + if (ws != null) { + ArrayList tempQueue = new ArrayList<>(); + String message; + while ((message = messageQueue.poll()) != null) { + tempQueue.add(message); + } + for (int i = 0; i < tempQueue.size(); i++) { + if (!ws.send(tempQueue.get(i))) { + for (int j = i; j < tempQueue.size(); j++) { + messageQueue.offer(tempQueue.get(j)); + } + break; + } + } + ArrayList tempBinaryQueue = new ArrayList<>(); + ByteString binaryMsg; + while ((binaryMsg = binaryMessageQueue.poll()) != null) { + tempBinaryQueue.add(binaryMsg); + } + for (int i = 0; i < tempBinaryQueue.size(); i++) { + if (!ws.send(tempBinaryQueue.get(i))) { + for (int j = i; j < tempBinaryQueue.size(); j++) { + binaryMessageQueue.offer(tempBinaryQueue.get(j)); + } + break; + } + } + } + } + + protected abstract void onWebSocketOpen(WebSocket webSocket, Response response); + + protected abstract void onWebSocketMessage(WebSocket webSocket, String text); + + protected abstract void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes); + + protected abstract void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response); + + protected abstract void onWebSocketClosed(WebSocket webSocket, int code, String reason); + + /** + * Configuration options for automatic reconnection. + */ + public static final class ReconnectOptions { + public final long minReconnectionDelayMs; + + public final long maxReconnectionDelayMs; + + public final double reconnectionDelayGrowFactor; + + public final int maxRetries; + + public final int maxEnqueuedMessages; + + public final long connectionTimeoutMs; + + private ReconnectOptions(Builder builder) { + this.minReconnectionDelayMs = builder.minReconnectionDelayMs; + this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; + this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; + this.maxRetries = builder.maxRetries; + this.maxEnqueuedMessages = builder.maxEnqueuedMessages; + this.connectionTimeoutMs = builder.connectionTimeoutMs; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private long minReconnectionDelayMs; + + private long maxReconnectionDelayMs; + + private double reconnectionDelayGrowFactor; + + private int maxRetries; + + private int maxEnqueuedMessages; + + private long connectionTimeoutMs; + + public Builder() { + this.minReconnectionDelayMs = 1000; + this.maxReconnectionDelayMs = 10000; + this.reconnectionDelayGrowFactor = 1.3; + this.maxRetries = 2147483647; + this.maxEnqueuedMessages = 1000; + this.connectionTimeoutMs = 4000; + } + + public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { + this.minReconnectionDelayMs = minReconnectionDelayMs; + return this; + } + + public Builder maxReconnectionDelayMs(long maxReconnectionDelayMs) { + this.maxReconnectionDelayMs = maxReconnectionDelayMs; + return this; + } + + public Builder reconnectionDelayGrowFactor(double reconnectionDelayGrowFactor) { + this.reconnectionDelayGrowFactor = reconnectionDelayGrowFactor; + return this; + } + + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { + this.maxEnqueuedMessages = maxEnqueuedMessages; + return this; + } + + /** + * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. + */ + public Builder connectionTimeoutMs(long connectionTimeoutMs) { + this.connectionTimeoutMs = connectionTimeoutMs; + return this; + } + + /** + * Builds the ReconnectOptions with validation. + * + * Validates that: + * - All delay values are positive + * - minReconnectionDelayMs <= maxReconnectionDelayMs + * - reconnectionDelayGrowFactor >= 1.0 + * - maxRetries and maxEnqueuedMessages are non-negative + * + * @return The validated ReconnectOptions instance + * @throws IllegalArgumentException if configuration is invalid + */ + public ReconnectOptions build() { + if (minReconnectionDelayMs <= 0) { + throw new IllegalArgumentException("minReconnectionDelayMs must be positive"); + } + if (maxReconnectionDelayMs <= 0) { + throw new IllegalArgumentException("maxReconnectionDelayMs must be positive"); + } + if (minReconnectionDelayMs > maxReconnectionDelayMs) { + throw new IllegalArgumentException("minReconnectionDelayMs (" + minReconnectionDelayMs + + ") must not exceed maxReconnectionDelayMs (" + maxReconnectionDelayMs + ")"); + } + if (reconnectionDelayGrowFactor < 1.0) { + throw new IllegalArgumentException("reconnectionDelayGrowFactor must be >= 1.0"); + } + if (maxRetries < 0) { + throw new IllegalArgumentException("maxRetries must be non-negative"); + } + if (maxEnqueuedMessages < 0) { + throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); + } + if (connectionTimeoutMs <= 0) { + throw new IllegalArgumentException("connectionTimeoutMs must be positive"); + } + return new ReconnectOptions(this); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak new file mode 100644 index 0000000..5962f4b --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1AgentAudioDone.Builder.class) +public final class AgentV1AgentAudioDone { + private final Map additionalProperties; + + private AgentV1AgentAudioDone(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier indicating the agent has finished sending audio + */ + @JsonProperty("type") + public String getType() { + return "AgentAudioDone"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1AgentAudioDone; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1AgentAudioDone other) { + return this; + } + + public AgentV1AgentAudioDone build() { + return new AgentV1AgentAudioDone(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak new file mode 100644 index 0000000..ef4f56a --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak @@ -0,0 +1,317 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ConversationText.Builder.class) +public final class AgentV1ConversationText { + private final AgentV1ConversationTextRole role; + + private final String content; + + private final AgentV1ConversationTextConversationalBehavior conversationalBehavior; + + private final Optional> languagesHinted; + + private final Optional> languages; + + private final Map additionalProperties; + + private AgentV1ConversationText( + AgentV1ConversationTextRole role, + String content, + AgentV1ConversationTextConversationalBehavior conversationalBehavior, + Optional> languagesHinted, + Optional> languages, + Map additionalProperties) { + this.role = role; + this.content = content; + this.conversationalBehavior = conversationalBehavior; + this.languagesHinted = languagesHinted; + this.languages = languages; + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for conversation text + */ + @JsonProperty("type") + public String getType() { + return "ConversationText"; + } + + /** + * @return Identifies who spoke the statement + */ + @JsonProperty("role") + public AgentV1ConversationTextRole getRole() { + return role; + } + + /** + * @return The actual statement that was spoken + */ + @JsonProperty("content") + public String getContent() { + return content; + } + + /** + * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off + */ + @JsonProperty("conversational_behavior") + public Optional getConversationalBehavior() { + return Optional.of(conversationalBehavior); + } + + /** + * @return The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi. + */ + @JsonProperty("languages_hinted") + public Optional> getLanguagesHinted() { + return languagesHinted; + } + + /** + * @return Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi. + */ + @JsonProperty("languages") + public Optional> getLanguages() { + return languages; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ConversationText && equalTo((AgentV1ConversationText) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AgentV1ConversationText other) { + return role.equals(other.role) + && content.equals(other.content) + && conversationalBehavior.equals(other.conversationalBehavior) + && languagesHinted.equals(other.languagesHinted) + && languages.equals(other.languages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.role, this.content, this.conversationalBehavior, this.languagesHinted, this.languages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static RoleStage builder() { + return new Builder(); + } + + public interface RoleStage { + /** + *

Identifies who spoke the statement

+ */ + ContentStage role(@NotNull AgentV1ConversationTextRole role); + + Builder from(AgentV1ConversationText other); + } + + public interface ContentStage { + /** + *

The actual statement that was spoken

+ */ + _FinalStage content(@NotNull String content); + } + + public interface ConversationalBehaviorStage { + /** + *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

+ */ + _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior); + } + + public interface _FinalStage { + AgentV1ConversationText build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + default _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { + return this; + } + + default _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ */ + _FinalStage languagesHinted(Optional> languagesHinted); + + _FinalStage languagesHinted(List languagesHinted); + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ */ + _FinalStage languages(Optional> languages); + + _FinalStage languages(List languages); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements RoleStage, ContentStage, ConversationalBehaviorStage, _FinalStage { + private AgentV1ConversationTextRole role; + + private String content; + + private AgentV1ConversationTextConversationalBehavior conversationalBehavior = + AgentV1ConversationTextConversationalBehavior.DEFAULT; + + private Optional> languages = Optional.empty(); + + private Optional> languagesHinted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AgentV1ConversationText other) { + role(other.getRole()); + content(other.getContent()); + conversationalBehavior(other.getConversationalBehavior()); + languagesHinted(other.getLanguagesHinted()); + languages(other.getLanguages()); + return this; + } + + /** + *

Identifies who spoke the statement

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("role") + public ContentStage role(@NotNull AgentV1ConversationTextRole role) { + this.role = Objects.requireNonNull(role, "role must not be null"); + return this; + } + + /** + *

The actual statement that was spoken

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("content") + public _FinalStage content(@NotNull String content) { + this.content = Objects.requireNonNull(content, "content must not be null"); + return this; + } + + /** + *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) + public _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { + this.conversationalBehavior = + Objects.requireNonNull(conversationalBehavior, "conversationalBehavior must not be null"); + return this; + } + + public _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + this.conversationalBehavior = conversationalBehavior.orElse( + AgentV1ConversationTextConversationalBehavior.DEFAULT); + return this; + } + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languages(List languages) { + this.languages = Optional.ofNullable(languages); + return this; + } + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ */ + @java.lang.Override + @JsonSetter(value = "languages", nulls = Nulls.SKIP) + public _FinalStage languages(Optional> languages) { + this.languages = languages; + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languagesHinted(List languagesHinted) { + this.languagesHinted = Optional.ofNullable(languagesHinted); + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ */ + @java.lang.Override + @JsonSetter(value = "languages_hinted", nulls = Nulls.SKIP) + public _FinalStage languagesHinted(Optional> languagesHinted) { + this.languagesHinted = languagesHinted; + return this; + } + + @java.lang.Override + public AgentV1ConversationText build() { + return new AgentV1ConversationText( + role, content, conversationalBehavior, languagesHinted, languages, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak new file mode 100644 index 0000000..9bd5f76 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ForceEndTurn.Builder.class) +public final class AgentV1ForceEndTurn { + private final Map additionalProperties; + + private AgentV1ForceEndTurn(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for forcing the end of the current turn + */ + @JsonProperty("type") + public String getType() { + return "ForceEndTurn"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ForceEndTurn; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ForceEndTurn other) { + return this; + } + + public AgentV1ForceEndTurn build() { + return new AgentV1ForceEndTurn(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak new file mode 100644 index 0000000..f82f59e --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1KeepAlive.Builder.class) +public final class AgentV1KeepAlive { + private final Map additionalProperties; + + private AgentV1KeepAlive(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "KeepAlive"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1KeepAlive; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1KeepAlive other) { + return this; + } + + public AgentV1KeepAlive build() { + return new AgentV1KeepAlive(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak new file mode 100644 index 0000000..43b8628 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ListenUpdated.Builder.class) +public final class AgentV1ListenUpdated { + private final Map additionalProperties; + + private AgentV1ListenUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for listen update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ListenUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ListenUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ListenUpdated other) { + return this; + } + + public AgentV1ListenUpdated build() { + return new AgentV1ListenUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak new file mode 100644 index 0000000..e6efced --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1PromptUpdated.Builder.class) +public final class AgentV1PromptUpdated { + private final Map additionalProperties; + + private AgentV1PromptUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for prompt update confirmation + */ + @JsonProperty("type") + public String getType() { + return "PromptUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1PromptUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1PromptUpdated other) { + return this; + } + + public AgentV1PromptUpdated build() { + return new AgentV1PromptUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak new file mode 100644 index 0000000..393f1f9 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1SettingsAgentContextListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1SettingsAgentContextListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1SettingsAgentContextListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1SettingsAgentContextListenProvider(new V1Value(value)); + } + + public static AgentV1SettingsAgentContextListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1SettingsAgentContextListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsAgentContextListenProvider + && value.equals(((AgentV1SettingsAgentContextListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak new file mode 100644 index 0000000..345ba2f --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1SettingsAgentListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1SettingsAgentListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1SettingsAgentListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1SettingsAgentListenProvider(new V1Value(value)); + } + + public static AgentV1SettingsAgentListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1SettingsAgentListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsAgentListenProvider + && value.equals(((AgentV1SettingsAgentListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak new file mode 100644 index 0000000..ad1fdb2 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1SettingsApplied.Builder.class) +public final class AgentV1SettingsApplied { + private final Map additionalProperties; + + private AgentV1SettingsApplied(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for settings applied confirmation + */ + @JsonProperty("type") + public String getType() { + return "SettingsApplied"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsApplied; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1SettingsApplied other) { + return this; + } + + public AgentV1SettingsApplied build() { + return new AgentV1SettingsApplied(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak new file mode 100644 index 0000000..8b134b5 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1SpeakUpdated.Builder.class) +public final class AgentV1SpeakUpdated { + private final Map additionalProperties; + + private AgentV1SpeakUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for speak update confirmation + */ + @JsonProperty("type") + public String getType() { + return "SpeakUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SpeakUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1SpeakUpdated other) { + return this; + } + + public AgentV1SpeakUpdated build() { + return new AgentV1SpeakUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak new file mode 100644 index 0000000..98eaf74 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ThinkLiveUpdated.Builder.class) +public final class AgentV1ThinkLiveUpdated { + private final Map additionalProperties; + + private AgentV1ThinkLiveUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for Think Live model update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ThinkLiveUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ThinkLiveUpdated; + } + + @java.lang.Override + public int hashCode() { + return 1; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ThinkLiveUpdated other) { + return this; + } + + public AgentV1ThinkLiveUpdated build() { + return new AgentV1ThinkLiveUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak new file mode 100644 index 0000000..2d67cad --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ThinkUpdated.Builder.class) +public final class AgentV1ThinkUpdated { + private final Map additionalProperties; + + private AgentV1ThinkUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for think update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ThinkUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ThinkUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ThinkUpdated other) { + return this; + } + + public AgentV1ThinkUpdated build() { + return new AgentV1ThinkUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak new file mode 100644 index 0000000..e739aec --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1UpdateListenListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1UpdateListenListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1UpdateListenListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1UpdateListenListenProvider(new V1Value(value)); + } + + public static AgentV1UpdateListenListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1UpdateListenListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1UpdateListenListenProvider + && value.equals(((AgentV1UpdateListenListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak new file mode 100644 index 0000000..3556d31 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1UserStartedSpeaking.Builder.class) +public final class AgentV1UserStartedSpeaking { + private final Map additionalProperties; + + private AgentV1UserStartedSpeaking(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier indicating that the user has begun speaking + */ + @JsonProperty("type") + public String getType() { + return "UserStartedSpeaking"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1UserStartedSpeaking; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1UserStartedSpeaking other) { + return this; + } + + public AgentV1UserStartedSpeaking build() { + return new AgentV1UserStartedSpeaking(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..b648a3e --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,981 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.agent.v1.types.AgentV1AgentAudioDone; +import com.deepgram.resources.agent.v1.types.AgentV1AgentStartedSpeaking; +import com.deepgram.resources.agent.v1.types.AgentV1AgentThinking; +import com.deepgram.resources.agent.v1.types.AgentV1ConversationText; +import com.deepgram.resources.agent.v1.types.AgentV1CustomFromThinkProvider; +import com.deepgram.resources.agent.v1.types.AgentV1CustomToThinkProvider; +import com.deepgram.resources.agent.v1.types.AgentV1Error; +import com.deepgram.resources.agent.v1.types.AgentV1ForceEndTurn; +import com.deepgram.resources.agent.v1.types.AgentV1FrustrationDetected; +import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallCancelled; +import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallRequest; +import com.deepgram.resources.agent.v1.types.AgentV1History; +import com.deepgram.resources.agent.v1.types.AgentV1InjectAgentMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectDynamicAgentMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectUserMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectionRefused; +import com.deepgram.resources.agent.v1.types.AgentV1KeepAlive; +import com.deepgram.resources.agent.v1.types.AgentV1LatencyReport; +import com.deepgram.resources.agent.v1.types.AgentV1ListenUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1PromptUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ReceiveFunctionCallResponse; +import com.deepgram.resources.agent.v1.types.AgentV1SendFunctionCallResponse; +import com.deepgram.resources.agent.v1.types.AgentV1Settings; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsApplied; +import com.deepgram.resources.agent.v1.types.AgentV1SpeakUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ThinkLiveUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ThinkUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateListen; +import com.deepgram.resources.agent.v1.types.AgentV1UpdatePrompt; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateSpeak; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateThink; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateThinkLive; +import com.deepgram.resources.agent.v1.types.AgentV1UserStartedSpeaking; +import com.deepgram.resources.agent.v1.types.AgentV1Warning; +import com.deepgram.resources.agent.v1.types.AgentV1Welcome; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer listenUpdatedHandler; + + private volatile Consumer thinkUpdatedHandler; + + private volatile Consumer thinkLiveUpdatedHandler; + + private volatile Consumer frustrationDetectedHandler; + + private volatile Consumer onFunctionCallResponseHandler; + + private volatile Consumer promptUpdatedHandler; + + private volatile Consumer speakUpdatedHandler; + + private volatile Consumer injectionRefusedHandler; + + private volatile Consumer welcomeHandler; + + private volatile Consumer settingsAppliedHandler; + + private volatile Consumer conversationTextHandler; + + private volatile Consumer userStartedSpeakingHandler; + + private volatile Consumer agentThinkingHandler; + + private volatile Consumer latencyReportHandler; + + private volatile Consumer functionCallRequestHandler; + + private volatile Consumer functionCallCancelledHandler; + + private volatile Consumer agentStartedSpeakingHandler; + + private volatile Consumer agentAudioDoneHandler; + + private volatile Consumer customFromThinkProviderHandler; + + private volatile Consumer errorHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer agentV1HistoryHandler; + + private volatile Consumer agentV1AudioHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + */ + public CompletableFuture connect() { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getAgentURL(); + String fullPath = "/v1/agent/converse"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (agentV1AudioHandler != null) { + agentV1AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends an AgentV1Settings message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendSettings(AgentV1Settings message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateListen message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateListen(AgentV1UpdateListen message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateThink message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateThink(AgentV1UpdateThink message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateThinkLive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateThinkLive(AgentV1UpdateThinkLive message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateSpeak message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateSpeak(AgentV1UpdateSpeak message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectUserMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectUserMessage(AgentV1InjectUserMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectAgentMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectAgentMessage(AgentV1InjectAgentMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectDynamicAgentMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectDynamicAgentMessage(AgentV1InjectDynamicAgentMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1SendFunctionCallResponse message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFunctionCallResponse(AgentV1SendFunctionCallResponse message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1KeepAlive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendKeepAlive(AgentV1KeepAlive message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdatePrompt message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdatePrompt(AgentV1UpdatePrompt message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1ForceEndTurn message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendForceEndTurn(AgentV1ForceEndTurn message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1CustomToThinkProvider message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCustomToThinkProvider(AgentV1CustomToThinkProvider message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Registers a handler for AgentV1ListenUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onListenUpdated(Consumer handler) { + this.listenUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1ThinkUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onThinkUpdated(Consumer handler) { + this.thinkUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1ThinkLiveUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onThinkLiveUpdated(Consumer handler) { + this.thinkLiveUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1FrustrationDetected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFrustrationDetected(Consumer handler) { + this.frustrationDetectedHandler = handler; + } + + /** + * Registers a handler for AgentV1ReceiveFunctionCallResponse messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallResponse(Consumer handler) { + this.onFunctionCallResponseHandler = handler; + } + + /** + * Registers a handler for AgentV1PromptUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onPromptUpdated(Consumer handler) { + this.promptUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1SpeakUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakUpdated(Consumer handler) { + this.speakUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1InjectionRefused messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onInjectionRefused(Consumer handler) { + this.injectionRefusedHandler = handler; + } + + /** + * Registers a handler for AgentV1Welcome messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWelcome(Consumer handler) { + this.welcomeHandler = handler; + } + + /** + * Registers a handler for AgentV1SettingsApplied messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSettingsApplied(Consumer handler) { + this.settingsAppliedHandler = handler; + } + + /** + * Registers a handler for AgentV1ConversationText messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConversationText(Consumer handler) { + this.conversationTextHandler = handler; + } + + /** + * Registers a handler for AgentV1UserStartedSpeaking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onUserStartedSpeaking(Consumer handler) { + this.userStartedSpeakingHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentThinking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentThinking(Consumer handler) { + this.agentThinkingHandler = handler; + } + + /** + * Registers a handler for AgentV1LatencyReport messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onLatencyReport(Consumer handler) { + this.latencyReportHandler = handler; + } + + /** + * Registers a handler for AgentV1FunctionCallRequest messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallRequest(Consumer handler) { + this.functionCallRequestHandler = handler; + } + + /** + * Registers a handler for AgentV1FunctionCallCancelled messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallCancelled(Consumer handler) { + this.functionCallCancelledHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentStartedSpeaking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentStartedSpeaking(Consumer handler) { + this.agentStartedSpeakingHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentAudioDone messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentAudioDone(Consumer handler) { + this.agentAudioDoneHandler = handler; + } + + /** + * Registers a handler for AgentV1CustomFromThinkProvider messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onCustomFromThinkProvider(Consumer handler) { + this.customFromThinkProviderHandler = handler; + } + + /** + * Registers a handler for AgentV1Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler for AgentV1Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for AgentV1History messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentV1History(Consumer handler) { + this.agentV1HistoryHandler = handler; + } + + /** + * Registers a handler for AgentV1Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentV1Audio(Consumer handler) { + this.agentV1AudioHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { + AgentV1ConversationText conversationTextHandlerEvent = null; + try { + conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); + } catch (Exception e) { + } + if (conversationTextHandlerEvent != null) { + if (conversationTextHandler != null) { + conversationTextHandler.accept(conversationTextHandlerEvent); + } + return; + } + } + if (node.has("total_latency") + && node.has("tts_latency") + && node.has("ttt_latency") + && "AgentStartedSpeaking".equals(node.path("type").asText())) { + AgentV1AgentStartedSpeaking agentStartedSpeakingHandlerEvent = null; + try { + agentStartedSpeakingHandlerEvent = + objectMapper.treeToValue(node, AgentV1AgentStartedSpeaking.class); + } catch (Exception e) { + } + if (agentStartedSpeakingHandlerEvent != null) { + if (agentStartedSpeakingHandler != null) { + agentStartedSpeakingHandler.accept(agentStartedSpeakingHandlerEvent); + } + return; + } + } + if (node.has("count") + && node.has("escalated") + && "FrustrationDetected".equals(node.path("type").asText())) { + AgentV1FrustrationDetected frustrationDetectedHandlerEvent = null; + try { + frustrationDetectedHandlerEvent = objectMapper.treeToValue(node, AgentV1FrustrationDetected.class); + } catch (Exception e) { + } + if (frustrationDetectedHandlerEvent != null) { + if (frustrationDetectedHandler != null) { + frustrationDetectedHandler.accept(frustrationDetectedHandlerEvent); + } + return; + } + } + if (node.has("name") + && node.has("content") + && "FunctionCallResponse".equals(node.path("type").asText())) { + AgentV1ReceiveFunctionCallResponse onFunctionCallResponseHandlerEvent = null; + try { + onFunctionCallResponseHandlerEvent = + objectMapper.treeToValue(node, AgentV1ReceiveFunctionCallResponse.class); + } catch (Exception e) { + } + if (onFunctionCallResponseHandlerEvent != null) { + if (onFunctionCallResponseHandler != null) { + onFunctionCallResponseHandler.accept(onFunctionCallResponseHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Error".equals(node.path("type").asText())) { + AgentV1Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, AgentV1Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Warning".equals(node.path("type").asText())) { + AgentV1Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, AgentV1Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("message") + && "InjectionRefused".equals(node.path("type").asText())) { + AgentV1InjectionRefused injectionRefusedHandlerEvent = null; + try { + injectionRefusedHandlerEvent = objectMapper.treeToValue(node, AgentV1InjectionRefused.class); + } catch (Exception e) { + } + if (injectionRefusedHandlerEvent != null) { + if (injectionRefusedHandler != null) { + injectionRefusedHandler.accept(injectionRefusedHandlerEvent); + } + return; + } + } + if (node.has("request_id") && "Welcome".equals(node.path("type").asText())) { + AgentV1Welcome welcomeHandlerEvent = null; + try { + welcomeHandlerEvent = objectMapper.treeToValue(node, AgentV1Welcome.class); + } catch (Exception e) { + } + if (welcomeHandlerEvent != null) { + if (welcomeHandler != null) { + welcomeHandler.accept(welcomeHandlerEvent); + } + return; + } + } + if (node.has("content") && "AgentThinking".equals(node.path("type").asText())) { + AgentV1AgentThinking agentThinkingHandlerEvent = null; + try { + agentThinkingHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentThinking.class); + } catch (Exception e) { + } + if (agentThinkingHandlerEvent != null) { + if (agentThinkingHandler != null) { + agentThinkingHandler.accept(agentThinkingHandlerEvent); + } + return; + } + } + if (node.has("functions") + && "FunctionCallRequest".equals(node.path("type").asText())) { + AgentV1FunctionCallRequest functionCallRequestHandlerEvent = null; + try { + functionCallRequestHandlerEvent = objectMapper.treeToValue(node, AgentV1FunctionCallRequest.class); + } catch (Exception e) { + } + if (functionCallRequestHandlerEvent != null) { + if (functionCallRequestHandler != null) { + functionCallRequestHandler.accept(functionCallRequestHandlerEvent); + } + return; + } + } + if (node.has("functions") + && "FunctionCallCancelled".equals(node.path("type").asText())) { + AgentV1FunctionCallCancelled functionCallCancelledHandlerEvent = null; + try { + functionCallCancelledHandlerEvent = + objectMapper.treeToValue(node, AgentV1FunctionCallCancelled.class); + } catch (Exception e) { + } + if (functionCallCancelledHandlerEvent != null) { + if (functionCallCancelledHandler != null) { + functionCallCancelledHandler.accept(functionCallCancelledHandlerEvent); + } + return; + } + } + if (node.has("content") + && "__customFromThinkProvider".equals(node.path("type").asText())) { + AgentV1CustomFromThinkProvider customFromThinkProviderHandlerEvent = null; + try { + customFromThinkProviderHandlerEvent = + objectMapper.treeToValue(node, AgentV1CustomFromThinkProvider.class); + } catch (Exception e) { + } + if (customFromThinkProviderHandlerEvent != null) { + if (customFromThinkProviderHandler != null) { + customFromThinkProviderHandler.accept(customFromThinkProviderHandlerEvent); + } + return; + } + } + if ("ListenUpdated".equals(node.path("type").asText())) { + AgentV1ListenUpdated listenUpdatedHandlerEvent = null; + try { + listenUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ListenUpdated.class); + } catch (Exception e) { + } + if (listenUpdatedHandlerEvent != null) { + if (listenUpdatedHandler != null) { + listenUpdatedHandler.accept(listenUpdatedHandlerEvent); + } + return; + } + } + if ("ThinkUpdated".equals(node.path("type").asText())) { + AgentV1ThinkUpdated thinkUpdatedHandlerEvent = null; + try { + thinkUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkUpdated.class); + } catch (Exception e) { + } + if (thinkUpdatedHandlerEvent != null) { + if (thinkUpdatedHandler != null) { + thinkUpdatedHandler.accept(thinkUpdatedHandlerEvent); + } + return; + } + } + if ("ThinkLiveUpdated".equals(node.path("type").asText())) { + AgentV1ThinkLiveUpdated thinkLiveUpdatedHandlerEvent = null; + try { + thinkLiveUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkLiveUpdated.class); + } catch (Exception e) { + } + if (thinkLiveUpdatedHandlerEvent != null) { + if (thinkLiveUpdatedHandler != null) { + thinkLiveUpdatedHandler.accept(thinkLiveUpdatedHandlerEvent); + } + return; + } + } + if ("PromptUpdated".equals(node.path("type").asText())) { + AgentV1PromptUpdated promptUpdatedHandlerEvent = null; + try { + promptUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1PromptUpdated.class); + } catch (Exception e) { + } + if (promptUpdatedHandlerEvent != null) { + if (promptUpdatedHandler != null) { + promptUpdatedHandler.accept(promptUpdatedHandlerEvent); + } + return; + } + } + if ("SpeakUpdated".equals(node.path("type").asText())) { + AgentV1SpeakUpdated speakUpdatedHandlerEvent = null; + try { + speakUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1SpeakUpdated.class); + } catch (Exception e) { + } + if (speakUpdatedHandlerEvent != null) { + if (speakUpdatedHandler != null) { + speakUpdatedHandler.accept(speakUpdatedHandlerEvent); + } + return; + } + } + if ("SettingsApplied".equals(node.path("type").asText())) { + AgentV1SettingsApplied settingsAppliedHandlerEvent = null; + try { + settingsAppliedHandlerEvent = objectMapper.treeToValue(node, AgentV1SettingsApplied.class); + } catch (Exception e) { + } + if (settingsAppliedHandlerEvent != null) { + if (settingsAppliedHandler != null) { + settingsAppliedHandler.accept(settingsAppliedHandlerEvent); + } + return; + } + } + if ("UserStartedSpeaking".equals(node.path("type").asText())) { + AgentV1UserStartedSpeaking userStartedSpeakingHandlerEvent = null; + try { + userStartedSpeakingHandlerEvent = objectMapper.treeToValue(node, AgentV1UserStartedSpeaking.class); + } catch (Exception e) { + } + if (userStartedSpeakingHandlerEvent != null) { + if (userStartedSpeakingHandler != null) { + userStartedSpeakingHandler.accept(userStartedSpeakingHandlerEvent); + } + return; + } + } + if ("LatencyReport".equals(node.path("type").asText())) { + AgentV1LatencyReport latencyReportHandlerEvent = null; + try { + latencyReportHandlerEvent = objectMapper.treeToValue(node, AgentV1LatencyReport.class); + } catch (Exception e) { + } + if (latencyReportHandlerEvent != null) { + if (latencyReportHandler != null) { + latencyReportHandler.accept(latencyReportHandlerEvent); + } + return; + } + } + if ("AgentAudioDone".equals(node.path("type").asText())) { + AgentV1AgentAudioDone agentAudioDoneHandlerEvent = null; + try { + agentAudioDoneHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentAudioDone.class); + } catch (Exception e) { + } + if (agentAudioDoneHandlerEvent != null) { + if (agentAudioDoneHandler != null) { + agentAudioDoneHandler.accept(agentAudioDoneHandlerEvent); + } + return; + } + } + AgentV1History agentV1HistoryHandlerEvent = null; + try { + agentV1HistoryHandlerEvent = objectMapper.treeToValue(node, AgentV1History.class); + } catch (Exception e) { + } + if (agentV1HistoryHandlerEvent != null) { + if (agentV1HistoryHandler != null) { + agentV1HistoryHandler.accept(agentV1HistoryHandlerEvent); + } + return; + } + if (onMessageHandler == null && onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak new file mode 100644 index 0000000..448c459 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak @@ -0,0 +1,1932 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.media.requests; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV1RequestUrl.Builder.class) +public final class ListenV1RequestUrl { + private final Optional> extra; + + private final Optional> tag; + + private final Optional> customTopic; + + private final Optional> customIntent; + + private final Optional> keyterm; + + private final Optional> keywords; + + private final Optional> languageHint; + + private final Optional> replace; + + private final Optional> search; + + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional sentiment; + + private final Optional summarize; + + private final Optional topics; + + private final Optional customTopicMode; + + private final Optional intents; + + private final Optional customIntentMode; + + private final Optional detectEntities; + + private final Optional detectLanguage; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional fillerWords; + + private final Optional language; + + private final Optional measurements; + + private final Optional model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional paragraphs; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional smartFormat; + + private final Optional utterances; + + private final Optional uttSplit; + + private final Optional version; + + private final Optional mipOptOut; + + private final String url; + + private final Map additionalProperties; + + private ListenV1RequestUrl( + Optional> extra, + Optional> tag, + Optional> customTopic, + Optional> customIntent, + Optional> keyterm, + Optional> keywords, + Optional> languageHint, + Optional> replace, + Optional> search, + Optional callback, + Optional callbackMethod, + Optional sentiment, + Optional summarize, + Optional topics, + Optional customTopicMode, + Optional intents, + Optional customIntentMode, + Optional detectEntities, + Optional detectLanguage, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional fillerWords, + Optional language, + Optional measurements, + Optional model, + Optional multichannel, + Optional numerals, + Optional paragraphs, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional smartFormat, + Optional utterances, + Optional uttSplit, + Optional version, + Optional mipOptOut, + String url, + Map additionalProperties) { + this.extra = extra; + this.tag = tag; + this.customTopic = customTopic; + this.customIntent = customIntent; + this.keyterm = keyterm; + this.keywords = keywords; + this.languageHint = languageHint; + this.replace = replace; + this.search = search; + this.callback = callback; + this.callbackMethod = callbackMethod; + this.sentiment = sentiment; + this.summarize = summarize; + this.topics = topics; + this.customTopicMode = customTopicMode; + this.intents = intents; + this.customIntentMode = customIntentMode; + this.detectEntities = detectEntities; + this.detectLanguage = detectLanguage; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.fillerWords = fillerWords; + this.language = language; + this.measurements = measurements; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.paragraphs = paragraphs; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.smartFormat = smartFormat; + this.utterances = utterances; + this.uttSplit = uttSplit; + this.version = version; + this.mipOptOut = mipOptOut; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ + @JsonIgnore + public Optional> getExtra() { + return extra; + } + + /** + * @return Label your requests for the purpose of identification during usage reporting + */ + @JsonIgnore + public Optional> getTag() { + return tag; + } + + /** + * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. + */ + @JsonIgnore + public Optional> getCustomTopic() { + return customTopic; + } + + /** + * @return Custom intents you want the model to detect within your input audio if present + */ + @JsonIgnore + public Optional> getCustomIntent() { + return customIntent; + } + + /** + * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. + *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @JsonIgnore + public Optional> getKeyterm() { + return keyterm; + } + + /** + * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. + */ + @JsonIgnore + public Optional> getKeywords() { + return keywords; + } + + /** + * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. + */ + @JsonIgnore + public Optional> getLanguageHint() { + return languageHint; + } + + /** + * @return Search for terms or phrases in submitted audio and replaces them + */ + @JsonIgnore + public Optional> getReplace() { + return replace; + } + + /** + * @return Search for terms or phrases in submitted audio + */ + @JsonIgnore + public Optional> getSearch() { + return search; + } + + /** + * @return URL to which we'll make the callback request + */ + @JsonIgnore + public Optional getCallback() { + return callback; + } + + /** + * @return HTTP method by which the callback request will be made + */ + @JsonIgnore + public Optional getCallbackMethod() { + return callbackMethod; + } + + /** + * @return Recognizes the sentiment throughout a transcript or text + */ + @JsonIgnore + public Optional getSentiment() { + return sentiment; + } + + /** + * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. + */ + @JsonIgnore + public Optional getSummarize() { + return summarize; + } + + /** + * @return Detect topics throughout a transcript or text + */ + @JsonIgnore + public Optional getTopics() { + return topics; + } + + /** + * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param + */ + @JsonIgnore + public Optional getCustomTopicMode() { + return customTopicMode; + } + + /** + * @return Recognizes speaker intent throughout a transcript or text + */ + @JsonIgnore + public Optional getIntents() { + return intents; + } + + /** + * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. + */ + @JsonIgnore + public Optional getCustomIntentMode() { + return customIntentMode; + } + + /** + * @return Identifies and extracts key entities from content in submitted audio + */ + @JsonIgnore + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Identifies the dominant language spoken in submitted audio + */ + @JsonIgnore + public Optional getDetectLanguage() { + return detectLanguage; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonIgnore + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. + */ + @JsonIgnore + public Optional getDiarizeModel() { + return diarizeModel; + } + + /** + * @return Dictation mode for controlling formatting with dictated speech + */ + @JsonIgnore + public Optional getDictation() { + return dictation; + } + + /** + * @return Specify the expected encoding of your submitted audio + */ + @JsonIgnore + public Optional getEncoding() { + return encoding; + } + + /** + * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" + */ + @JsonIgnore + public Optional getFillerWords() { + return fillerWords; + } + + /** + * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available + */ + @JsonIgnore + public Optional getLanguage() { + return language; + } + + /** + * @return Spoken measurements will be converted to their corresponding abbreviations + */ + @JsonIgnore + public Optional getMeasurements() { + return measurements; + } + + /** + * @return AI model used to process submitted audio + */ + @JsonIgnore + public Optional getModel() { + return model; + } + + /** + * @return Transcribe each audio channel independently + */ + @JsonIgnore + public Optional getMultichannel() { + return multichannel; + } + + /** + * @return Numerals converts numbers from written format to numerical format + */ + @JsonIgnore + public Optional getNumerals() { + return numerals; + } + + /** + * @return Splits audio into paragraphs to improve transcript readability + */ + @JsonIgnore + public Optional getParagraphs() { + return paragraphs; + } + + /** + * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely + */ + @JsonIgnore + public Optional getProfanityFilter() { + return profanityFilter; + } + + /** + * @return Add punctuation and capitalization to the transcript + */ + @JsonIgnore + public Optional getPunctuate() { + return punctuate; + } + + /** + * @return Redaction removes sensitive information from your transcripts + */ + @JsonIgnore + public Optional getRedact() { + return redact; + } + + /** + * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability + */ + @JsonIgnore + public Optional getSmartFormat() { + return smartFormat; + } + + /** + * @return Segments speech into meaningful semantic units + */ + @JsonIgnore + public Optional getUtterances() { + return utterances; + } + + /** + * @return Seconds to wait before detecting a pause between words in submitted audio + */ + @JsonIgnore + public Optional getUttSplit() { + return uttSplit; + } + + /** + * @return Version of an AI model to use + */ + @JsonIgnore + public Optional getVersion() { + return version; + } + + /** + * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ + @JsonIgnore + public Optional getMipOptOut() { + return mipOptOut; + } + + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV1RequestUrl && equalTo((ListenV1RequestUrl) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListenV1RequestUrl other) { + return extra.equals(other.extra) + && tag.equals(other.tag) + && customTopic.equals(other.customTopic) + && customIntent.equals(other.customIntent) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && languageHint.equals(other.languageHint) + && replace.equals(other.replace) + && search.equals(other.search) + && callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && sentiment.equals(other.sentiment) + && summarize.equals(other.summarize) + && topics.equals(other.topics) + && customTopicMode.equals(other.customTopicMode) + && intents.equals(other.intents) + && customIntentMode.equals(other.customIntentMode) + && detectEntities.equals(other.detectEntities) + && detectLanguage.equals(other.detectLanguage) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && fillerWords.equals(other.fillerWords) + && language.equals(other.language) + && measurements.equals(other.measurements) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && paragraphs.equals(other.paragraphs) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && smartFormat.equals(other.smartFormat) + && utterances.equals(other.utterances) + && uttSplit.equals(other.uttSplit) + && version.equals(other.version) + && mipOptOut.equals(other.mipOptOut) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.extra, + this.tag, + this.customTopic, + this.customIntent, + this.keyterm, + this.keywords, + this.languageHint, + this.replace, + this.search, + this.callback, + this.callbackMethod, + this.sentiment, + this.summarize, + this.topics, + this.customTopicMode, + this.intents, + this.customIntentMode, + this.detectEntities, + this.detectLanguage, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.fillerWords, + this.language, + this.measurements, + this.model, + this.multichannel, + this.numerals, + this.paragraphs, + this.profanityFilter, + this.punctuate, + this.redact, + this.smartFormat, + this.utterances, + this.uttSplit, + this.version, + this.mipOptOut, + this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UrlStage builder() { + return new Builder(); + } + + public interface UrlStage { + _FinalStage url(@NotNull String url); + + Builder from(ListenV1RequestUrl other); + } + + public interface _FinalStage { + ListenV1RequestUrl build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + _FinalStage extra(Optional> extra); + + _FinalStage extra(List extra); + + _FinalStage extra(String extra); + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + _FinalStage tag(Optional> tag); + + _FinalStage tag(List tag); + + _FinalStage tag(String tag); + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + _FinalStage customTopic(Optional> customTopic); + + _FinalStage customTopic(List customTopic); + + _FinalStage customTopic(String customTopic); + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + _FinalStage customIntent(Optional> customIntent); + + _FinalStage customIntent(List customIntent); + + _FinalStage customIntent(String customIntent); + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + _FinalStage keyterm(Optional> keyterm); + + _FinalStage keyterm(List keyterm); + + _FinalStage keyterm(String keyterm); + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + _FinalStage keywords(Optional> keywords); + + _FinalStage keywords(List keywords); + + _FinalStage keywords(String keywords); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional> languageHint) { + return this; + } + + default _FinalStage languageHint(List languageHint) { + return this; + } + + default _FinalStage languageHint(String languageHint) { + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + _FinalStage replace(Optional> replace); + + _FinalStage replace(List replace); + + _FinalStage replace(String replace); + + /** + *

Search for terms or phrases in submitted audio

+ */ + _FinalStage search(Optional> search); + + _FinalStage search(List search); + + _FinalStage search(String search); + + /** + *

URL to which we'll make the callback request

+ */ + _FinalStage callback(Optional callback); + + _FinalStage callback(String callback); + + /** + *

HTTP method by which the callback request will be made

+ */ + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + _FinalStage sentiment(Optional sentiment); + + _FinalStage sentiment(Boolean sentiment); + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + _FinalStage summarize(Optional summarize); + + _FinalStage summarize(MediaTranscribeRequestSummarize summarize); + + /** + *

Detect topics throughout a transcript or text

+ */ + _FinalStage topics(Optional topics); + + _FinalStage topics(Boolean topics); + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + _FinalStage customTopicMode(Optional customTopicMode); + + _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + _FinalStage intents(Optional intents); + + _FinalStage intents(Boolean intents); + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + _FinalStage customIntentMode(Optional customIntentMode); + + _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(Boolean detectEntities); + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + _FinalStage detectLanguage(Optional detectLanguage); + + _FinalStage detectLanguage(Boolean detectLanguage); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(Boolean diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(Boolean dictation); + + /** + *

Specify the expected encoding of your submitted audio

+ */ + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(MediaTranscribeRequestEncoding encoding); + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + _FinalStage fillerWords(Optional fillerWords); + + _FinalStage fillerWords(Boolean fillerWords); + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + _FinalStage language(Optional language); + + _FinalStage language(String language); + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + _FinalStage measurements(Optional measurements); + + _FinalStage measurements(Boolean measurements); + + /** + *

AI model used to process submitted audio

+ */ + _FinalStage model(Optional model); + + _FinalStage model(MediaTranscribeRequestModel model); + + /** + *

Transcribe each audio channel independently

+ */ + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(Boolean multichannel); + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(Boolean numerals); + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + _FinalStage paragraphs(Optional paragraphs); + + _FinalStage paragraphs(Boolean paragraphs); + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(Boolean profanityFilter); + + /** + *

Add punctuation and capitalization to the transcript

+ */ + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(Boolean punctuate); + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + _FinalStage redact(Optional redact); + + _FinalStage redact(String redact); + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(Boolean smartFormat); + + /** + *

Segments speech into meaningful semantic units

+ */ + _FinalStage utterances(Optional utterances); + + _FinalStage utterances(Boolean utterances); + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + _FinalStage uttSplit(Optional uttSplit); + + _FinalStage uttSplit(Double uttSplit); + + /** + *

Version of an AI model to use

+ */ + _FinalStage version(Optional version); + + _FinalStage version(MediaTranscribeRequestVersion version); + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(Boolean mipOptOut); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UrlStage, _FinalStage { + private String url; + + private Optional mipOptOut = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional uttSplit = Optional.empty(); + + private Optional utterances = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional paragraphs = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional measurements = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional fillerWords = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectLanguage = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional customIntentMode = Optional.empty(); + + private Optional intents = Optional.empty(); + + private Optional customTopicMode = Optional.empty(); + + private Optional topics = Optional.empty(); + + private Optional summarize = Optional.empty(); + + private Optional sentiment = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + private Optional> search = Optional.empty(); + + private Optional> replace = Optional.empty(); + + private Optional> languageHint = Optional.empty(); + + private Optional> keywords = Optional.empty(); + + private Optional> keyterm = Optional.empty(); + + private Optional> customIntent = Optional.empty(); + + private Optional> customTopic = Optional.empty(); + + private Optional> tag = Optional.empty(); + + private Optional> extra = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListenV1RequestUrl other) { + extra(other.getExtra()); + tag(other.getTag()); + customTopic(other.getCustomTopic()); + customIntent(other.getCustomIntent()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + languageHint(other.getLanguageHint()); + replace(other.getReplace()); + search(other.getSearch()); + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + sentiment(other.getSentiment()); + summarize(other.getSummarize()); + topics(other.getTopics()); + customTopicMode(other.getCustomTopicMode()); + intents(other.getIntents()); + customIntentMode(other.getCustomIntentMode()); + detectEntities(other.getDetectEntities()); + detectLanguage(other.getDetectLanguage()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + fillerWords(other.getFillerWords()); + language(other.getLanguage()); + measurements(other.getMeasurements()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + paragraphs(other.getParagraphs()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + smartFormat(other.getSmartFormat()); + utterances(other.getUtterances()); + uttSplit(other.getUttSplit()); + version(other.getVersion()); + mipOptOut(other.getMipOptOut()); + url(other.getUrl()); + return this; + } + + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage mipOptOut(Boolean mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + /** + *

Version of an AI model to use

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(MediaTranscribeRequestVersion version) { + this.version = Optional.ofNullable(version); + return this; + } + + /** + *

Version of an AI model to use

+ */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage uttSplit(Double uttSplit) { + this.uttSplit = Optional.ofNullable(uttSplit); + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) + public _FinalStage uttSplit(Optional uttSplit) { + this.uttSplit = uttSplit; + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage utterances(Boolean utterances) { + this.utterances = Optional.ofNullable(utterances); + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ */ + @java.lang.Override + @JsonSetter(value = "utterances", nulls = Nulls.SKIP) + public _FinalStage utterances(Optional utterances) { + this.utterances = utterances; + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage smartFormat(Boolean smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redact(String redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage punctuate(Boolean punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ */ + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage profanityFilter(Boolean profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage paragraphs(Boolean paragraphs) { + this.paragraphs = Optional.ofNullable(paragraphs); + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + @java.lang.Override + @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) + public _FinalStage paragraphs(Optional paragraphs) { + this.paragraphs = paragraphs; + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numerals(Boolean numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + /** + *

Transcribe each audio channel independently

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multichannel(Boolean multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + /** + *

Transcribe each audio channel independently

+ */ + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + /** + *

AI model used to process submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(MediaTranscribeRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

AI model used to process submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage measurements(Boolean measurements) { + this.measurements = Optional.ofNullable(measurements); + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + @java.lang.Override + @JsonSetter(value = "measurements", nulls = Nulls.SKIP) + public _FinalStage measurements(Optional measurements) { + this.measurements = measurements; + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage language(String language) { + this.language = Optional.ofNullable(language); + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage fillerWords(Boolean fillerWords) { + this.fillerWords = Optional.ofNullable(fillerWords); + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + @java.lang.Override + @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) + public _FinalStage fillerWords(Optional fillerWords) { + this.fillerWords = fillerWords; + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage dictation(Boolean dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(Boolean diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectLanguage(Boolean detectLanguage) { + this.detectLanguage = Optional.ofNullable(detectLanguage); + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) + public _FinalStage detectLanguage(Optional detectLanguage) { + this.detectLanguage = detectLanguage; + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectEntities(Boolean detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { + this.customIntentMode = Optional.ofNullable(customIntentMode); + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) + public _FinalStage customIntentMode(Optional customIntentMode) { + this.customIntentMode = customIntentMode; + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intents(Boolean intents) { + this.intents = Optional.ofNullable(intents); + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "intents", nulls = Nulls.SKIP) + public _FinalStage intents(Optional intents) { + this.intents = intents; + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { + this.customTopicMode = Optional.ofNullable(customTopicMode); + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) + public _FinalStage customTopicMode(Optional customTopicMode) { + this.customTopicMode = customTopicMode; + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage topics(Boolean topics) { + this.topics = Optional.ofNullable(topics); + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "topics", nulls = Nulls.SKIP) + public _FinalStage topics(Optional topics) { + this.topics = topics; + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { + this.summarize = Optional.ofNullable(summarize); + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + @java.lang.Override + @JsonSetter(value = "summarize", nulls = Nulls.SKIP) + public _FinalStage summarize(Optional summarize) { + this.summarize = summarize; + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sentiment(Boolean sentiment) { + this.sentiment = Optional.ofNullable(sentiment); + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) + public _FinalStage sentiment(Optional sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ */ + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + /** + *

URL to which we'll make the callback request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callback(String callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + /** + *

URL to which we'll make the callback request

+ */ + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public _FinalStage search(String search) { + this.search = Optional.of(Collections.singletonList(search)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage search(List search) { + this.search = Optional.ofNullable(search); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional> search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage replace(String replace) { + this.replace = Optional.of(Collections.singletonList(replace)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage replace(List replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional> replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(String languageHint) { + this.languageHint = Optional.of(Collections.singletonList(languageHint)); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languageHint(List languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional> languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage keywords(String keywords) { + this.keywords = Optional.of(Collections.singletonList(keywords)); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keywords(List keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional> keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(String keyterm) { + this.keyterm = Optional.of(Collections.singletonList(keyterm)); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keyterm(List keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional> keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage customIntent(String customIntent) { + this.customIntent = Optional.of(Collections.singletonList(customIntent)); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntent(List customIntent) { + this.customIntent = Optional.ofNullable(customIntent); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) + public _FinalStage customIntent(Optional> customIntent) { + this.customIntent = customIntent; + return this; + } + + @java.lang.Override + public _FinalStage customTopic(String customTopic) { + this.customTopic = Optional.of(Collections.singletonList(customTopic)); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopic(List customTopic) { + this.customTopic = Optional.ofNullable(customTopic); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) + public _FinalStage customTopic(Optional> customTopic) { + this.customTopic = customTopic; + return this; + } + + @java.lang.Override + public _FinalStage tag(String tag) { + this.tag = Optional.of(Collections.singletonList(tag)); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tag(List tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional> tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage extra(String extra) { + this.extra = Optional.of(Collections.singletonList(extra)); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage extra(List extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional> extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public ListenV1RequestUrl build() { + return new ListenV1RequestUrl( + extra, + tag, + customTopic, + customIntent, + keyterm, + keywords, + languageHint, + replace, + search, + callback, + callbackMethod, + sentiment, + summarize, + topics, + customTopicMode, + intents, + customIntentMode, + detectEntities, + detectLanguage, + diarize, + diarizeModel, + dictation, + encoding, + fillerWords, + language, + measurements, + model, + multichannel, + numerals, + paragraphs, + profanityFilter, + punctuate, + redact, + smartFormat, + utterances, + uttSplit, + version, + mipOptOut, + url, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak new file mode 100644 index 0000000..f094b06 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak @@ -0,0 +1,1931 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.media.requests; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MediaTranscribeRequestOctetStream.Builder.class) +public final class MediaTranscribeRequestOctetStream { + private final Optional> extra; + + private final Optional> tag; + + private final Optional> customTopic; + + private final Optional> customIntent; + + private final Optional> keyterm; + + private final Optional> keywords; + + private final Optional> languageHint; + + private final Optional> replace; + + private final Optional> search; + + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional sentiment; + + private final Optional summarize; + + private final Optional topics; + + private final Optional customTopicMode; + + private final Optional intents; + + private final Optional customIntentMode; + + private final Optional detectEntities; + + private final Optional detectLanguage; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional fillerWords; + + private final Optional language; + + private final Optional measurements; + + private final Optional model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional paragraphs; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional smartFormat; + + private final Optional utterances; + + private final Optional uttSplit; + + private final Optional version; + + private final Optional mipOptOut; + + private final byte[] body; + + private final Map additionalProperties; + + private MediaTranscribeRequestOctetStream( + Optional> extra, + Optional> tag, + Optional> customTopic, + Optional> customIntent, + Optional> keyterm, + Optional> keywords, + Optional> languageHint, + Optional> replace, + Optional> search, + Optional callback, + Optional callbackMethod, + Optional sentiment, + Optional summarize, + Optional topics, + Optional customTopicMode, + Optional intents, + Optional customIntentMode, + Optional detectEntities, + Optional detectLanguage, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional fillerWords, + Optional language, + Optional measurements, + Optional model, + Optional multichannel, + Optional numerals, + Optional paragraphs, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional smartFormat, + Optional utterances, + Optional uttSplit, + Optional version, + Optional mipOptOut, + byte[] body, + Map additionalProperties) { + this.extra = extra; + this.tag = tag; + this.customTopic = customTopic; + this.customIntent = customIntent; + this.keyterm = keyterm; + this.keywords = keywords; + this.languageHint = languageHint; + this.replace = replace; + this.search = search; + this.callback = callback; + this.callbackMethod = callbackMethod; + this.sentiment = sentiment; + this.summarize = summarize; + this.topics = topics; + this.customTopicMode = customTopicMode; + this.intents = intents; + this.customIntentMode = customIntentMode; + this.detectEntities = detectEntities; + this.detectLanguage = detectLanguage; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.fillerWords = fillerWords; + this.language = language; + this.measurements = measurements; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.paragraphs = paragraphs; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.smartFormat = smartFormat; + this.utterances = utterances; + this.uttSplit = uttSplit; + this.version = version; + this.mipOptOut = mipOptOut; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ + @JsonProperty("extra") + public Optional> getExtra() { + return extra; + } + + /** + * @return Label your requests for the purpose of identification during usage reporting + */ + @JsonProperty("tag") + public Optional> getTag() { + return tag; + } + + /** + * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. + */ + @JsonProperty("custom_topic") + public Optional> getCustomTopic() { + return customTopic; + } + + /** + * @return Custom intents you want the model to detect within your input audio if present + */ + @JsonProperty("custom_intent") + public Optional> getCustomIntent() { + return customIntent; + } + + /** + * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. + *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @JsonProperty("keyterm") + public Optional> getKeyterm() { + return keyterm; + } + + /** + * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. + */ + @JsonProperty("keywords") + public Optional> getKeywords() { + return keywords; + } + + /** + * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. + */ + @JsonProperty("language_hint") + public Optional> getLanguageHint() { + return languageHint; + } + + /** + * @return Search for terms or phrases in submitted audio and replaces them + */ + @JsonProperty("replace") + public Optional> getReplace() { + return replace; + } + + /** + * @return Search for terms or phrases in submitted audio + */ + @JsonProperty("search") + public Optional> getSearch() { + return search; + } + + /** + * @return URL to which we'll make the callback request + */ + @JsonProperty("callback") + public Optional getCallback() { + return callback; + } + + /** + * @return HTTP method by which the callback request will be made + */ + @JsonProperty("callback_method") + public Optional getCallbackMethod() { + return callbackMethod; + } + + /** + * @return Recognizes the sentiment throughout a transcript or text + */ + @JsonProperty("sentiment") + public Optional getSentiment() { + return sentiment; + } + + /** + * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. + */ + @JsonProperty("summarize") + public Optional getSummarize() { + return summarize; + } + + /** + * @return Detect topics throughout a transcript or text + */ + @JsonProperty("topics") + public Optional getTopics() { + return topics; + } + + /** + * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param + */ + @JsonProperty("custom_topic_mode") + public Optional getCustomTopicMode() { + return customTopicMode; + } + + /** + * @return Recognizes speaker intent throughout a transcript or text + */ + @JsonProperty("intents") + public Optional getIntents() { + return intents; + } + + /** + * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. + */ + @JsonProperty("custom_intent_mode") + public Optional getCustomIntentMode() { + return customIntentMode; + } + + /** + * @return Identifies and extracts key entities from content in submitted audio + */ + @JsonProperty("detect_entities") + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Identifies the dominant language spoken in submitted audio + */ + @JsonProperty("detect_language") + public Optional getDetectLanguage() { + return detectLanguage; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonProperty("diarize") + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. + */ + @JsonProperty("diarize_model") + public Optional getDiarizeModel() { + return diarizeModel; + } + + /** + * @return Dictation mode for controlling formatting with dictated speech + */ + @JsonProperty("dictation") + public Optional getDictation() { + return dictation; + } + + /** + * @return Specify the expected encoding of your submitted audio + */ + @JsonProperty("encoding") + public Optional getEncoding() { + return encoding; + } + + /** + * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" + */ + @JsonProperty("filler_words") + public Optional getFillerWords() { + return fillerWords; + } + + /** + * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available + */ + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + /** + * @return Spoken measurements will be converted to their corresponding abbreviations + */ + @JsonProperty("measurements") + public Optional getMeasurements() { + return measurements; + } + + /** + * @return AI model used to process submitted audio + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Transcribe each audio channel independently + */ + @JsonProperty("multichannel") + public Optional getMultichannel() { + return multichannel; + } + + /** + * @return Numerals converts numbers from written format to numerical format + */ + @JsonProperty("numerals") + public Optional getNumerals() { + return numerals; + } + + /** + * @return Splits audio into paragraphs to improve transcript readability + */ + @JsonProperty("paragraphs") + public Optional getParagraphs() { + return paragraphs; + } + + /** + * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely + */ + @JsonProperty("profanity_filter") + public Optional getProfanityFilter() { + return profanityFilter; + } + + /** + * @return Add punctuation and capitalization to the transcript + */ + @JsonProperty("punctuate") + public Optional getPunctuate() { + return punctuate; + } + + /** + * @return Redaction removes sensitive information from your transcripts + */ + @JsonProperty("redact") + public Optional getRedact() { + return redact; + } + + /** + * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability + */ + @JsonProperty("smart_format") + public Optional getSmartFormat() { + return smartFormat; + } + + /** + * @return Segments speech into meaningful semantic units + */ + @JsonProperty("utterances") + public Optional getUtterances() { + return utterances; + } + + /** + * @return Seconds to wait before detecting a pause between words in submitted audio + */ + @JsonProperty("utt_split") + public Optional getUttSplit() { + return uttSplit; + } + + /** + * @return Version of an AI model to use + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + /** + * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ + @JsonProperty("mip_opt_out") + public Optional getMipOptOut() { + return mipOptOut; + } + + @JsonProperty("body") + public byte[] getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MediaTranscribeRequestOctetStream && equalTo((MediaTranscribeRequestOctetStream) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MediaTranscribeRequestOctetStream other) { + return extra.equals(other.extra) + && tag.equals(other.tag) + && customTopic.equals(other.customTopic) + && customIntent.equals(other.customIntent) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && languageHint.equals(other.languageHint) + && replace.equals(other.replace) + && search.equals(other.search) + && callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && sentiment.equals(other.sentiment) + && summarize.equals(other.summarize) + && topics.equals(other.topics) + && customTopicMode.equals(other.customTopicMode) + && intents.equals(other.intents) + && customIntentMode.equals(other.customIntentMode) + && detectEntities.equals(other.detectEntities) + && detectLanguage.equals(other.detectLanguage) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && fillerWords.equals(other.fillerWords) + && language.equals(other.language) + && measurements.equals(other.measurements) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && paragraphs.equals(other.paragraphs) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && smartFormat.equals(other.smartFormat) + && utterances.equals(other.utterances) + && uttSplit.equals(other.uttSplit) + && version.equals(other.version) + && mipOptOut.equals(other.mipOptOut) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.extra, + this.tag, + this.customTopic, + this.customIntent, + this.keyterm, + this.keywords, + this.languageHint, + this.replace, + this.search, + this.callback, + this.callbackMethod, + this.sentiment, + this.summarize, + this.topics, + this.customTopicMode, + this.intents, + this.customIntentMode, + this.detectEntities, + this.detectLanguage, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.fillerWords, + this.language, + this.measurements, + this.model, + this.multichannel, + this.numerals, + this.paragraphs, + this.profanityFilter, + this.punctuate, + this.redact, + this.smartFormat, + this.utterances, + this.uttSplit, + this.version, + this.mipOptOut, + this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BodyStage builder() { + return new Builder(); + } + + public interface BodyStage { + _FinalStage body(@NotNull byte[] body); + + Builder from(MediaTranscribeRequestOctetStream other); + } + + public interface _FinalStage { + MediaTranscribeRequestOctetStream build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + _FinalStage extra(Optional> extra); + + _FinalStage extra(List extra); + + _FinalStage extra(String extra); + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + _FinalStage tag(Optional> tag); + + _FinalStage tag(List tag); + + _FinalStage tag(String tag); + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + _FinalStage customTopic(Optional> customTopic); + + _FinalStage customTopic(List customTopic); + + _FinalStage customTopic(String customTopic); + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + _FinalStage customIntent(Optional> customIntent); + + _FinalStage customIntent(List customIntent); + + _FinalStage customIntent(String customIntent); + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + _FinalStage keyterm(Optional> keyterm); + + _FinalStage keyterm(List keyterm); + + _FinalStage keyterm(String keyterm); + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + _FinalStage keywords(Optional> keywords); + + _FinalStage keywords(List keywords); + + _FinalStage keywords(String keywords); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional> languageHint) { + return this; + } + + default _FinalStage languageHint(List languageHint) { + return this; + } + + default _FinalStage languageHint(String languageHint) { + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + _FinalStage replace(Optional> replace); + + _FinalStage replace(List replace); + + _FinalStage replace(String replace); + + /** + *

Search for terms or phrases in submitted audio

+ */ + _FinalStage search(Optional> search); + + _FinalStage search(List search); + + _FinalStage search(String search); + + /** + *

URL to which we'll make the callback request

+ */ + _FinalStage callback(Optional callback); + + _FinalStage callback(String callback); + + /** + *

HTTP method by which the callback request will be made

+ */ + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + _FinalStage sentiment(Optional sentiment); + + _FinalStage sentiment(Boolean sentiment); + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + _FinalStage summarize(Optional summarize); + + _FinalStage summarize(MediaTranscribeRequestSummarize summarize); + + /** + *

Detect topics throughout a transcript or text

+ */ + _FinalStage topics(Optional topics); + + _FinalStage topics(Boolean topics); + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + _FinalStage customTopicMode(Optional customTopicMode); + + _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + _FinalStage intents(Optional intents); + + _FinalStage intents(Boolean intents); + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + _FinalStage customIntentMode(Optional customIntentMode); + + _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(Boolean detectEntities); + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + _FinalStage detectLanguage(Optional detectLanguage); + + _FinalStage detectLanguage(Boolean detectLanguage); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(Boolean diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(Boolean dictation); + + /** + *

Specify the expected encoding of your submitted audio

+ */ + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(MediaTranscribeRequestEncoding encoding); + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + _FinalStage fillerWords(Optional fillerWords); + + _FinalStage fillerWords(Boolean fillerWords); + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + _FinalStage language(Optional language); + + _FinalStage language(String language); + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + _FinalStage measurements(Optional measurements); + + _FinalStage measurements(Boolean measurements); + + /** + *

AI model used to process submitted audio

+ */ + _FinalStage model(Optional model); + + _FinalStage model(MediaTranscribeRequestModel model); + + /** + *

Transcribe each audio channel independently

+ */ + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(Boolean multichannel); + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(Boolean numerals); + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + _FinalStage paragraphs(Optional paragraphs); + + _FinalStage paragraphs(Boolean paragraphs); + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(Boolean profanityFilter); + + /** + *

Add punctuation and capitalization to the transcript

+ */ + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(Boolean punctuate); + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + _FinalStage redact(Optional redact); + + _FinalStage redact(String redact); + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(Boolean smartFormat); + + /** + *

Segments speech into meaningful semantic units

+ */ + _FinalStage utterances(Optional utterances); + + _FinalStage utterances(Boolean utterances); + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + _FinalStage uttSplit(Optional uttSplit); + + _FinalStage uttSplit(Double uttSplit); + + /** + *

Version of an AI model to use

+ */ + _FinalStage version(Optional version); + + _FinalStage version(MediaTranscribeRequestVersion version); + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(Boolean mipOptOut); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BodyStage, _FinalStage { + private byte[] body; + + private Optional mipOptOut = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional uttSplit = Optional.empty(); + + private Optional utterances = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional paragraphs = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional measurements = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional fillerWords = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectLanguage = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional customIntentMode = Optional.empty(); + + private Optional intents = Optional.empty(); + + private Optional customTopicMode = Optional.empty(); + + private Optional topics = Optional.empty(); + + private Optional summarize = Optional.empty(); + + private Optional sentiment = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + private Optional> search = Optional.empty(); + + private Optional> replace = Optional.empty(); + + private Optional> languageHint = Optional.empty(); + + private Optional> keywords = Optional.empty(); + + private Optional> keyterm = Optional.empty(); + + private Optional> customIntent = Optional.empty(); + + private Optional> customTopic = Optional.empty(); + + private Optional> tag = Optional.empty(); + + private Optional> extra = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(MediaTranscribeRequestOctetStream other) { + extra(other.getExtra()); + tag(other.getTag()); + customTopic(other.getCustomTopic()); + customIntent(other.getCustomIntent()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + languageHint(other.getLanguageHint()); + replace(other.getReplace()); + search(other.getSearch()); + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + sentiment(other.getSentiment()); + summarize(other.getSummarize()); + topics(other.getTopics()); + customTopicMode(other.getCustomTopicMode()); + intents(other.getIntents()); + customIntentMode(other.getCustomIntentMode()); + detectEntities(other.getDetectEntities()); + detectLanguage(other.getDetectLanguage()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + fillerWords(other.getFillerWords()); + language(other.getLanguage()); + measurements(other.getMeasurements()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + paragraphs(other.getParagraphs()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + smartFormat(other.getSmartFormat()); + utterances(other.getUtterances()); + uttSplit(other.getUttSplit()); + version(other.getVersion()); + mipOptOut(other.getMipOptOut()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull byte[] body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage mipOptOut(Boolean mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + /** + *

Version of an AI model to use

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(MediaTranscribeRequestVersion version) { + this.version = Optional.ofNullable(version); + return this; + } + + /** + *

Version of an AI model to use

+ */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage uttSplit(Double uttSplit) { + this.uttSplit = Optional.ofNullable(uttSplit); + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) + public _FinalStage uttSplit(Optional uttSplit) { + this.uttSplit = uttSplit; + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage utterances(Boolean utterances) { + this.utterances = Optional.ofNullable(utterances); + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ */ + @java.lang.Override + @JsonSetter(value = "utterances", nulls = Nulls.SKIP) + public _FinalStage utterances(Optional utterances) { + this.utterances = utterances; + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage smartFormat(Boolean smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redact(String redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage punctuate(Boolean punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ */ + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage profanityFilter(Boolean profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage paragraphs(Boolean paragraphs) { + this.paragraphs = Optional.ofNullable(paragraphs); + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + @java.lang.Override + @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) + public _FinalStage paragraphs(Optional paragraphs) { + this.paragraphs = paragraphs; + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numerals(Boolean numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + /** + *

Transcribe each audio channel independently

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multichannel(Boolean multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + /** + *

Transcribe each audio channel independently

+ */ + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + /** + *

AI model used to process submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(MediaTranscribeRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

AI model used to process submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage measurements(Boolean measurements) { + this.measurements = Optional.ofNullable(measurements); + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + @java.lang.Override + @JsonSetter(value = "measurements", nulls = Nulls.SKIP) + public _FinalStage measurements(Optional measurements) { + this.measurements = measurements; + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage language(String language) { + this.language = Optional.ofNullable(language); + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage fillerWords(Boolean fillerWords) { + this.fillerWords = Optional.ofNullable(fillerWords); + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + @java.lang.Override + @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) + public _FinalStage fillerWords(Optional fillerWords) { + this.fillerWords = fillerWords; + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage dictation(Boolean dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(Boolean diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectLanguage(Boolean detectLanguage) { + this.detectLanguage = Optional.ofNullable(detectLanguage); + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) + public _FinalStage detectLanguage(Optional detectLanguage) { + this.detectLanguage = detectLanguage; + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectEntities(Boolean detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { + this.customIntentMode = Optional.ofNullable(customIntentMode); + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) + public _FinalStage customIntentMode(Optional customIntentMode) { + this.customIntentMode = customIntentMode; + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intents(Boolean intents) { + this.intents = Optional.ofNullable(intents); + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "intents", nulls = Nulls.SKIP) + public _FinalStage intents(Optional intents) { + this.intents = intents; + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { + this.customTopicMode = Optional.ofNullable(customTopicMode); + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) + public _FinalStage customTopicMode(Optional customTopicMode) { + this.customTopicMode = customTopicMode; + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage topics(Boolean topics) { + this.topics = Optional.ofNullable(topics); + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "topics", nulls = Nulls.SKIP) + public _FinalStage topics(Optional topics) { + this.topics = topics; + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { + this.summarize = Optional.ofNullable(summarize); + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + @java.lang.Override + @JsonSetter(value = "summarize", nulls = Nulls.SKIP) + public _FinalStage summarize(Optional summarize) { + this.summarize = summarize; + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sentiment(Boolean sentiment) { + this.sentiment = Optional.ofNullable(sentiment); + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) + public _FinalStage sentiment(Optional sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ */ + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + /** + *

URL to which we'll make the callback request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callback(String callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + /** + *

URL to which we'll make the callback request

+ */ + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public _FinalStage search(String search) { + this.search = Optional.of(Collections.singletonList(search)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage search(List search) { + this.search = Optional.ofNullable(search); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional> search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage replace(String replace) { + this.replace = Optional.of(Collections.singletonList(replace)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage replace(List replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional> replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(String languageHint) { + this.languageHint = Optional.of(Collections.singletonList(languageHint)); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languageHint(List languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional> languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage keywords(String keywords) { + this.keywords = Optional.of(Collections.singletonList(keywords)); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keywords(List keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional> keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(String keyterm) { + this.keyterm = Optional.of(Collections.singletonList(keyterm)); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keyterm(List keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional> keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage customIntent(String customIntent) { + this.customIntent = Optional.of(Collections.singletonList(customIntent)); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntent(List customIntent) { + this.customIntent = Optional.ofNullable(customIntent); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) + public _FinalStage customIntent(Optional> customIntent) { + this.customIntent = customIntent; + return this; + } + + @java.lang.Override + public _FinalStage customTopic(String customTopic) { + this.customTopic = Optional.of(Collections.singletonList(customTopic)); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopic(List customTopic) { + this.customTopic = Optional.ofNullable(customTopic); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) + public _FinalStage customTopic(Optional> customTopic) { + this.customTopic = customTopic; + return this; + } + + @java.lang.Override + public _FinalStage tag(String tag) { + this.tag = Optional.of(Collections.singletonList(tag)); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tag(List tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional> tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage extra(String extra) { + this.extra = Optional.of(Collections.singletonList(extra)); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage extra(List extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional> extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public MediaTranscribeRequestOctetStream build() { + return new MediaTranscribeRequestOctetStream( + extra, + tag, + customTopic, + customIntent, + keyterm, + keywords, + languageHint, + replace, + search, + callback, + callbackMethod, + sentiment, + summarize, + topics, + customTopicMode, + intents, + customIntentMode, + detectEntities, + detectLanguage, + diarize, + diarizeModel, + dictation, + encoding, + fillerWords, + language, + measurements, + model, + multichannel, + numerals, + paragraphs, + profanityFilter, + punctuate, + redact, + smartFormat, + utterances, + uttSplit, + version, + mipOptOut, + body, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak new file mode 100644 index 0000000..2694721 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak @@ -0,0 +1,1129 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.websocket; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.types.DiarizeModel; +import com.deepgram.types.ListenV1Callback; +import com.deepgram.types.ListenV1CallbackMethod; +import com.deepgram.types.ListenV1Channels; +import com.deepgram.types.ListenV1DetectEntities; +import com.deepgram.types.ListenV1Diarize; +import com.deepgram.types.ListenV1Dictation; +import com.deepgram.types.ListenV1Encoding; +import com.deepgram.types.ListenV1Endpointing; +import com.deepgram.types.ListenV1Extra; +import com.deepgram.types.ListenV1InterimResults; +import com.deepgram.types.ListenV1Keyterm; +import com.deepgram.types.ListenV1Keywords; +import com.deepgram.types.ListenV1Language; +import com.deepgram.types.ListenV1LanguageHint; +import com.deepgram.types.ListenV1MipOptOut; +import com.deepgram.types.ListenV1Model; +import com.deepgram.types.ListenV1Multichannel; +import com.deepgram.types.ListenV1Numerals; +import com.deepgram.types.ListenV1ProfanityFilter; +import com.deepgram.types.ListenV1Punctuate; +import com.deepgram.types.ListenV1Redact; +import com.deepgram.types.ListenV1Replace; +import com.deepgram.types.ListenV1SampleRate; +import com.deepgram.types.ListenV1Search; +import com.deepgram.types.ListenV1SmartFormat; +import com.deepgram.types.ListenV1Tag; +import com.deepgram.types.ListenV1UtteranceEndMs; +import com.deepgram.types.ListenV1VadEvents; +import com.deepgram.types.ListenV1Version; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = V1ConnectOptions.Builder.class) +public final class V1ConnectOptions { + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional channels; + + private final Optional detectEntities; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional endpointing; + + private final Optional extra; + + private final Optional interimResults; + + private final Optional keyterm; + + private final Optional keywords; + + private final Optional language; + + private final Optional languageHint; + + private final Optional mipOptOut; + + private final ListenV1Model model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional replace; + + private final Optional sampleRate; + + private final Optional search; + + private final Optional smartFormat; + + private final Optional tag; + + private final Optional utteranceEndMs; + + private final Optional vadEvents; + + private final Optional version; + + private final Map additionalProperties; + + private V1ConnectOptions( + Optional callback, + Optional callbackMethod, + Optional channels, + Optional detectEntities, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional endpointing, + Optional extra, + Optional interimResults, + Optional keyterm, + Optional keywords, + Optional language, + Optional languageHint, + Optional mipOptOut, + ListenV1Model model, + Optional multichannel, + Optional numerals, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional replace, + Optional sampleRate, + Optional search, + Optional smartFormat, + Optional tag, + Optional utteranceEndMs, + Optional vadEvents, + Optional version, + Map additionalProperties) { + this.callback = callback; + this.callbackMethod = callbackMethod; + this.channels = channels; + this.detectEntities = detectEntities; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.endpointing = endpointing; + this.extra = extra; + this.interimResults = interimResults; + this.keyterm = keyterm; + this.keywords = keywords; + this.language = language; + this.languageHint = languageHint; + this.mipOptOut = mipOptOut; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.replace = replace; + this.sampleRate = sampleRate; + this.search = search; + this.smartFormat = smartFormat; + this.tag = tag; + this.utteranceEndMs = utteranceEndMs; + this.vadEvents = vadEvents; + this.version = version; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("callback") + public Optional getCallback() { + return callback; + } + + @JsonProperty("callback_method") + public Optional getCallbackMethod() { + return callbackMethod; + } + + @JsonProperty("channels") + public Optional getChannels() { + return channels; + } + + @JsonProperty("detect_entities") + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonProperty("diarize") + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error. + */ + @JsonProperty("diarize_model") + public Optional getDiarizeModel() { + return diarizeModel; + } + + @JsonProperty("dictation") + public Optional getDictation() { + return dictation; + } + + @JsonProperty("encoding") + public Optional getEncoding() { + return encoding; + } + + @JsonProperty("endpointing") + public Optional getEndpointing() { + return endpointing; + } + + @JsonProperty("extra") + public Optional getExtra() { + return extra; + } + + @JsonProperty("interim_results") + public Optional getInterimResults() { + return interimResults; + } + + @JsonProperty("keyterm") + public Optional getKeyterm() { + return keyterm; + } + + @JsonProperty("keywords") + public Optional getKeywords() { + return keywords; + } + + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + @JsonProperty("language_hint") + public Optional getLanguageHint() { + return languageHint; + } + + @JsonProperty("mip_opt_out") + public Optional getMipOptOut() { + return mipOptOut; + } + + /** + * @return AI model to use for the transcription + */ + @JsonProperty("model") + public ListenV1Model getModel() { + return model; + } + + @JsonProperty("multichannel") + public Optional getMultichannel() { + return multichannel; + } + + @JsonProperty("numerals") + public Optional getNumerals() { + return numerals; + } + + @JsonProperty("profanity_filter") + public Optional getProfanityFilter() { + return profanityFilter; + } + + @JsonProperty("punctuate") + public Optional getPunctuate() { + return punctuate; + } + + @JsonProperty("redact") + public Optional getRedact() { + return redact; + } + + @JsonProperty("replace") + public Optional getReplace() { + return replace; + } + + @JsonProperty("sample_rate") + public Optional getSampleRate() { + return sampleRate; + } + + @JsonProperty("search") + public Optional getSearch() { + return search; + } + + @JsonProperty("smart_format") + public Optional getSmartFormat() { + return smartFormat; + } + + @JsonProperty("tag") + public Optional getTag() { + return tag; + } + + @JsonProperty("utterance_end_ms") + public Optional getUtteranceEndMs() { + return utteranceEndMs; + } + + @JsonProperty("vad_events") + public Optional getVadEvents() { + return vadEvents; + } + + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1ConnectOptions && equalTo((V1ConnectOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1ConnectOptions other) { + return callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && channels.equals(other.channels) + && detectEntities.equals(other.detectEntities) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && endpointing.equals(other.endpointing) + && extra.equals(other.extra) + && interimResults.equals(other.interimResults) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && language.equals(other.language) + && languageHint.equals(other.languageHint) + && mipOptOut.equals(other.mipOptOut) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && replace.equals(other.replace) + && sampleRate.equals(other.sampleRate) + && search.equals(other.search) + && smartFormat.equals(other.smartFormat) + && tag.equals(other.tag) + && utteranceEndMs.equals(other.utteranceEndMs) + && vadEvents.equals(other.vadEvents) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.callback, + this.callbackMethod, + this.channels, + this.detectEntities, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.endpointing, + this.extra, + this.interimResults, + this.keyterm, + this.keywords, + this.language, + this.languageHint, + this.mipOptOut, + this.model, + this.multichannel, + this.numerals, + this.profanityFilter, + this.punctuate, + this.redact, + this.replace, + this.sampleRate, + this.search, + this.smartFormat, + this.tag, + this.utteranceEndMs, + this.vadEvents, + this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ModelStage builder() { + return new Builder(); + } + + public interface ModelStage { + /** + *

AI model to use for the transcription

+ */ + _FinalStage model(@NotNull ListenV1Model model); + + Builder from(V1ConnectOptions other); + } + + public interface _FinalStage { + V1ConnectOptions build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage callback(Optional callback); + + _FinalStage callback(ListenV1Callback callback); + + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod); + + _FinalStage channels(Optional channels); + + _FinalStage channels(ListenV1Channels channels); + + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(ListenV1DetectEntities detectEntities); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(ListenV1Diarize diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(DiarizeModel diarizeModel); + + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(ListenV1Dictation dictation); + + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(ListenV1Encoding encoding); + + _FinalStage endpointing(Optional endpointing); + + _FinalStage endpointing(ListenV1Endpointing endpointing); + + _FinalStage extra(Optional extra); + + _FinalStage extra(ListenV1Extra extra); + + _FinalStage interimResults(Optional interimResults); + + _FinalStage interimResults(ListenV1InterimResults interimResults); + + _FinalStage keyterm(Optional keyterm); + + _FinalStage keyterm(ListenV1Keyterm keyterm); + + _FinalStage keywords(Optional keywords); + + _FinalStage keywords(ListenV1Keywords keywords); + + _FinalStage language(Optional language); + + _FinalStage language(ListenV1Language language); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional languageHint) { + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(ListenV1LanguageHint languageHint) { + return this; + } + + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut); + + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(ListenV1Multichannel multichannel); + + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(ListenV1Numerals numerals); + + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter); + + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(ListenV1Punctuate punctuate); + + _FinalStage redact(Optional redact); + + _FinalStage redact(ListenV1Redact redact); + + _FinalStage replace(Optional replace); + + _FinalStage replace(ListenV1Replace replace); + + _FinalStage sampleRate(Optional sampleRate); + + _FinalStage sampleRate(ListenV1SampleRate sampleRate); + + _FinalStage search(Optional search); + + _FinalStage search(ListenV1Search search); + + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(ListenV1SmartFormat smartFormat); + + _FinalStage tag(Optional tag); + + _FinalStage tag(ListenV1Tag tag); + + _FinalStage utteranceEndMs(Optional utteranceEndMs); + + _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs); + + _FinalStage vadEvents(Optional vadEvents); + + _FinalStage vadEvents(ListenV1VadEvents vadEvents); + + _FinalStage version(Optional version); + + _FinalStage version(ListenV1Version version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ModelStage, _FinalStage { + private ListenV1Model model; + + private Optional version = Optional.empty(); + + private Optional vadEvents = Optional.empty(); + + private Optional utteranceEndMs = Optional.empty(); + + private Optional tag = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional search = Optional.empty(); + + private Optional sampleRate = Optional.empty(); + + private Optional replace = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional mipOptOut = Optional.empty(); + + private Optional languageHint = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional keywords = Optional.empty(); + + private Optional keyterm = Optional.empty(); + + private Optional interimResults = Optional.empty(); + + private Optional extra = Optional.empty(); + + private Optional endpointing = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional channels = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(V1ConnectOptions other) { + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + channels(other.getChannels()); + detectEntities(other.getDetectEntities()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + endpointing(other.getEndpointing()); + extra(other.getExtra()); + interimResults(other.getInterimResults()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + language(other.getLanguage()); + languageHint(other.getLanguageHint()); + mipOptOut(other.getMipOptOut()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + replace(other.getReplace()); + sampleRate(other.getSampleRate()); + search(other.getSearch()); + smartFormat(other.getSmartFormat()); + tag(other.getTag()); + utteranceEndMs(other.getUtteranceEndMs()); + vadEvents(other.getVadEvents()); + version(other.getVersion()); + return this; + } + + /** + *

AI model to use for the transcription

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public _FinalStage model(@NotNull ListenV1Model model) { + this.model = Objects.requireNonNull(model, "model must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage version(ListenV1Version version) { + this.version = Optional.ofNullable(version); + return this; + } + + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public _FinalStage vadEvents(ListenV1VadEvents vadEvents) { + this.vadEvents = Optional.ofNullable(vadEvents); + return this; + } + + @java.lang.Override + @JsonSetter(value = "vad_events", nulls = Nulls.SKIP) + public _FinalStage vadEvents(Optional vadEvents) { + this.vadEvents = vadEvents; + return this; + } + + @java.lang.Override + public _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs) { + this.utteranceEndMs = Optional.ofNullable(utteranceEndMs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "utterance_end_ms", nulls = Nulls.SKIP) + public _FinalStage utteranceEndMs(Optional utteranceEndMs) { + this.utteranceEndMs = utteranceEndMs; + return this; + } + + @java.lang.Override + public _FinalStage tag(ListenV1Tag tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage smartFormat(ListenV1SmartFormat smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + @java.lang.Override + public _FinalStage search(ListenV1Search search) { + this.search = Optional.ofNullable(search); + return this; + } + + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage sampleRate(ListenV1SampleRate sampleRate) { + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "sample_rate", nulls = Nulls.SKIP) + public _FinalStage sampleRate(Optional sampleRate) { + this.sampleRate = sampleRate; + return this; + } + + @java.lang.Override + public _FinalStage replace(ListenV1Replace replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage redact(ListenV1Redact redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + @java.lang.Override + public _FinalStage punctuate(ListenV1Punctuate punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + @java.lang.Override + public _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + @java.lang.Override + public _FinalStage numerals(ListenV1Numerals numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + @java.lang.Override + public _FinalStage multichannel(ListenV1Multichannel multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + @java.lang.Override + public _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(ListenV1LanguageHint languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage language(ListenV1Language language) { + this.language = Optional.ofNullable(language); + return this; + } + + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + @java.lang.Override + public _FinalStage keywords(ListenV1Keywords keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(ListenV1Keyterm keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage interimResults(ListenV1InterimResults interimResults) { + this.interimResults = Optional.ofNullable(interimResults); + return this; + } + + @java.lang.Override + @JsonSetter(value = "interim_results", nulls = Nulls.SKIP) + public _FinalStage interimResults(Optional interimResults) { + this.interimResults = interimResults; + return this; + } + + @java.lang.Override + public _FinalStage extra(ListenV1Extra extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public _FinalStage endpointing(ListenV1Endpointing endpointing) { + this.endpointing = Optional.ofNullable(endpointing); + return this; + } + + @java.lang.Override + @JsonSetter(value = "endpointing", nulls = Nulls.SKIP) + public _FinalStage endpointing(Optional endpointing) { + this.endpointing = endpointing; + return this; + } + + @java.lang.Override + public _FinalStage encoding(ListenV1Encoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + @java.lang.Override + public _FinalStage dictation(ListenV1Dictation dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(DiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(ListenV1Diarize diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + @java.lang.Override + public _FinalStage detectEntities(ListenV1DetectEntities detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + @java.lang.Override + public _FinalStage channels(ListenV1Channels channels) { + this.channels = Optional.ofNullable(channels); + return this; + } + + @java.lang.Override + @JsonSetter(value = "channels", nulls = Nulls.SKIP) + public _FinalStage channels(Optional channels) { + this.channels = channels; + return this; + } + + @java.lang.Override + public _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + @java.lang.Override + public _FinalStage callback(ListenV1Callback callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public V1ConnectOptions build() { + return new V1ConnectOptions( + callback, + callbackMethod, + channels, + detectEntities, + diarize, + diarizeModel, + dictation, + encoding, + endpointing, + extra, + interimResults, + keyterm, + keywords, + language, + languageHint, + mipOptOut, + model, + multichannel, + numerals, + profanityFilter, + punctuate, + redact, + replace, + sampleRate, + search, + smartFormat, + tag, + utteranceEndMs, + vadEvents, + version, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..885f60c --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,650 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.listen.v1.types.ListenV1CloseStream; +import com.deepgram.resources.listen.v1.types.ListenV1Configure; +import com.deepgram.resources.listen.v1.types.ListenV1ConfigureFailure; +import com.deepgram.resources.listen.v1.types.ListenV1ConfigureSuccess; +import com.deepgram.resources.listen.v1.types.ListenV1Error; +import com.deepgram.resources.listen.v1.types.ListenV1Finalize; +import com.deepgram.resources.listen.v1.types.ListenV1KeepAlive; +import com.deepgram.resources.listen.v1.types.ListenV1Metadata; +import com.deepgram.resources.listen.v1.types.ListenV1Results; +import com.deepgram.resources.listen.v1.types.ListenV1SpeechStarted; +import com.deepgram.resources.listen.v1.types.ListenV1UtteranceEnd; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer resultsHandler; + + private volatile Consumer metadataHandler; + + private volatile Consumer utteranceEndHandler; + + private volatile Consumer speechStartedHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V1ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v1/listen"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + if (options.getCallback() != null && options.getCallback().isPresent()) { + urlBuilder.addQueryParameter( + "callback", String.valueOf(options.getCallback().get())); + } + if (options.getCallbackMethod() != null && options.getCallbackMethod().isPresent()) { + urlBuilder.addQueryParameter( + "callback_method", + String.valueOf(options.getCallbackMethod().get())); + } + if (options.getChannels() != null && options.getChannels().isPresent()) { + urlBuilder.addQueryParameter( + "channels", String.valueOf(options.getChannels().get())); + } + if (options.getDetectEntities() != null && options.getDetectEntities().isPresent()) { + urlBuilder.addQueryParameter( + "detect_entities", + String.valueOf(options.getDetectEntities().get())); + } + if (options.getDiarize() != null && options.getDiarize().isPresent()) { + urlBuilder.addQueryParameter( + "diarize", String.valueOf(options.getDiarize().get())); + } + if (options.getDiarizeModel() != null && options.getDiarizeModel().isPresent()) { + urlBuilder.addQueryParameter( + "diarize_model", String.valueOf(options.getDiarizeModel().get())); + } + if (options.getDictation() != null && options.getDictation().isPresent()) { + urlBuilder.addQueryParameter( + "dictation", String.valueOf(options.getDictation().get())); + } + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getEndpointing() != null && options.getEndpointing().isPresent()) { + urlBuilder.addQueryParameter( + "endpointing", String.valueOf(options.getEndpointing().get())); + } + if (options.getExtra() != null && options.getExtra().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); + } + if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { + urlBuilder.addQueryParameter( + "interim_results", + String.valueOf(options.getInterimResults().get())); + } + if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + } + if (options.getKeywords() != null && options.getKeywords().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); + } + if (options.getLanguage() != null && options.getLanguage().isPresent()) { + urlBuilder.addQueryParameter( + "language", String.valueOf(options.getLanguage().get())); + } + if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getMultichannel() != null && options.getMultichannel().isPresent()) { + urlBuilder.addQueryParameter( + "multichannel", String.valueOf(options.getMultichannel().get())); + } + if (options.getNumerals() != null && options.getNumerals().isPresent()) { + urlBuilder.addQueryParameter( + "numerals", String.valueOf(options.getNumerals().get())); + } + if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { + urlBuilder.addQueryParameter( + "profanity_filter", + String.valueOf(options.getProfanityFilter().get())); + } + if (options.getPunctuate() != null && options.getPunctuate().isPresent()) { + urlBuilder.addQueryParameter( + "punctuate", String.valueOf(options.getPunctuate().get())); + } + if (options.getRedact() != null && options.getRedact().isPresent()) { + urlBuilder.addQueryParameter( + "redact", String.valueOf(options.getRedact().get())); + } + if (options.getReplace() != null && options.getReplace().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSearch() != null && options.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); + } + if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { + urlBuilder.addQueryParameter( + "smart_format", String.valueOf(options.getSmartFormat().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { + urlBuilder.addQueryParameter( + "utterance_end_ms", + String.valueOf(options.getUtteranceEndMs().get())); + } + if (options.getVadEvents() != null && options.getVadEvents().isPresent()) { + urlBuilder.addQueryParameter( + "vad_events", String.valueOf(options.getVadEvents().get())); + } + if (options.getVersion() != null && options.getVersion().isPresent()) { + urlBuilder.addQueryParameter( + "version", String.valueOf(options.getVersion().get())); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a ListenV1Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Sends a ListenV1Finalize message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFinalize(ListenV1Finalize message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1CloseStream message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCloseStream(ListenV1CloseStream message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1KeepAlive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendKeepAlive(ListenV1KeepAlive message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(ListenV1Configure message) { + return sendMessage(message); + } + + /** + * Registers a handler for ListenV1ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for ListenV1ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for ListenV1Results messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onResults(Consumer handler) { + this.resultsHandler = handler; + } + + /** + * Registers a handler for ListenV1Metadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onMetadata(Consumer handler) { + this.metadataHandler = handler; + } + + /** + * Registers a handler for ListenV1UtteranceEnd messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onUtteranceEnd(Consumer handler) { + this.utteranceEndHandler = handler; + } + + /** + * Registers a handler for ListenV1SpeechStarted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechStarted(Consumer handler) { + this.speechStartedHandler = handler; + } + + /** + * Registers a handler for ListenV1Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("transaction_key") + && node.has("request_id") + && node.has("sha256") + && node.has("created") + && node.has("duration") + && node.has("channels") + && "Metadata".equals(node.path("type").asText())) { + ListenV1Metadata metadataHandlerEvent = null; + try { + metadataHandlerEvent = objectMapper.treeToValue(node, ListenV1Metadata.class); + } catch (Exception e) { + } + if (metadataHandlerEvent != null) { + if (metadataHandler != null) { + metadataHandler.accept(metadataHandlerEvent); + } + return; + } + } + if (node.has("channel_index") + && node.has("duration") + && node.has("start") + && node.has("channel") + && node.has("metadata") + && "Results".equals(node.path("type").asText())) { + ListenV1Results resultsHandlerEvent = null; + try { + resultsHandlerEvent = objectMapper.treeToValue(node, ListenV1Results.class); + } catch (Exception e) { + } + if (resultsHandlerEvent != null) { + if (resultsHandler != null) { + resultsHandler.accept(resultsHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("code") + && node.has("description") + && "ConfigureFailure".equals(node.path("type").asText())) { + ListenV1ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); + } + return; + } + } + if (node.has("channel") + && node.has("last_word_end") + && "UtteranceEnd".equals(node.path("type").asText())) { + ListenV1UtteranceEnd utteranceEndHandlerEvent = null; + try { + utteranceEndHandlerEvent = objectMapper.treeToValue(node, ListenV1UtteranceEnd.class); + } catch (Exception e) { + } + if (utteranceEndHandlerEvent != null) { + if (utteranceEndHandler != null) { + utteranceEndHandler.accept(utteranceEndHandlerEvent); + } + return; + } + } + if (node.has("channel") + && node.has("timestamp") + && "SpeechStarted".equals(node.path("type").asText())) { + ListenV1SpeechStarted speechStartedHandlerEvent = null; + try { + speechStartedHandlerEvent = objectMapper.treeToValue(node, ListenV1SpeechStarted.class); + } catch (Exception e) { + } + if (speechStartedHandlerEvent != null) { + if (speechStartedHandler != null) { + speechStartedHandler.accept(speechStartedHandlerEvent); + } + return; + } + } + if (node.has("variant") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + ListenV1Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, ListenV1Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); + } + return; + } + } + if (node.has("request_id") + && "ConfigureSuccess".equals(node.path("type").asText())) { + ListenV1ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak new file mode 100644 index 0000000..c9f2f35 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV2CloseStream.Builder.class) +public final class ListenV2CloseStream { + private final Map additionalProperties; + + private ListenV2CloseStream(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "CloseStream"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV2CloseStream; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListenV2CloseStream other) { + return this; + } + + public ListenV2CloseStream build() { + return new ListenV2CloseStream(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak new file mode 100644 index 0000000..894bd3c --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV2ForceEndTurn.Builder.class) +public final class ListenV2ForceEndTurn { + private final Map additionalProperties; + + private ListenV2ForceEndTurn(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "ForceEndTurn"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV2ForceEndTurn; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListenV2ForceEndTurn other) { + return this; + } + + public ListenV2ForceEndTurn build() { + return new ListenV2ForceEndTurn(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak new file mode 100644 index 0000000..5f55fea --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak @@ -0,0 +1,563 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.listen.v2.types.ListenV2CloseStream; +import com.deepgram.resources.listen.v2.types.ListenV2Configure; +import com.deepgram.resources.listen.v2.types.ListenV2ConfigureFailure; +import com.deepgram.resources.listen.v2.types.ListenV2ConfigureSuccess; +import com.deepgram.resources.listen.v2.types.ListenV2Connected; +import com.deepgram.resources.listen.v2.types.ListenV2FatalError; +import com.deepgram.resources.listen.v2.types.ListenV2ForceEndTurn; +import com.deepgram.resources.listen.v2.types.ListenV2TurnInfo; +import com.deepgram.resources.listen.v2.types.ListenV2Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v2 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V2WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private final AtomicReference closeStreamSocket = new AtomicReference<>(); + + private volatile Consumer connectedHandler; + + private volatile Consumer turnInfoHandler; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v2 channel. + */ + public V2WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V2ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + closeStreamSocket.set(null); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v2/listen"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getEagerEotThreshold() != null + && options.getEagerEotThreshold().isPresent()) { + urlBuilder.addQueryParameter( + "eager_eot_threshold", + String.valueOf(options.getEagerEotThreshold().get())); + } + if (options.getEotThreshold() != null && options.getEotThreshold().isPresent()) { + urlBuilder.addQueryParameter( + "eot_threshold", String.valueOf(options.getEotThreshold().get())); + } + if (options.getEotTimeoutMs() != null && options.getEotTimeoutMs().isPresent()) { + urlBuilder.addQueryParameter( + "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); + } + if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + } + if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + } + if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { + urlBuilder.addQueryParameter( + "profanity_filter", + String.valueOf(options.getProfanityFilter().get())); + } + if (options.getNumerals() != null && options.getNumerals().isPresent()) { + urlBuilder.addQueryParameter( + "numerals", String.valueOf(options.getNumerals().get())); + } + if (options.getRedact() != null && options.getRedact().isPresent()) { + urlBuilder.addQueryParameter( + "redact", String.valueOf(options.getRedact().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + closeStreamSocket.set(null); + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + + @Override + protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { + return super.shouldReconnectAfterClose(webSocket, code, reason) + && (code != 1005 || closeStreamSocket.get() != webSocket); + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a ListenV2Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does + * not suppress reconnects because it might never reach the server. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCloseStream(ListenV2CloseStream message) { + return sendMessage(message, closeStreamSocket::set); + } + + /** + * Sends a ListenV2ForceEndTurn message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendForceEndTurn(ListenV2ForceEndTurn message) { + return sendMessage(message); + } + + /** + * Sends a ListenV2Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(ListenV2Configure message) { + return sendMessage(message); + } + + /** + * Registers a handler for ListenV2Connected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConnected(Consumer handler) { + this.connectedHandler = handler; + } + + /** + * Registers a handler for ListenV2TurnInfo messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onTurnInfo(Consumer handler) { + this.turnInfoHandler = handler; + } + + /** + * Registers a handler for ListenV2ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for ListenV2ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for ListenV2Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for ListenV2FatalError messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + return sendMessage(body, null); + } + + private CompletableFuture sendMessage(Object body, Consumer onSent) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json, onSent); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("request_id") + && node.has("sequence_id") + && node.has("event") + && node.has("turn_index") + && node.has("audio_window_start") + && node.has("audio_window_end") + && node.has("transcript") + && node.has("words") + && node.has("end_of_turn_confidence") + && "TurnInfo".equals(node.path("type").asText())) { + ListenV2TurnInfo turnInfoHandlerEvent = null; + try { + turnInfoHandlerEvent = objectMapper.treeToValue(node, ListenV2TurnInfo.class); + } catch (Exception e) { + } + if (turnInfoHandlerEvent != null) { + if (turnInfoHandler != null) { + turnInfoHandler.accept(turnInfoHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("thresholds") + && node.has("keyterms") + && node.has("sequence_id") + && "ConfigureSuccess".equals(node.path("type").asText())) { + ListenV2ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && node.has("code") + && node.has("description") + && "Warning".equals(node.path("type").asText())) { + ListenV2Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, ListenV2Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("sequence_id") + && node.has("code") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + ListenV2FatalError errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, ListenV2FatalError.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && "Connected".equals(node.path("type").asText())) { + ListenV2Connected connectedHandlerEvent = null; + try { + connectedHandlerEvent = objectMapper.treeToValue(node, ListenV2Connected.class); + } catch (Exception e) { + } + if (connectedHandlerEvent != null) { + if (connectedHandler != null) { + connectedHandler.accept(connectedHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && "ConfigureFailure".equals(node.path("type").asText())) { + ListenV2ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } + return; + } + } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..e6824a3 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,467 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.speak.v1.types.SpeakV1Clear; +import com.deepgram.resources.speak.v1.types.SpeakV1Cleared; +import com.deepgram.resources.speak.v1.types.SpeakV1Close; +import com.deepgram.resources.speak.v1.types.SpeakV1Flush; +import com.deepgram.resources.speak.v1.types.SpeakV1Flushed; +import com.deepgram.resources.speak.v1.types.SpeakV1Metadata; +import com.deepgram.resources.speak.v1.types.SpeakV1Text; +import com.deepgram.resources.speak.v1.types.SpeakV1Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer speakV1AudioHandler; + + private volatile Consumer metadataHandler; + + private volatile Consumer flushedHandler; + + private volatile Consumer clearedHandler; + + private volatile Consumer warningHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V1ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v1/speak"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getModel() != null && options.getModel().isPresent()) { + urlBuilder.addQueryParameter( + "model", String.valueOf(options.getModel().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSpeed() != null && options.getSpeed().isPresent()) { + urlBuilder.addQueryParameter( + "speed", String.valueOf(options.getSpeed().get())); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (speakV1AudioHandler != null) { + speakV1AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Establishes the WebSocket connection asynchronously with default options. + * @return a CompletableFuture that completes when the connection is established + */ + public CompletableFuture connect() { + return connect(V1ConnectOptions.builder().build()); + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a SpeakV1Text message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendText(SpeakV1Text message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Flush message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFlush(SpeakV1Flush message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Clear message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClear(SpeakV1Clear message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Close message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClose(SpeakV1Close message) { + return sendMessage(message); + } + + /** + * Registers a handler for SpeakV1Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakV1Audio(Consumer handler) { + this.speakV1AudioHandler = handler; + } + + /** + * Registers a handler for SpeakV1Metadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onMetadata(Consumer handler) { + this.metadataHandler = handler; + } + + /** + * Registers a handler for SpeakV1Flushed messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFlushed(Consumer handler) { + this.flushedHandler = handler; + } + + /** + * Registers a handler for SpeakV1Cleared messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onCleared(Consumer handler) { + this.clearedHandler = handler; + } + + /** + * Registers a handler for SpeakV1Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("request_id") + && node.has("model_name") + && node.has("model_version") + && node.has("model_uuid") + && "Metadata".equals(node.path("type").asText())) { + SpeakV1Metadata metadataHandlerEvent = null; + try { + metadataHandlerEvent = objectMapper.treeToValue(node, SpeakV1Metadata.class); + } catch (Exception e) { + } + if (metadataHandlerEvent != null) { + if (metadataHandler != null) { + metadataHandler.accept(metadataHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Warning".equals(node.path("type").asText())) { + SpeakV1Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, SpeakV1Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("type") && node.has("sequence_id")) { + SpeakV1Flushed flushedHandlerEvent = null; + try { + flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Flushed.class); + } catch (Exception e) { + } + if (flushedHandlerEvent != null) { + if (flushedHandler != null) { + flushedHandler.accept(flushedHandlerEvent); + } + return; + } + } + if (node.has("type") && node.has("sequence_id")) { + SpeakV1Cleared clearedHandlerEvent = null; + try { + clearedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Cleared.class); + } catch (Exception e) { + } + if (clearedHandlerEvent != null) { + if (clearedHandler != null) { + clearedHandler.accept(clearedHandlerEvent); + } + return; + } + } + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak new file mode 100644 index 0000000..7fecd79 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SpeakV2Close.Builder.class) +public final class SpeakV2Close { + private final Map additionalProperties; + + private SpeakV2Close(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "Close"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SpeakV2Close; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SpeakV2Close other) { + return this; + } + + public SpeakV2Close build() { + return new SpeakV2Close(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak new file mode 100644 index 0000000..f678e97 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SpeakV2ConfigureFailureCode { + public static final SpeakV2ConfigureFailureCode CONTROL_COMBINATION_INVALID = + new SpeakV2ConfigureFailureCode(Value.CONTROL_COMBINATION_INVALID, "CONTROL_COMBINATION_INVALID"); + + public static final SpeakV2ConfigureFailureCode SPEED_OUT_OF_RANGE = + new SpeakV2ConfigureFailureCode(Value.SPEED_OUT_OF_RANGE, "SPEED_OUT_OF_RANGE"); + + public static final SpeakV2ConfigureFailureCode SPEED_INCREMENT_INVALID = + new SpeakV2ConfigureFailureCode(Value.SPEED_INCREMENT_INVALID, "SPEED_INCREMENT_INVALID"); + + public static final SpeakV2ConfigureFailureCode INTERNAL_ERROR = + new SpeakV2ConfigureFailureCode(Value.INTERNAL_ERROR, "INTERNAL_ERROR"); + + public static final SpeakV2ConfigureFailureCode SPEED_NOT_SUPPORTED = + new SpeakV2ConfigureFailureCode(Value.SPEED_NOT_SUPPORTED, "SPEED_NOT_SUPPORTED"); + + private final Value value; + + private final String string; + + SpeakV2ConfigureFailureCode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SpeakV2ConfigureFailureCode + && this.string.equals(((SpeakV2ConfigureFailureCode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTROL_COMBINATION_INVALID: + return visitor.visitControlCombinationInvalid(); + case SPEED_OUT_OF_RANGE: + return visitor.visitSpeedOutOfRange(); + case SPEED_INCREMENT_INVALID: + return visitor.visitSpeedIncrementInvalid(); + case INTERNAL_ERROR: + return visitor.visitInternalError(); + case SPEED_NOT_SUPPORTED: + return visitor.visitSpeedNotSupported(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SpeakV2ConfigureFailureCode valueOf(String value) { + switch (value) { + case "CONTROL_COMBINATION_INVALID": + return CONTROL_COMBINATION_INVALID; + case "SPEED_OUT_OF_RANGE": + return SPEED_OUT_OF_RANGE; + case "SPEED_INCREMENT_INVALID": + return SPEED_INCREMENT_INVALID; + case "INTERNAL_ERROR": + return INTERNAL_ERROR; + case "SPEED_NOT_SUPPORTED": + return SPEED_NOT_SUPPORTED; + default: + return new SpeakV2ConfigureFailureCode(Value.UNKNOWN, value); + } + } + + public enum Value { + SPEED_OUT_OF_RANGE, + + SPEED_INCREMENT_INVALID, + + SPEED_NOT_SUPPORTED, + + CONTROL_COMBINATION_INVALID, + + INTERNAL_ERROR, + + UNKNOWN + } + + public interface Visitor { + T visitSpeedOutOfRange(); + + T visitSpeedIncrementInvalid(); + + T visitSpeedNotSupported(); + + default T visitControlCombinationInvalid() { + return visitUnknown("CONTROL_COMBINATION_INVALID"); + } + + T visitInternalError(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak new file mode 100644 index 0000000..130da0d --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SpeakV2Flush.Builder.class) +public final class SpeakV2Flush { + private final Map additionalProperties; + + private SpeakV2Flush(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "Flush"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SpeakV2Flush; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SpeakV2Flush other) { + return this; + } + + public SpeakV2Flush build() { + return new SpeakV2Flush(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak new file mode 100644 index 0000000..b4e01f7 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak @@ -0,0 +1,630 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.speak.v2.types.SpeakV2Close; +import com.deepgram.resources.speak.v2.types.SpeakV2Configure; +import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureFailure; +import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureSuccess; +import com.deepgram.resources.speak.v2.types.SpeakV2Connected; +import com.deepgram.resources.speak.v2.types.SpeakV2Error; +import com.deepgram.resources.speak.v2.types.SpeakV2Flush; +import com.deepgram.resources.speak.v2.types.SpeakV2Flushed; +import com.deepgram.resources.speak.v2.types.SpeakV2Interrupt; +import com.deepgram.resources.speak.v2.types.SpeakV2SessionMetadata; +import com.deepgram.resources.speak.v2.types.SpeakV2Speak; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechInterrupted; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechMetadata; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechStarted; +import com.deepgram.resources.speak.v2.types.SpeakV2Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v2 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V2WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer speakV2AudioHandler; + + private volatile Consumer connectedHandler; + + private volatile Consumer speechStartedHandler; + + private volatile Consumer speechMetadataHandler; + + private volatile Consumer speechInterruptedHandler; + + private volatile Consumer flushedHandler; + + private volatile Consumer sessionMetadataHandler; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v2 channel. + */ + public V2WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V2ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v2/speak"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSpeed() != null && options.getSpeed().isPresent()) { + urlBuilder.addQueryParameter( + "speed", String.valueOf(options.getSpeed().get())); + } + if (options.getExpressivity() != null && options.getExpressivity().isPresent()) { + urlBuilder.addQueryParameter( + "expressivity", String.valueOf(options.getExpressivity().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (speakV2AudioHandler != null) { + speakV2AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a SpeakV2Speak message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendSpeak(SpeakV2Speak message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Flush message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFlush(SpeakV2Flush message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Interrupt message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInterrupt(SpeakV2Interrupt message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(SpeakV2Configure message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Close message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClose(SpeakV2Close message) { + return sendMessage(message); + } + + /** + * Registers a handler for SpeakV2Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakV2Audio(Consumer handler) { + this.speakV2AudioHandler = handler; + } + + /** + * Registers a handler for SpeakV2Connected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConnected(Consumer handler) { + this.connectedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechStarted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechStarted(Consumer handler) { + this.speechStartedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechMetadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechMetadata(Consumer handler) { + this.speechMetadataHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechInterrupted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechInterrupted(Consumer handler) { + this.speechInterruptedHandler = handler; + } + + /** + * Registers a handler for SpeakV2Flushed messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFlushed(Consumer handler) { + this.flushedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SessionMetadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSessionMetadata(Consumer handler) { + this.sessionMetadataHandler = handler; + } + + /** + * Registers a handler for SpeakV2ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for SpeakV2ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for SpeakV2Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for SpeakV2Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("speech_id") + && node.has("audio_duration_ms") + && node.has("input_character_count") + && node.has("billable_character_count") + && node.has("controls_applied") + && "SpeechMetadata".equals(node.path("type").asText())) { + SpeakV2SpeechMetadata speechMetadataHandlerEvent = null; + try { + speechMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechMetadata.class); + } catch (Exception e) { + } + if (speechMetadataHandlerEvent != null) { + if (speechMetadataHandler != null) { + speechMetadataHandler.accept(speechMetadataHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("model_name") + && node.has("model_version") + && node.has("model_uuids") + && "Connected".equals(node.path("type").asText())) { + SpeakV2Connected connectedHandlerEvent = null; + try { + connectedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Connected.class); + } catch (Exception e) { + } + if (connectedHandlerEvent != null) { + if (connectedHandler != null) { + connectedHandler.accept(connectedHandlerEvent); + } + return; + } + } + if (node.has("total_audio_duration_ms") + && node.has("total_input_character_count") + && node.has("total_billable_character_count") + && "SessionMetadata".equals(node.path("type").asText())) { + SpeakV2SessionMetadata sessionMetadataHandlerEvent = null; + try { + sessionMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SessionMetadata.class); + } catch (Exception e) { + } + if (sessionMetadataHandlerEvent != null) { + if (sessionMetadataHandler != null) { + sessionMetadataHandler.accept(sessionMetadataHandlerEvent); + } + return; + } + } + if (node.has("audio_played_ms") + && node.has("metadata") + && "SpeechInterrupted".equals(node.path("type").asText())) { + SpeakV2SpeechInterrupted speechInterruptedHandlerEvent = null; + try { + speechInterruptedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechInterrupted.class); + } catch (Exception e) { + } + if (speechInterruptedHandlerEvent != null) { + if (speechInterruptedHandler != null) { + speechInterruptedHandler.accept(speechInterruptedHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "ConfigureFailure".equals(node.path("type").asText())) { + SpeakV2ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "Warning".equals(node.path("type").asText())) { + SpeakV2Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, SpeakV2Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + SpeakV2Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, SpeakV2Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("speech_id") + && "SpeechStarted".equals(node.path("type").asText())) { + SpeakV2SpeechStarted speechStartedHandlerEvent = null; + try { + speechStartedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechStarted.class); + } catch (Exception e) { + } + if (speechStartedHandlerEvent != null) { + if (speechStartedHandler != null) { + speechStartedHandler.accept(speechStartedHandlerEvent); + } + return; + } + } + if (node.has("speech_id") && "Flushed".equals(node.path("type").asText())) { + SpeakV2Flushed flushedHandlerEvent = null; + try { + flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Flushed.class); + } catch (Exception e) { + } + if (flushedHandlerEvent != null) { + if (flushedHandler != null) { + flushedHandler.accept(flushedHandlerEvent); + } + return; + } + } + if (node.has("applied") + && "ConfigureSuccess".equals(node.path("type").asText())) { + SpeakV2ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java.bak b/src/main/java/com/deepgram/types/DeepgramModel.java.bak new file mode 100644 index 0000000..9fa2f8b --- /dev/null +++ b/src/main/java/com/deepgram/types/DeepgramModel.java.bak @@ -0,0 +1,1081 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DeepgramModel { + public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); + + public static final DeepgramModel AURA2HERA_EN = new DeepgramModel(Value.AURA2HERA_EN, "aura-2-hera-en"); + + public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); + + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); + + public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); + + public static final DeepgramModel AURA2HARMONIA_EN = + new DeepgramModel(Value.AURA2HARMONIA_EN, "aura-2-harmonia-en"); + + public static final DeepgramModel AURA2CARINA_ES = new DeepgramModel(Value.AURA2CARINA_ES, "aura-2-carina-es"); + + public static final DeepgramModel FLUX_MEENA_EN = new DeepgramModel(Value.FLUX_MEENA_EN, "flux-meena-en"); + + public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); + + public static final DeepgramModel AURA_ZEUS_EN = new DeepgramModel(Value.AURA_ZEUS_EN, "aura-zeus-en"); + + public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); + + public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); + + public static final DeepgramModel AURA2NEPTUNE_EN = new DeepgramModel(Value.AURA2NEPTUNE_EN, "aura-2-neptune-en"); + + public static final DeepgramModel FLUX_BROOKE_EN = new DeepgramModel(Value.FLUX_BROOKE_EN, "flux-brooke-en"); + + public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); + + public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); + + public static final DeepgramModel AURA2CALLISTA_EN = + new DeepgramModel(Value.AURA2CALLISTA_EN, "aura-2-callista-en"); + + public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); + + public static final DeepgramModel AURA2OPHELIA_EN = new DeepgramModel(Value.AURA2OPHELIA_EN, "aura-2-ophelia-en"); + + public static final DeepgramModel FLUX_BRUCE_EN = new DeepgramModel(Value.FLUX_BRUCE_EN, "flux-bruce-en"); + + public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); + + public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); + + public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); + + public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); + + public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); + + public static final DeepgramModel FLUX_MARCUS_EN = new DeepgramModel(Value.FLUX_MARCUS_EN, "flux-marcus-en"); + + public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); + + public static final DeepgramModel FLUX_PAIGE_EN = new DeepgramModel(Value.FLUX_PAIGE_EN, "flux-paige-en"); + + public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); + + public static final DeepgramModel FLUX_DREW_EN = new DeepgramModel(Value.FLUX_DREW_EN, "flux-drew-en"); + + public static final DeepgramModel AURA2JAVIER_ES = new DeepgramModel(Value.AURA2JAVIER_ES, "aura-2-javier-es"); + + public static final DeepgramModel AURA2ANDROMEDA_EN = + new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); + + public static final DeepgramModel AURA2SATURN_EN = new DeepgramModel(Value.AURA2SATURN_EN, "aura-2-saturn-en"); + + public static final DeepgramModel AURA2IRIS_EN = new DeepgramModel(Value.AURA2IRIS_EN, "aura-2-iris-en"); + + public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); + + public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); + + public static final DeepgramModel FLUX_BRITTANY_EN = new DeepgramModel(Value.FLUX_BRITTANY_EN, "flux-brittany-en"); + + public static final DeepgramModel FLUX_SEAN_EN = new DeepgramModel(Value.FLUX_SEAN_EN, "flux-sean-en"); + + public static final DeepgramModel AURA2HELENA_EN = new DeepgramModel(Value.AURA2HELENA_EN, "aura-2-helena-en"); + + public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); + + public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); + + public static final DeepgramModel FLUX_JACK_EN = new DeepgramModel(Value.FLUX_JACK_EN, "flux-jack-en"); + + public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); + + public static final DeepgramModel FLUX_PRIYA_EN = new DeepgramModel(Value.FLUX_PRIYA_EN, "flux-priya-en"); + + public static final DeepgramModel AURA_HELIOS_EN = new DeepgramModel(Value.AURA_HELIOS_EN, "aura-helios-en"); + + public static final DeepgramModel AURA2JANUS_EN = new DeepgramModel(Value.AURA2JANUS_EN, "aura-2-janus-en"); + + public static final DeepgramModel AURA2NESTOR_ES = new DeepgramModel(Value.AURA2NESTOR_ES, "aura-2-nestor-es"); + + public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); + + public static final DeepgramModel AURA2MINERVA_EN = new DeepgramModel(Value.AURA2MINERVA_EN, "aura-2-minerva-en"); + + public static final DeepgramModel AURA2ALVARO_ES = new DeepgramModel(Value.AURA2ALVARO_ES, "aura-2-alvaro-es"); + + public static final DeepgramModel AURA_PERSEUS_EN = new DeepgramModel(Value.AURA_PERSEUS_EN, "aura-perseus-en"); + + public static final DeepgramModel AURA2VESTA_EN = new DeepgramModel(Value.AURA2VESTA_EN, "aura-2-vesta-en"); + + public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); + + public static final DeepgramModel AURA2ZEUS_EN = new DeepgramModel(Value.AURA2ZEUS_EN, "aura-2-zeus-en"); + + public static final DeepgramModel AURA2ORPHEUS_EN = new DeepgramModel(Value.AURA2ORPHEUS_EN, "aura-2-orpheus-en"); + + public static final DeepgramModel AURA2THALIA_EN = new DeepgramModel(Value.AURA2THALIA_EN, "aura-2-thalia-en"); + + public static final DeepgramModel FLUX_NAVEEN_EN = new DeepgramModel(Value.FLUX_NAVEEN_EN, "flux-naveen-en"); + + public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); + + public static final DeepgramModel AURA2SELENA_ES = new DeepgramModel(Value.AURA2SELENA_ES, "aura-2-selena-es"); + + public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); + + public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); + + public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); + + public static final DeepgramModel AURA_LUNA_EN = new DeepgramModel(Value.AURA_LUNA_EN, "aura-luna-en"); + + public static final DeepgramModel AURA_ORPHEUS_EN = new DeepgramModel(Value.AURA_ORPHEUS_EN, "aura-orpheus-en"); + + public static final DeepgramModel AURA2AMALTHEA_EN = + new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); + + public static final DeepgramModel FLUX_DONOVAN_EN = new DeepgramModel(Value.FLUX_DONOVAN_EN, "flux-donovan-en"); + + public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); + + public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); + + public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); + + public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); + + public static final DeepgramModel AURA2PHOEBE_EN = new DeepgramModel(Value.AURA2PHOEBE_EN, "aura-2-phoebe-en"); + + public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); + + public static final DeepgramModel AURA2DIANA_ES = new DeepgramModel(Value.AURA2DIANA_ES, "aura-2-diana-es"); + + public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); + + public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); + + public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); + + public static final DeepgramModel AURA2THEIA_EN = new DeepgramModel(Value.AURA2THEIA_EN, "aura-2-theia-en"); + + public static final DeepgramModel FLUX_WADE_EN = new DeepgramModel(Value.FLUX_WADE_EN, "flux-wade-en"); + + public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); + + public static final DeepgramModel FLUX_CLIFF_EN = new DeepgramModel(Value.FLUX_CLIFF_EN, "flux-cliff-en"); + + public static final DeepgramModel AURA2JUPITER_EN = new DeepgramModel(Value.AURA2JUPITER_EN, "aura-2-jupiter-en"); + + public static final DeepgramModel FLUX_KIT_EN = new DeepgramModel(Value.FLUX_KIT_EN, "flux-kit-en"); + + public static final DeepgramModel AURA2AQUILA_ES = new DeepgramModel(Value.AURA2AQUILA_ES, "aura-2-aquila-es"); + + public static final DeepgramModel AURA2CORA_EN = new DeepgramModel(Value.AURA2CORA_EN, "aura-2-cora-en"); + + public static final DeepgramModel AURA2CORDELIA_EN = + new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); + + public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); + + public static final DeepgramModel AURA2HYPERION_EN = + new DeepgramModel(Value.AURA2HYPERION_EN, "aura-2-hyperion-en"); + + public static final DeepgramModel AURA2CELESTE_ES = new DeepgramModel(Value.AURA2CELESTE_ES, "aura-2-celeste-es"); + + public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); + + public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); + + public static final DeepgramModel AURA2ARCAS_EN = new DeepgramModel(Value.AURA2ARCAS_EN, "aura-2-arcas-en"); + + public static final DeepgramModel FLUX_COLIN_EN = new DeepgramModel(Value.FLUX_COLIN_EN, "flux-colin-en"); + + public static final DeepgramModel AURA_ATHENA_EN = new DeepgramModel(Value.AURA_ATHENA_EN, "aura-athena-en"); + + public static final DeepgramModel AURA2ODYSSEUS_EN = + new DeepgramModel(Value.AURA2ODYSSEUS_EN, "aura-2-odysseus-en"); + + public static final DeepgramModel AURA2PANDORA_EN = new DeepgramModel(Value.AURA2PANDORA_EN, "aura-2-pandora-en"); + + public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); + + public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); + + public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); + + public static final DeepgramModel FLUX_GEMMA_EN = new DeepgramModel(Value.FLUX_GEMMA_EN, "flux-gemma-en"); + + public static final DeepgramModel AURA2ESTRELLA_ES = + new DeepgramModel(Value.AURA2ESTRELLA_ES, "aura-2-estrella-es"); + + private final Value value; + + private final String string; + + DeepgramModel(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof DeepgramModel && this.string.equals(((DeepgramModel) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AURA2SIRIO_ES: + return visitor.visitAura2SirioEs(); + case AURA2HERA_EN: + return visitor.visitAura2HeraEn(); + case FLUX_KELSEY_EN: + return visitor.visitFluxKelseyEn(); + case FLUX_RENEE_EN: + return visitor.visitFluxReneeEn(); + case FLUX_SIENNA_EN: + return visitor.visitFluxSiennaEn(); + case AURA2HARMONIA_EN: + return visitor.visitAura2HarmoniaEn(); + case AURA2CARINA_ES: + return visitor.visitAura2CarinaEs(); + case FLUX_MEENA_EN: + return visitor.visitFluxMeenaEn(); + case FLUX_MEGHAN_EN: + return visitor.visitFluxMeghanEn(); + case AURA_ZEUS_EN: + return visitor.visitAuraZeusEn(); + case AURA2HERMES_EN: + return visitor.visitAura2HermesEn(); + case FLUX_CONOR_EN: + return visitor.visitFluxConorEn(); + case AURA2NEPTUNE_EN: + return visitor.visitAura2NeptuneEn(); + case FLUX_BROOKE_EN: + return visitor.visitFluxBrookeEn(); + case FLUX_RUFUS_EN: + return visitor.visitFluxRufusEn(); + case FLUX_WES_EN: + return visitor.visitFluxWesEn(); + case AURA2CALLISTA_EN: + return visitor.visitAura2CallistaEn(); + case AURA2AURORA_EN: + return visitor.visitAura2AuroraEn(); + case AURA2OPHELIA_EN: + return visitor.visitAura2OpheliaEn(); + case FLUX_BRUCE_EN: + return visitor.visitFluxBruceEn(); + case AURA2APOLLO_EN: + return visitor.visitAura2ApolloEn(); + case AURA2DELIA_EN: + return visitor.visitAura2DeliaEn(); + case AURA2MARS_EN: + return visitor.visitAura2MarsEn(); + case AURA_HERA_EN: + return visitor.visitAuraHeraEn(); + case FLUX_MAEVE_EN: + return visitor.visitFluxMaeveEn(); + case FLUX_MARCUS_EN: + return visitor.visitFluxMarcusEn(); + case AURA2ARIES_EN: + return visitor.visitAura2AriesEn(); + case FLUX_PAIGE_EN: + return visitor.visitFluxPaigeEn(); + case AURA2JUNO_EN: + return visitor.visitAura2JunoEn(); + case FLUX_DREW_EN: + return visitor.visitFluxDrewEn(); + case AURA2JAVIER_ES: + return visitor.visitAura2JavierEs(); + case AURA2ANDROMEDA_EN: + return visitor.visitAura2AndromedaEn(); + case AURA2SATURN_EN: + return visitor.visitAura2SaturnEn(); + case AURA2IRIS_EN: + return visitor.visitAura2IrisEn(); + case AURA_ANGUS_EN: + return visitor.visitAuraAngusEn(); + case FLUX_KAI_EN: + return visitor.visitFluxKaiEn(); + case FLUX_BRITTANY_EN: + return visitor.visitFluxBrittanyEn(); + case FLUX_SEAN_EN: + return visitor.visitFluxSeanEn(); + case AURA2HELENA_EN: + return visitor.visitAura2HelenaEn(); + case FLUX_HALEY_EN: + return visitor.visitFluxHaleyEn(); + case AURA_STELLA_EN: + return visitor.visitAuraStellaEn(); + case FLUX_JACK_EN: + return visitor.visitFluxJackEn(); + case AURA2DRACO_EN: + return visitor.visitAura2DracoEn(); + case FLUX_PRIYA_EN: + return visitor.visitFluxPriyaEn(); + case AURA_HELIOS_EN: + return visitor.visitAuraHeliosEn(); + case AURA2JANUS_EN: + return visitor.visitAura2JanusEn(); + case AURA2NESTOR_ES: + return visitor.visitAura2NestorEs(); + case AURA2ORION_EN: + return visitor.visitAura2OrionEn(); + case AURA2MINERVA_EN: + return visitor.visitAura2MinervaEn(); + case AURA2ALVARO_ES: + return visitor.visitAura2AlvaroEs(); + case AURA_PERSEUS_EN: + return visitor.visitAuraPerseusEn(); + case AURA2VESTA_EN: + return visitor.visitAura2VestaEn(); + case FLUX_COLE_EN: + return visitor.visitFluxColeEn(); + case AURA2ZEUS_EN: + return visitor.visitAura2ZeusEn(); + case AURA2ORPHEUS_EN: + return visitor.visitAura2OrpheusEn(); + case AURA2THALIA_EN: + return visitor.visitAura2ThaliaEn(); + case FLUX_NAVEEN_EN: + return visitor.visitFluxNaveenEn(); + case AURA2ASTERIA_EN: + return visitor.visitAura2AsteriaEn(); + case AURA2SELENA_ES: + return visitor.visitAura2SelenaEs(); + case FLUX_MARCELO_EN: + return visitor.visitFluxMarceloEn(); + case FLUX_ELISE_EN: + return visitor.visitFluxEliseEn(); + case FLUX_ALEXIS_EN: + return visitor.visitFluxAlexisEn(); + case AURA_LUNA_EN: + return visitor.visitAuraLunaEn(); + case AURA_ORPHEUS_EN: + return visitor.visitAuraOrpheusEn(); + case AURA2AMALTHEA_EN: + return visitor.visitAura2AmaltheaEn(); + case FLUX_DONOVAN_EN: + return visitor.visitFluxDonovanEn(); + case AURA2SELENE_EN: + return visitor.visitAura2SeleneEn(); + case FLUX_TANNER_EN: + return visitor.visitFluxTannerEn(); + case FLUX_SHARON_EN: + return visitor.visitFluxSharonEn(); + case AURA2LUNA_EN: + return visitor.visitAura2LunaEn(); + case AURA2PHOEBE_EN: + return visitor.visitAura2PhoebeEn(); + case FLUX_HANNAH_EN: + return visitor.visitFluxHannahEn(); + case AURA2DIANA_ES: + return visitor.visitAura2DianaEs(); + case AURA_ORION_EN: + return visitor.visitAuraOrionEn(); + case AURA2ATHENA_EN: + return visitor.visitAura2AthenaEn(); + case AURA_ARCAS_EN: + return visitor.visitAuraArcasEn(); + case AURA2THEIA_EN: + return visitor.visitAura2TheiaEn(); + case FLUX_WADE_EN: + return visitor.visitFluxWadeEn(); + case FLUX_HEATHER_EN: + return visitor.visitFluxHeatherEn(); + case FLUX_CLIFF_EN: + return visitor.visitFluxCliffEn(); + case AURA2JUPITER_EN: + return visitor.visitAura2JupiterEn(); + case FLUX_KIT_EN: + return visitor.visitFluxKitEn(); + case AURA2AQUILA_ES: + return visitor.visitAura2AquilaEs(); + case AURA2CORA_EN: + return visitor.visitAura2CoraEn(); + case AURA2CORDELIA_EN: + return visitor.visitAura2CordeliaEn(); + case AURA2ATLAS_EN: + return visitor.visitAura2AtlasEn(); + case AURA2HYPERION_EN: + return visitor.visitAura2HyperionEn(); + case AURA2CELESTE_ES: + return visitor.visitAura2CelesteEs(); + case AURA2PLUTO_EN: + return visitor.visitAura2PlutoEn(); + case FLUX_BREE_EN: + return visitor.visitFluxBreeEn(); + case AURA2ARCAS_EN: + return visitor.visitAura2ArcasEn(); + case FLUX_COLIN_EN: + return visitor.visitFluxColinEn(); + case AURA_ATHENA_EN: + return visitor.visitAuraAthenaEn(); + case AURA2ODYSSEUS_EN: + return visitor.visitAura2OdysseusEn(); + case AURA2PANDORA_EN: + return visitor.visitAura2PandoraEn(); + case FLUX_MILES_EN: + return visitor.visitFluxMilesEn(); + case AURA_ASTERIA_EN: + return visitor.visitAuraAsteriaEn(); + case AURA2ELECTRA_EN: + return visitor.visitAura2ElectraEn(); + case FLUX_GEMMA_EN: + return visitor.visitFluxGemmaEn(); + case AURA2ESTRELLA_ES: + return visitor.visitAura2EstrellaEs(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeepgramModel valueOf(String value) { + switch (value) { + case "aura-2-sirio-es": + return AURA2SIRIO_ES; + case "aura-2-hera-en": + return AURA2HERA_EN; + case "flux-kelsey-en": + return FLUX_KELSEY_EN; + case "flux-renee-en": + return FLUX_RENEE_EN; + case "flux-sienna-en": + return FLUX_SIENNA_EN; + case "aura-2-harmonia-en": + return AURA2HARMONIA_EN; + case "aura-2-carina-es": + return AURA2CARINA_ES; + case "flux-meena-en": + return FLUX_MEENA_EN; + case "flux-meghan-en": + return FLUX_MEGHAN_EN; + case "aura-zeus-en": + return AURA_ZEUS_EN; + case "aura-2-hermes-en": + return AURA2HERMES_EN; + case "flux-conor-en": + return FLUX_CONOR_EN; + case "aura-2-neptune-en": + return AURA2NEPTUNE_EN; + case "flux-brooke-en": + return FLUX_BROOKE_EN; + case "flux-rufus-en": + return FLUX_RUFUS_EN; + case "flux-wes-en": + return FLUX_WES_EN; + case "aura-2-callista-en": + return AURA2CALLISTA_EN; + case "aura-2-aurora-en": + return AURA2AURORA_EN; + case "aura-2-ophelia-en": + return AURA2OPHELIA_EN; + case "flux-bruce-en": + return FLUX_BRUCE_EN; + case "aura-2-apollo-en": + return AURA2APOLLO_EN; + case "aura-2-delia-en": + return AURA2DELIA_EN; + case "aura-2-mars-en": + return AURA2MARS_EN; + case "aura-hera-en": + return AURA_HERA_EN; + case "flux-maeve-en": + return FLUX_MAEVE_EN; + case "flux-marcus-en": + return FLUX_MARCUS_EN; + case "aura-2-aries-en": + return AURA2ARIES_EN; + case "flux-paige-en": + return FLUX_PAIGE_EN; + case "aura-2-juno-en": + return AURA2JUNO_EN; + case "flux-drew-en": + return FLUX_DREW_EN; + case "aura-2-javier-es": + return AURA2JAVIER_ES; + case "aura-2-andromeda-en": + return AURA2ANDROMEDA_EN; + case "aura-2-saturn-en": + return AURA2SATURN_EN; + case "aura-2-iris-en": + return AURA2IRIS_EN; + case "aura-angus-en": + return AURA_ANGUS_EN; + case "flux-kai-en": + return FLUX_KAI_EN; + case "flux-brittany-en": + return FLUX_BRITTANY_EN; + case "flux-sean-en": + return FLUX_SEAN_EN; + case "aura-2-helena-en": + return AURA2HELENA_EN; + case "flux-haley-en": + return FLUX_HALEY_EN; + case "aura-stella-en": + return AURA_STELLA_EN; + case "flux-jack-en": + return FLUX_JACK_EN; + case "aura-2-draco-en": + return AURA2DRACO_EN; + case "flux-priya-en": + return FLUX_PRIYA_EN; + case "aura-helios-en": + return AURA_HELIOS_EN; + case "aura-2-janus-en": + return AURA2JANUS_EN; + case "aura-2-nestor-es": + return AURA2NESTOR_ES; + case "aura-2-orion-en": + return AURA2ORION_EN; + case "aura-2-minerva-en": + return AURA2MINERVA_EN; + case "aura-2-alvaro-es": + return AURA2ALVARO_ES; + case "aura-perseus-en": + return AURA_PERSEUS_EN; + case "aura-2-vesta-en": + return AURA2VESTA_EN; + case "flux-cole-en": + return FLUX_COLE_EN; + case "aura-2-zeus-en": + return AURA2ZEUS_EN; + case "aura-2-orpheus-en": + return AURA2ORPHEUS_EN; + case "aura-2-thalia-en": + return AURA2THALIA_EN; + case "flux-naveen-en": + return FLUX_NAVEEN_EN; + case "aura-2-asteria-en": + return AURA2ASTERIA_EN; + case "aura-2-selena-es": + return AURA2SELENA_ES; + case "flux-marcelo-en": + return FLUX_MARCELO_EN; + case "flux-elise-en": + return FLUX_ELISE_EN; + case "flux-alexis-en": + return FLUX_ALEXIS_EN; + case "aura-luna-en": + return AURA_LUNA_EN; + case "aura-orpheus-en": + return AURA_ORPHEUS_EN; + case "aura-2-amalthea-en": + return AURA2AMALTHEA_EN; + case "flux-donovan-en": + return FLUX_DONOVAN_EN; + case "aura-2-selene-en": + return AURA2SELENE_EN; + case "flux-tanner-en": + return FLUX_TANNER_EN; + case "flux-sharon-en": + return FLUX_SHARON_EN; + case "aura-2-luna-en": + return AURA2LUNA_EN; + case "aura-2-phoebe-en": + return AURA2PHOEBE_EN; + case "flux-hannah-en": + return FLUX_HANNAH_EN; + case "aura-2-diana-es": + return AURA2DIANA_ES; + case "aura-orion-en": + return AURA_ORION_EN; + case "aura-2-athena-en": + return AURA2ATHENA_EN; + case "aura-arcas-en": + return AURA_ARCAS_EN; + case "aura-2-theia-en": + return AURA2THEIA_EN; + case "flux-wade-en": + return FLUX_WADE_EN; + case "flux-heather-en": + return FLUX_HEATHER_EN; + case "flux-cliff-en": + return FLUX_CLIFF_EN; + case "aura-2-jupiter-en": + return AURA2JUPITER_EN; + case "flux-kit-en": + return FLUX_KIT_EN; + case "aura-2-aquila-es": + return AURA2AQUILA_ES; + case "aura-2-cora-en": + return AURA2CORA_EN; + case "aura-2-cordelia-en": + return AURA2CORDELIA_EN; + case "aura-2-atlas-en": + return AURA2ATLAS_EN; + case "aura-2-hyperion-en": + return AURA2HYPERION_EN; + case "aura-2-celeste-es": + return AURA2CELESTE_ES; + case "aura-2-pluto-en": + return AURA2PLUTO_EN; + case "flux-bree-en": + return FLUX_BREE_EN; + case "aura-2-arcas-en": + return AURA2ARCAS_EN; + case "flux-colin-en": + return FLUX_COLIN_EN; + case "aura-athena-en": + return AURA_ATHENA_EN; + case "aura-2-odysseus-en": + return AURA2ODYSSEUS_EN; + case "aura-2-pandora-en": + return AURA2PANDORA_EN; + case "flux-miles-en": + return FLUX_MILES_EN; + case "aura-asteria-en": + return AURA_ASTERIA_EN; + case "aura-2-electra-en": + return AURA2ELECTRA_EN; + case "flux-gemma-en": + return FLUX_GEMMA_EN; + case "aura-2-estrella-es": + return AURA2ESTRELLA_ES; + default: + return new DeepgramModel(Value.UNKNOWN, value); + } + } + + public enum Value { + AURA_ASTERIA_EN, + + AURA_LUNA_EN, + + AURA_STELLA_EN, + + AURA_ATHENA_EN, + + AURA_HERA_EN, + + AURA_ORION_EN, + + AURA_ARCAS_EN, + + AURA_PERSEUS_EN, + + AURA_ANGUS_EN, + + AURA_ORPHEUS_EN, + + AURA_HELIOS_EN, + + AURA_ZEUS_EN, + + AURA2AMALTHEA_EN, + + AURA2ANDROMEDA_EN, + + AURA2APOLLO_EN, + + AURA2ARCAS_EN, + + AURA2ARIES_EN, + + AURA2ASTERIA_EN, + + AURA2ATHENA_EN, + + AURA2ATLAS_EN, + + AURA2AURORA_EN, + + AURA2CALLISTA_EN, + + AURA2CORA_EN, + + AURA2CORDELIA_EN, + + AURA2DELIA_EN, + + AURA2DRACO_EN, + + AURA2ELECTRA_EN, + + AURA2HARMONIA_EN, + + AURA2HELENA_EN, + + AURA2HERA_EN, + + AURA2HERMES_EN, + + AURA2HYPERION_EN, + + AURA2IRIS_EN, + + AURA2JANUS_EN, + + AURA2JUNO_EN, + + AURA2JUPITER_EN, + + AURA2LUNA_EN, + + AURA2MARS_EN, + + AURA2MINERVA_EN, + + AURA2NEPTUNE_EN, + + AURA2ODYSSEUS_EN, + + AURA2OPHELIA_EN, + + AURA2ORION_EN, + + AURA2ORPHEUS_EN, + + AURA2PANDORA_EN, + + AURA2PHOEBE_EN, + + AURA2PLUTO_EN, + + AURA2SATURN_EN, + + AURA2SELENE_EN, + + AURA2THALIA_EN, + + AURA2THEIA_EN, + + AURA2VESTA_EN, + + AURA2ZEUS_EN, + + AURA2SIRIO_ES, + + AURA2NESTOR_ES, + + AURA2CARINA_ES, + + AURA2CELESTE_ES, + + AURA2ALVARO_ES, + + AURA2DIANA_ES, + + AURA2AQUILA_ES, + + AURA2SELENA_ES, + + AURA2ESTRELLA_ES, + + AURA2JAVIER_ES, + + FLUX_ALEXIS_EN, + + FLUX_BREE_EN, + + FLUX_BRITTANY_EN, + + FLUX_BROOKE_EN, + + FLUX_BRUCE_EN, + + FLUX_CLIFF_EN, + + FLUX_COLE_EN, + + FLUX_COLIN_EN, + + FLUX_CONOR_EN, + + FLUX_DONOVAN_EN, + + FLUX_DREW_EN, + + FLUX_ELISE_EN, + + FLUX_GEMMA_EN, + + FLUX_HALEY_EN, + + FLUX_HANNAH_EN, + + FLUX_HEATHER_EN, + + FLUX_JACK_EN, + + FLUX_KAI_EN, + + FLUX_KELSEY_EN, + + FLUX_RENEE_EN, + + FLUX_KIT_EN, + + FLUX_MAEVE_EN, + + FLUX_MARCELO_EN, + + FLUX_MARCUS_EN, + + FLUX_MEENA_EN, + + FLUX_MEGHAN_EN, + + FLUX_MILES_EN, + + FLUX_NAVEEN_EN, + + FLUX_PAIGE_EN, + + FLUX_PRIYA_EN, + + FLUX_RUFUS_EN, + + FLUX_SEAN_EN, + + FLUX_SHARON_EN, + + FLUX_SIENNA_EN, + + FLUX_TANNER_EN, + + FLUX_WADE_EN, + + FLUX_WES_EN, + + UNKNOWN + } + + public interface Visitor { + T visitAuraAsteriaEn(); + + T visitAuraLunaEn(); + + T visitAuraStellaEn(); + + T visitAuraAthenaEn(); + + T visitAuraHeraEn(); + + T visitAuraOrionEn(); + + T visitAuraArcasEn(); + + T visitAuraPerseusEn(); + + T visitAuraAngusEn(); + + T visitAuraOrpheusEn(); + + T visitAuraHeliosEn(); + + T visitAuraZeusEn(); + + T visitAura2AmaltheaEn(); + + T visitAura2AndromedaEn(); + + T visitAura2ApolloEn(); + + T visitAura2ArcasEn(); + + T visitAura2AriesEn(); + + T visitAura2AsteriaEn(); + + T visitAura2AthenaEn(); + + T visitAura2AtlasEn(); + + T visitAura2AuroraEn(); + + T visitAura2CallistaEn(); + + T visitAura2CoraEn(); + + T visitAura2CordeliaEn(); + + T visitAura2DeliaEn(); + + T visitAura2DracoEn(); + + T visitAura2ElectraEn(); + + T visitAura2HarmoniaEn(); + + T visitAura2HelenaEn(); + + T visitAura2HeraEn(); + + T visitAura2HermesEn(); + + T visitAura2HyperionEn(); + + T visitAura2IrisEn(); + + T visitAura2JanusEn(); + + T visitAura2JunoEn(); + + T visitAura2JupiterEn(); + + T visitAura2LunaEn(); + + T visitAura2MarsEn(); + + T visitAura2MinervaEn(); + + T visitAura2NeptuneEn(); + + T visitAura2OdysseusEn(); + + T visitAura2OpheliaEn(); + + T visitAura2OrionEn(); + + T visitAura2OrpheusEn(); + + T visitAura2PandoraEn(); + + T visitAura2PhoebeEn(); + + T visitAura2PlutoEn(); + + T visitAura2SaturnEn(); + + T visitAura2SeleneEn(); + + T visitAura2ThaliaEn(); + + T visitAura2TheiaEn(); + + T visitAura2VestaEn(); + + T visitAura2ZeusEn(); + + T visitAura2SirioEs(); + + T visitAura2NestorEs(); + + T visitAura2CarinaEs(); + + T visitAura2CelesteEs(); + + T visitAura2AlvaroEs(); + + T visitAura2DianaEs(); + + T visitAura2AquilaEs(); + + T visitAura2SelenaEs(); + + T visitAura2EstrellaEs(); + + T visitAura2JavierEs(); + + T visitFluxAlexisEn(); + + T visitFluxBreeEn(); + + T visitFluxBrittanyEn(); + + T visitFluxBrookeEn(); + + T visitFluxBruceEn(); + + T visitFluxCliffEn(); + + T visitFluxColeEn(); + + T visitFluxColinEn(); + + T visitFluxConorEn(); + + T visitFluxDonovanEn(); + + T visitFluxDrewEn(); + + T visitFluxEliseEn(); + + T visitFluxGemmaEn(); + + T visitFluxHaleyEn(); + + T visitFluxHannahEn(); + + T visitFluxHeatherEn(); + + T visitFluxJackEn(); + + T visitFluxKaiEn(); + + T visitFluxKelseyEn(); + + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + T visitFluxReneeEn(); + + T visitFluxKitEn(); + + T visitFluxMaeveEn(); + + T visitFluxMarceloEn(); + + T visitFluxMarcusEn(); + + T visitFluxMeenaEn(); + + T visitFluxMeghanEn(); + + T visitFluxMilesEn(); + + T visitFluxNaveenEn(); + + T visitFluxPaigeEn(); + + T visitFluxPriyaEn(); + + T visitFluxRufusEn(); + + T visitFluxSeanEn(); + + T visitFluxSharonEn(); + + T visitFluxSiennaEn(); + + T visitFluxTannerEn(); + + T visitFluxWadeEn(); + + T visitFluxWesEn(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak new file mode 100644 index 0000000..e0db2fe --- /dev/null +++ b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak @@ -0,0 +1,248 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeepgramThinkProvider.Builder.class) +public final class DeepgramThinkProvider { + private final Optional version; + + private final DeepgramThinkProviderModel model; + + private final Optional temperature; + + private final Optional reasoningMode; + + private final Optional voicePromptOptOut; + + private final Map additionalProperties; + + private DeepgramThinkProvider( + Optional version, + DeepgramThinkProviderModel model, + Optional temperature, + Optional reasoningMode, + Optional voicePromptOptOut, + Map additionalProperties) { + this.version = version; + this.model = model; + this.temperature = temperature; + this.reasoningMode = reasoningMode; + this.voicePromptOptOut = voicePromptOptOut; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("type") + public String getType() { + return "deepgram"; + } + + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @JsonProperty("model") + public DeepgramThinkProviderModel getModel() { + return model; + } + + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; + } + + @JsonProperty("reasoning_mode") + public Optional getReasoningMode() { + return reasoningMode; + } + + @JsonProperty("voice_prompt_opt_out") + public Optional getVoicePromptOptOut() { + return voicePromptOptOut; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeepgramThinkProvider && equalTo((DeepgramThinkProvider) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeepgramThinkProvider other) { + return version.equals(other.version) + && model.equals(other.model) + && temperature.equals(other.temperature) + && reasoningMode.equals(other.reasoningMode) + && voicePromptOptOut.equals(other.voicePromptOptOut); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.version, this.model, this.temperature, this.reasoningMode, this.voicePromptOptOut); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ModelStage builder() { + return new Builder(); + } + + public interface ModelStage { + _FinalStage model(@NotNull DeepgramThinkProviderModel model); + + Builder from(DeepgramThinkProvider other); + } + + public interface _FinalStage { + DeepgramThinkProvider build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage version(Optional version); + + _FinalStage version(String version); + + _FinalStage temperature(Optional temperature); + + _FinalStage temperature(Double temperature); + + _FinalStage reasoningMode(Optional reasoningMode); + + _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode); + + _FinalStage voicePromptOptOut(Optional voicePromptOptOut); + + _FinalStage voicePromptOptOut(Boolean voicePromptOptOut); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ModelStage, _FinalStage { + private DeepgramThinkProviderModel model; + + private Optional voicePromptOptOut = Optional.empty(); + + private Optional reasoningMode = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional version = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeepgramThinkProvider other) { + version(other.getVersion()); + model(other.getModel()); + temperature(other.getTemperature()); + reasoningMode(other.getReasoningMode()); + voicePromptOptOut(other.getVoicePromptOptOut()); + return this; + } + + @java.lang.Override + @JsonSetter("model") + public _FinalStage model(@NotNull DeepgramThinkProviderModel model) { + this.model = Objects.requireNonNull(model, "model must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage voicePromptOptOut(Boolean voicePromptOptOut) { + this.voicePromptOptOut = Optional.ofNullable(voicePromptOptOut); + return this; + } + + @java.lang.Override + @JsonSetter(value = "voice_prompt_opt_out", nulls = Nulls.SKIP) + public _FinalStage voicePromptOptOut(Optional voicePromptOptOut) { + this.voicePromptOptOut = voicePromptOptOut; + return this; + } + + @java.lang.Override + public _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode) { + this.reasoningMode = Optional.ofNullable(reasoningMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "reasoning_mode", nulls = Nulls.SKIP) + public _FinalStage reasoningMode(Optional reasoningMode) { + this.reasoningMode = reasoningMode; + return this; + } + + @java.lang.Override + public _FinalStage temperature(Double temperature) { + this.temperature = Optional.ofNullable(temperature); + return this; + } + + @java.lang.Override + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public _FinalStage temperature(Optional temperature) { + this.temperature = temperature; + return this; + } + + @java.lang.Override + public _FinalStage version(String version) { + this.version = Optional.ofNullable(version); + return this; + } + + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public DeepgramThinkProvider build() { + return new DeepgramThinkProvider( + version, model, temperature, reasoningMode, voicePromptOptOut, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak new file mode 100644 index 0000000..f9f00eb --- /dev/null +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DeepgramThinkProviderModel { + public static final DeepgramThinkProviderModel THINK_FAST = + new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); + + public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA_2_FP8 = + new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); + + private final Value value; + + private final String string; + + DeepgramThinkProviderModel(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof DeepgramThinkProviderModel + && this.string.equals(((DeepgramThinkProviderModel) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case THINK_FAST: + return visitor.visitThinkFast(); + case PHONELLM_MINI_ALPHA_2_FP8: + return visitor.visitPhonellmMiniAlpha2Fp8(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeepgramThinkProviderModel valueOf(String value) { + switch (value) { + case "think-fast": + return THINK_FAST; + case "phonellm-mini-alpha-2-fp8": + return PHONELLM_MINI_ALPHA_2_FP8; + default: + return new DeepgramThinkProviderModel(Value.UNKNOWN, value); + } + } + + public enum Value { + THINK_FAST, + + PHONELLM_MINI_ALPHA_2_FP8, + + UNKNOWN + } + + public interface Visitor { + T visitThinkFast(); + + T visitPhonellmMiniAlpha2Fp8(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak new file mode 100644 index 0000000..d093a02 --- /dev/null +++ b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak @@ -0,0 +1,458 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class ThinkSettingsV1Provider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ThinkSettingsV1Provider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ThinkSettingsV1Provider openAi(OpenAiThinkProvider value) { + return new ThinkSettingsV1Provider(new OpenAiValue(value)); + } + + public static ThinkSettingsV1Provider awsBedrock(AwsBedrockThinkProvider value) { + return new ThinkSettingsV1Provider(new AwsBedrockValue(value)); + } + + public static ThinkSettingsV1Provider anthropic(Anthropic value) { + return new ThinkSettingsV1Provider(new AnthropicValue(value)); + } + + public static ThinkSettingsV1Provider google(Google value) { + return new ThinkSettingsV1Provider(new GoogleValue(value)); + } + + public static ThinkSettingsV1Provider groq(Groq value) { + return new ThinkSettingsV1Provider(new GroqValue(value)); + } + + public static ThinkSettingsV1Provider deepgram(DeepgramThinkProvider value) { + return new ThinkSettingsV1Provider(new DeepgramValue(value)); + } + + public boolean isOpenAi() { + return value instanceof OpenAiValue; + } + + public boolean isAwsBedrock() { + return value instanceof AwsBedrockValue; + } + + public boolean isAnthropic() { + return value instanceof AnthropicValue; + } + + public boolean isGoogle() { + return value instanceof GoogleValue; + } + + public boolean isGroq() { + return value instanceof GroqValue; + } + + public boolean isDeepgram() { + return value instanceof DeepgramValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getOpenAi() { + if (isOpenAi()) { + return Optional.of(((OpenAiValue) value).value); + } + return Optional.empty(); + } + + public Optional getAwsBedrock() { + if (isAwsBedrock()) { + return Optional.of(((AwsBedrockValue) value).value); + } + return Optional.empty(); + } + + public Optional getAnthropic() { + if (isAnthropic()) { + return Optional.of(((AnthropicValue) value).value); + } + return Optional.empty(); + } + + public Optional getGoogle() { + if (isGoogle()) { + return Optional.of(((GoogleValue) value).value); + } + return Optional.empty(); + } + + public Optional getGroq() { + if (isGroq()) { + return Optional.of(((GroqValue) value).value); + } + return Optional.empty(); + } + + public Optional getDeepgram() { + if (isDeepgram()) { + return Optional.of(((DeepgramValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ThinkSettingsV1Provider && value.equals(((ThinkSettingsV1Provider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitOpenAi(OpenAiThinkProvider openAi); + + T visitAwsBedrock(AwsBedrockThinkProvider awsBedrock); + + T visitAnthropic(Anthropic anthropic); + + T visitGoogle(Google google); + + T visitGroq(Groq groq); + + default T visitDeepgram(DeepgramThinkProvider deepgram) { + return _visitUnknown(deepgram); + } + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(OpenAiValue.class), + @JsonSubTypes.Type(AwsBedrockValue.class), + @JsonSubTypes.Type(AnthropicValue.class), + @JsonSubTypes.Type(GoogleValue.class), + @JsonSubTypes.Type(GroqValue.class), + @JsonSubTypes.Type(DeepgramValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("open_ai") + @JsonIgnoreProperties("type") + private static final class OpenAiValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private OpenAiThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private OpenAiValue() {} + + private OpenAiValue(OpenAiThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitOpenAi(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OpenAiValue && equalTo((OpenAiValue) other); + } + + private boolean equalTo(OpenAiValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("aws_bedrock") + @JsonIgnoreProperties("type") + private static final class AwsBedrockValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private AwsBedrockThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AwsBedrockValue() {} + + private AwsBedrockValue(AwsBedrockThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAwsBedrock(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AwsBedrockValue && equalTo((AwsBedrockValue) other); + } + + private boolean equalTo(AwsBedrockValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("anthropic") + @JsonIgnoreProperties("type") + private static final class AnthropicValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Anthropic value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AnthropicValue() {} + + private AnthropicValue(Anthropic value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAnthropic(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AnthropicValue && equalTo((AnthropicValue) other); + } + + private boolean equalTo(AnthropicValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("google") + @JsonIgnoreProperties("type") + private static final class GoogleValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Google value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private GoogleValue() {} + + private GoogleValue(Google value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitGoogle(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GoogleValue && equalTo((GoogleValue) other); + } + + private boolean equalTo(GoogleValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("groq") + @JsonIgnoreProperties("type") + private static final class GroqValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Groq value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private GroqValue() {} + + private GroqValue(Groq value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitGroq(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GroqValue && equalTo((GroqValue) other); + } + + private boolean equalTo(GroqValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("deepgram") + @JsonIgnoreProperties("type") + private static final class DeepgramValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private DeepgramThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private DeepgramValue() {} + + private DeepgramValue(DeepgramThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitDeepgram(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeepgramValue && equalTo((DeepgramValue) other); + } + + private boolean equalTo(DeepgramValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "type: " + type + ", value: " + value + "}"; + } + } +} From e417e22236733f8c9131abe46b57769c1e91b995 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:29:21 +0000 Subject: [PATCH 3/9] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-java-sdk: 4.23.1 --- .fern/metadata.json | 6 ++--- ...> DeepgramThinkProviderReasoningMode.java} | 27 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) rename src/main/java/com/deepgram/types/{DeepgramReasoningMode.java => DeepgramThinkProviderReasoningMode.java} (62%) diff --git a/.fern/metadata.json b/.fern/metadata.json index 159adaf..8e40cb5 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -12,8 +12,8 @@ "enable-wire-tests": true, "runtime-version": true }, - "originGitCommit": "56f50652950bce4294c5388be6f25055749f55a7", + "originGitCommit": "596e7bdfa377f40f3301b1d394c9f0215af5f6d4", "originGitCommitIsDirty": true, "invokedBy": "manual", - "sdkVersion": "0.11.3" -} + "sdkVersion": "0.11.4" +} \ No newline at end of file diff --git a/src/main/java/com/deepgram/types/DeepgramReasoningMode.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderReasoningMode.java similarity index 62% rename from src/main/java/com/deepgram/types/DeepgramReasoningMode.java rename to src/main/java/com/deepgram/types/DeepgramThinkProviderReasoningMode.java index ef23885..68d1fc3 100644 --- a/src/main/java/com/deepgram/types/DeepgramReasoningMode.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderReasoningMode.java @@ -6,22 +6,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public final class DeepgramReasoningMode { - public static final DeepgramReasoningMode MEDIUM = new DeepgramReasoningMode(Value.MEDIUM, "medium"); +public final class DeepgramThinkProviderReasoningMode { + public static final DeepgramThinkProviderReasoningMode MEDIUM = + new DeepgramThinkProviderReasoningMode(Value.MEDIUM, "medium"); - public static final DeepgramReasoningMode LOW = new DeepgramReasoningMode(Value.LOW, "low"); + public static final DeepgramThinkProviderReasoningMode LOW = + new DeepgramThinkProviderReasoningMode(Value.LOW, "low"); - public static final DeepgramReasoningMode MINIMAL = new DeepgramReasoningMode(Value.MINIMAL, "minimal"); + public static final DeepgramThinkProviderReasoningMode MINIMAL = + new DeepgramThinkProviderReasoningMode(Value.MINIMAL, "minimal"); - public static final DeepgramReasoningMode HIGH = new DeepgramReasoningMode(Value.HIGH, "high"); + public static final DeepgramThinkProviderReasoningMode HIGH = + new DeepgramThinkProviderReasoningMode(Value.HIGH, "high"); - public static final DeepgramReasoningMode NONE = new DeepgramReasoningMode(Value.NONE, "none"); + public static final DeepgramThinkProviderReasoningMode NONE = + new DeepgramThinkProviderReasoningMode(Value.NONE, "none"); private final Value value; private final String string; - DeepgramReasoningMode(Value value, String string) { + DeepgramThinkProviderReasoningMode(Value value, String string) { this.value = value; this.string = string; } @@ -39,8 +44,8 @@ public String toString() { @java.lang.Override public boolean equals(Object other) { return (this == other) - || (other instanceof DeepgramReasoningMode - && this.string.equals(((DeepgramReasoningMode) other).string)); + || (other instanceof DeepgramThinkProviderReasoningMode + && this.string.equals(((DeepgramThinkProviderReasoningMode) other).string)); } @java.lang.Override @@ -67,7 +72,7 @@ public T visit(Visitor visitor) { } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DeepgramReasoningMode valueOf(String value) { + public static DeepgramThinkProviderReasoningMode valueOf(String value) { switch (value) { case "medium": return MEDIUM; @@ -80,7 +85,7 @@ public static DeepgramReasoningMode valueOf(String value) { case "none": return NONE; default: - return new DeepgramReasoningMode(Value.UNKNOWN, value); + return new DeepgramThinkProviderReasoningMode(Value.UNKNOWN, value); } } From 039d80c686407e0efb3bfb836cbc632111ae0da2 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:29:22 +0000 Subject: [PATCH 4/9] [fern-replay] advance lockfile --- .fern/replay.lock | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.fern/replay.lock b/.fern/replay.lock index e4c4c8d..fe8324d 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -12,5 +12,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-java-sdk: 4.23.1 -current_generation: 845b148ea6620e53afaf4d91446982c75859df82 + - commit_sha: 20d377528203ce9826f798cedd4a62eec4d376f9 + tree_hash: 9fc4ce6f8063ab5246ecd2f960d3e79d8dd3898b + timestamp: 2026-10-30T17:29:19.868Z + cli_version: unknown + generator_versions: + fernapi/fern-java-sdk: 4.23.1 +current_generation: 20d377528203ce9826f798cedd4a62eec4d376f9 patches: [] From da1d635678e98b0ac18b51c2ecebd7c7bf0f550e Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 17:40:30 +0000 Subject: [PATCH 5/9] chore: re-apply manual patches after regen --- .fernignore | 66 +- examples/agent/ProviderCombinations.java | 4 +- .../com/deepgram/core/ClientOptions.java.bak | 409 ---- .../ReconnectingWebSocketListener.java.bak | 622 ------ .../v1/types/AgentV1AgentAudioDone.java.bak | 83 - .../v1/types/AgentV1ConversationText.java.bak | 317 --- .../v1/types/AgentV1ForceEndTurn.java.bak | 83 - .../agent/v1/types/AgentV1KeepAlive.java.bak | 83 - .../v1/types/AgentV1ListenUpdated.java.bak | 83 - .../v1/types/AgentV1PromptUpdated.java.bak | 83 - ...ettingsAgentContextListenProvider.java.bak | 224 -- ...gentV1SettingsAgentListenProvider.java.bak | 224 -- .../v1/types/AgentV1SettingsApplied.java.bak | 83 - .../v1/types/AgentV1SpeakUpdated.java.bak | 83 - .../v1/types/AgentV1ThinkLiveUpdated.java.bak | 83 - .../v1/types/AgentV1ThinkUpdated.java.bak | 83 - ...AgentV1UpdateListenListenProvider.java.bak | 224 -- .../types/AgentV1UserStartedSpeaking.java.bak | 83 - .../v1/websocket/V1WebSocketClient.java.bak | 981 --------- .../requests/ListenV1RequestUrl.java.bak | 1932 ----------------- ...MediaTranscribeRequestOctetStream.java.bak | 1931 ---------------- .../v1/websocket/V1ConnectOptions.java.bak | 1129 ---------- .../v1/websocket/V1WebSocketClient.java.bak | 650 ------ .../v2/types/ListenV2CloseStream.java.bak | 83 - .../v2/types/ListenV2ForceEndTurn.java.bak | 83 - .../v2/websocket/V2WebSocketClient.java.bak | 563 ----- .../v1/websocket/V1WebSocketClient.java.bak | 467 ---- .../speak/v2/types/SpeakV2Close.java.bak | 83 - .../SpeakV2ConfigureFailureCode.java.bak | 121 -- .../speak/v2/types/SpeakV2Flush.java.bak | 83 - .../v2/websocket/V2WebSocketClient.java.bak | 630 ------ .../com/deepgram/types/DeepgramModel.java.bak | 1081 --------- .../deepgram/types/DeepgramThinkProvider.java | 16 +- .../types/DeepgramThinkProvider.java.bak | 248 --- .../types/DeepgramThinkProviderModel.java.bak | 86 - .../types/ThinkSettingsV1Provider.java.bak | 458 ---- .../deepgram/AgentV1ThinkLiveWireTest.java | 4 +- .../java/com/deepgram/RegenTypesTest.java | 6 +- 38 files changed, 48 insertions(+), 13507 deletions(-) delete mode 100644 src/main/java/com/deepgram/core/ClientOptions.java.bak delete mode 100644 src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/types/DeepgramModel.java.bak delete mode 100644 src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak delete mode 100644 src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak delete mode 100644 src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak diff --git a/.fernignore b/.fernignore index 38352f8..b0b2ff9 100644 --- a/.fernignore +++ b/.fernignore @@ -16,7 +16,7 @@ src/main/java/com/deepgram/AsyncDeepgramClientBuilder.java # Fern regen overwrites these with incorrect SDK names and strips the markers. # Fern 4.22.1 closes tracked WebSockets before SDK-owned OkHttp resources; retain that lifecycle behavior while # reapplying only these headers. -src/main/java/com/deepgram/core/ClientOptions.java.bak +src/main/java/com/deepgram/core/ClientOptions.java # Transport abstraction (pluggable transport for SageMaker, etc.) src/main/java/com/deepgram/core/transport/ @@ -30,7 +30,7 @@ src/main/java/com/deepgram/resources/listen/v1/websocket/ListenV1ConfigureFailur # Bug fixes for maxRetries(0) semantics ("connect once, don't retry") and a # configurable connectionTimeoutMs on ReconnectOptions (was hardcoded 4000ms). # Pull this back out once the fixes are upstreamed into the Fern generator. -src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak +src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java # Forward-compat patch: Fern's generated dispatcher routes any unrecognized message # type to the error handler ("Update your SDK version..."), which makes benign new @@ -40,8 +40,8 @@ src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak # NOTE: the listen v2 and speak v2 clients below also carry the streaming query-param patches # (multi-value serialization + the additionalProperties escape hatch) documented lower down — # keep them frozen until those fixes are upstreamed too. -src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak -src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak +src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java +src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java # Streaming query-param patches on the generated WS connect() builders. Two fixes: # (1) Multi-value serialization: array-valued params (listen: keyterm, keywords, replace, search, @@ -55,27 +55,27 @@ src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java. # listen v2 and speak v2 clients are frozen above; freeze the listen v1 and speak v1 clients here too # so the fixes survive regen. Re-apply after regen; unfreeze once the generator emits array params as # repeats and serializes additionalProperties on the WS connect path (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak -src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java # Agent V1 forwards raw frames through onMessage(String); suppress generic errors only when a raw # handler is registered, otherwise retain legacy onError delivery for unknown control frames. -src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java # Source and binary compatibility for third-party implementations of generated builder stages. # Generated concrete builders override languageHint; default interface methods preserve existing custom implementations. -src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak -src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak -src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak +src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java +src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java +src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java # Preserve existing AgentV1ConversationText builder implementations after adding conversationalBehavior. -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java # The spec's Deepgram Think/Speak title collision makes Fern use the TTS-shaped Deepgram type for Think. # Restore the distinct Think provider/model types until the spec produces them; retain the Visitor default until Fern does. -src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak -src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak -src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak +src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java +src/main/java/com/deepgram/types/DeepgramThinkProvider.java +src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java # Restores the FLUX_RENEE_EN constant that generator 4.18.0 dropped. The voice is live: # POST /v2/speak?model=flux-renee-en returns 200 with valid audio, and the name resolves in the @@ -87,26 +87,26 @@ src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak # changes -- 4.18.0 alone added 25 constants. On the next regen do NOT restore the .bak wholesale: # diff it against the newly generated file, carry forward every new voice, and re-apply only the # FLUX_RENEE_EN touchpoints (constant, Value enum, visit() case, valueOf() case, Visitor method). -src/main/java/com/deepgram/types/DeepgramModel.java.bak +src/main/java/com/deepgram/types/DeepgramModel.java # Manual equals/hashCode contract fix: Fern generates equals() (all instances equal) but no # hashCode() for fields-less message types, violating the Object contract. We add a consistent # hashCode() to each. Unfreeze and drop these patches once the generator emits a matching # equals/hashCode pair for fields-less types (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # Union default-variant fix (STOPGAP). The agent listen-provider unions declare `version` as an # optional discriminator, so a provider payload without it is valid (and is what 0.7.x emits). Fern @@ -115,13 +115,13 @@ src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # {"provider":null}, silently dropping the caller's provider on the wire. Patched to # defaultImpl = V2Value on each. Guarded by AgentSettingsProviderDefaultTest. Unfreeze and drop once # the generator stops defaulting unions to the empty _UnknownValue (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java # Preserve binary-compatible Visitor implementations from before this generated enum added # CONTROL_COMBINATION_INVALID. The default method routes old visitors through visitUnknown. -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java # Build and project configuration build.gradle diff --git a/examples/agent/ProviderCombinations.java b/examples/agent/ProviderCombinations.java index 83ab36f..79e8de4 100644 --- a/examples/agent/ProviderCombinations.java +++ b/examples/agent/ProviderCombinations.java @@ -6,9 +6,9 @@ import com.deepgram.types.AnthropicModel; import com.deepgram.types.Deepgram; import com.deepgram.types.DeepgramModel; -import com.deepgram.types.DeepgramReasoningMode; import com.deepgram.types.DeepgramThinkProvider; import com.deepgram.types.DeepgramThinkProviderModel; +import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.Google; import com.deepgram.types.GoogleModel; import com.deepgram.types.OpenAiThinkProvider; @@ -96,7 +96,7 @@ public static void main(String[] args) { System.out.println("=== Combination 4: Deepgram Think + Deepgram ==="); DeepgramThinkProvider deepgramThinkProvider = DeepgramThinkProvider.builder() .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8) - .reasoningMode(DeepgramReasoningMode.NONE) + .reasoningMode(DeepgramThinkProviderReasoningMode.NONE) .build(); AgentV1SettingsAgent deepgramConfig = AgentV1SettingsAgent.of(AgentV1SettingsAgentContext.builder() diff --git a/src/main/java/com/deepgram/core/ClientOptions.java.bak b/src/main/java/com/deepgram/core/ClientOptions.java.bak deleted file mode 100644 index c3e3eed..0000000 --- a/src/main/java/com/deepgram/core/ClientOptions.java.bak +++ /dev/null @@ -1,409 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Supplier; -import okhttp3.OkHttpClient; - -public final class ClientOptions { - private final Environment environment; - - private final Map headers; - - private final Map> headerSuppliers; - - private final OkHttpClient httpClient; - - private final boolean ownsHttpClient; - - private final AtomicBoolean closed; - - private final Set openWebSockets; - - private final int timeout; - - private final int maxRetries; - - private final Optional initialRetryDelayMillis; - - private final Optional maxRetryDelayMillis; - - private final Optional retryJitterFactor; - - private final Optional webSocketFactory; - - private final Optional logging; - - private ClientOptions( - Environment environment, - Map headers, - Map> headerSuppliers, - OkHttpClient httpClient, - boolean ownsHttpClient, - AtomicBoolean closed, - Set openWebSockets, - int timeout, - int maxRetries, - Optional initialRetryDelayMillis, - Optional maxRetryDelayMillis, - Optional retryJitterFactor, - Optional webSocketFactory, - Optional logging) { - this.environment = environment; - this.headers = new HashMap<>(); - this.headers.putAll(headers); - this.headers.putAll(new HashMap() { - { - put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.3"); // x-release-please-version - put("X-Fern-Language", "JAVA"); - put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); - put("X-Fern-SDK-Version", "0.11.3"); // x-release-please-version - } - }); - this.headerSuppliers = headerSuppliers; - this.httpClient = httpClient; - this.ownsHttpClient = ownsHttpClient; - this.closed = closed; - this.openWebSockets = openWebSockets; - this.timeout = timeout; - this.maxRetries = maxRetries; - this.initialRetryDelayMillis = initialRetryDelayMillis; - this.maxRetryDelayMillis = maxRetryDelayMillis; - this.retryJitterFactor = retryJitterFactor; - this.webSocketFactory = webSocketFactory; - this.logging = logging; - } - - public Environment environment() { - return this.environment; - } - - public Map headers(RequestOptions requestOptions) { - Map values = new HashMap<>(this.headers); - headerSuppliers.forEach((key, supplier) -> { - values.put(key, supplier.get()); - }); - if (requestOptions != null) { - values.putAll(requestOptions.getHeaders()); - } - return values; - } - - public int timeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.timeout; - } - return requestOptions.getTimeout().orElse(this.timeout); - } - - public OkHttpClient httpClient() { - return this.httpClient; - } - - public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.httpClient; - } - return this.httpClient - .newBuilder() - .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .build(); - } - - public int maxRetries() { - return this.maxRetries; - } - - public Optional initialRetryDelayMillis() { - return this.initialRetryDelayMillis; - } - - public Optional maxRetryDelayMillis() { - return this.maxRetryDelayMillis; - } - - public Optional retryJitterFactor() { - return this.retryJitterFactor; - } - - /** - * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's - * dispatcher executor and evicts its connection pool when this client created that - * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the - * caller owns its lifecycle. - *

- * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later - * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous - * requests may still run. Options derived from this one via - * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either - * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method - * more than once has no further effect. - *

- * WebSocket clients created from this client that are still connected are disconnected - * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the - * dispatcher goes away. Any WebSocket connect or reconnect attempted afterwards fails with - * an {@code IllegalStateException} explaining that the client has been closed. - */ - public void close() { - if (!this.closed.compareAndSet(false, true)) { - return; - } - for (AutoCloseable webSocket : new ArrayList<>(this.openWebSockets)) { - try { - webSocket.close(); - } catch (Exception e) { - // best effort; keep closing the remaining sockets and the HTTP client - } - } - this.openWebSockets.clear(); - if (!this.ownsHttpClient) { - return; - } - this.httpClient.dispatcher().executorService().shutdown(); - this.httpClient.connectionPool().evictAll(); - } - - /** - * Returns whether {@link #close()} has been called on this client. - */ - public boolean isClosed() { - return this.closed.get(); - } - - /** - * Tracks a connected WebSocket client so that {@link #close()} disconnects it. - * - * @throws IllegalStateException if this client has already been closed - */ - public void registerWebSocket(AutoCloseable webSocket) { - this.openWebSockets.add(webSocket); - if (this.closed.get()) { - this.openWebSockets.remove(webSocket); - throw new IllegalStateException("root client has been closed"); - } - } - - /** - * Stops tracking a WebSocket client that has been disconnected. - */ - public void unregisterWebSocket(AutoCloseable webSocket) { - this.openWebSockets.remove(webSocket); - } - - public Optional webSocketFactory() { - return this.webSocketFactory; - } - - public Optional logging() { - return this.logging; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Environment environment; - - private final Map headers = new HashMap<>(); - - private final Map> headerSuppliers = new HashMap<>(); - - private int maxRetries = 2; - - private Optional initialRetryDelayMillis = Optional.empty(); - - private Optional maxRetryDelayMillis = Optional.empty(); - - private Optional retryJitterFactor = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private OkHttpClient httpClient = null; - - private boolean ownsHttpClient = true; - - private AtomicBoolean closed; - - private Set openWebSockets; - - private Optional logging = Optional.empty(); - - private Optional webSocketFactory = Optional.empty(); - - public Builder environment(Environment environment) { - this.environment = environment; - return this; - } - - public Builder addHeader(String key, String value) { - if (value != null) { - this.headers.put(key, value); - } - return this; - } - - public Builder addHeader(String key, Supplier value) { - this.headerSuppliers.put(key, value); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(int timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - /** - * Override the maximum number of retries. Defaults to 2 retries. - */ - public Builder maxRetries(int maxRetries) { - this.maxRetries = maxRetries; - return this; - } - - /** - * Override the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. - */ - public Builder initialRetryDelayMillis(long initialRetryDelayMillis) { - this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); - return this; - } - - /** - * Override the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. - */ - public Builder maxRetryDelayMillis(long maxRetryDelayMillis) { - this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); - return this; - } - - /** - * Override the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. - */ - public Builder retryJitterFactor(double retryJitterFactor) { - this.retryJitterFactor = Optional.of(retryJitterFactor); - return this; - } - - /** - * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle: - * close() will not shut down its dispatcher executor or evict its connection pool. - */ - public Builder httpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; - this.ownsHttpClient = httpClient == null; - return this; - } - - /** - * Set a custom WebSocketFactory for creating WebSocket connections. - */ - public Builder webSocketFactory(WebSocketFactory webSocketFactory) { - this.webSocketFactory = Optional.of(webSocketFactory); - return this; - } - - /** - * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. - */ - public Builder logging(LogConfig logging) { - this.logging = Optional.of(logging); - return this; - } - - public ClientOptions build() { - OkHttpClient.Builder httpClientBuilder = - this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); - - if (this.httpClient != null) { - timeout.ifPresent(timeout -> httpClientBuilder - .callTimeout(timeout, TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS)); - } else { - httpClientBuilder - .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .addInterceptor(new RetryInterceptor( - this.maxRetries, - this.initialRetryDelayMillis, - this.maxRetryDelayMillis, - this.retryJitterFactor)); - } - - Logger logger = Logger.from(this.logging); - httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); - httpClientBuilder.addInterceptor(new ResponseDecompressionInterceptor()); - - this.httpClient = httpClientBuilder.build(); - this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); - - AtomicBoolean closedToUse = this.closed != null ? this.closed : new AtomicBoolean(false); - Set openWebSocketsToUse = - this.openWebSockets != null ? this.openWebSockets : ConcurrentHashMap.newKeySet(); - - return new ClientOptions( - environment, - headers, - headerSuppliers, - httpClient, - this.ownsHttpClient, - closedToUse, - openWebSocketsToUse, - this.timeout.get(), - this.maxRetries, - this.initialRetryDelayMillis, - this.maxRetryDelayMillis, - this.retryJitterFactor, - this.webSocketFactory, - this.logging); - } - - /** - * Create a new Builder initialized with values from an existing ClientOptions - */ - public static Builder from(ClientOptions clientOptions) { - Builder builder = new Builder(); - builder.environment = clientOptions.environment(); - builder.timeout = Optional.of(clientOptions.timeout(null)); - builder.httpClient = clientOptions.httpClient(); - builder.ownsHttpClient = clientOptions.ownsHttpClient; - builder.closed = clientOptions.closed; - builder.openWebSockets = clientOptions.openWebSockets; - builder.headers.putAll(clientOptions.headers); - builder.headerSuppliers.putAll(clientOptions.headerSuppliers); - builder.maxRetries = clientOptions.maxRetries(); - builder.initialRetryDelayMillis = clientOptions.initialRetryDelayMillis(); - builder.maxRetryDelayMillis = clientOptions.maxRetryDelayMillis(); - builder.retryJitterFactor = clientOptions.retryJitterFactor(); - builder.logging = clientOptions.logging(); - return builder; - } - } -} diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak deleted file mode 100644 index b51aacc..0000000 --- a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak +++ /dev/null @@ -1,622 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.core; - -import static java.util.concurrent.TimeUnit.*; - -import java.util.ArrayList; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.BooleanSupplier; -import java.util.function.Consumer; -import java.util.function.Supplier; -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; -import okio.ByteString; - -/** - * WebSocketListener with automatic reconnection, exponential backoff, and message queuing. - * Provides production-ready resilience for WebSocket connections. - */ -public abstract class ReconnectingWebSocketListener extends WebSocketListener { - private volatile ReconnectOptions activeOptions; - - private final int maxEnqueuedMessages; - - private final AtomicInteger retryCount = new AtomicInteger(0); - - private final AtomicBoolean connectLock = new AtomicBoolean(false); - - private final AtomicBoolean shouldReconnect = new AtomicBoolean(true); - - protected volatile WebSocket webSocket; - - private volatile long connectionEstablishedTime = 0L; - - private final ConcurrentLinkedQueue messageQueue = new ConcurrentLinkedQueue<>(); - - private final ConcurrentLinkedQueue binaryMessageQueue = new ConcurrentLinkedQueue<>(); - - private final ScheduledExecutorService reconnectExecutor = Executors.newSingleThreadScheduledExecutor(); - - private final Supplier connectionSupplier; - - private final BooleanSupplier closedCheck; - - /** - * Creates a new reconnecting WebSocket listener. - * - * @param options Reconnection configuration options - * @param connectionSupplier Supplier that creates new WebSocket connections - */ - public ReconnectingWebSocketListener( - ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier) { - this(options, connectionSupplier, () -> false); - } - - /** - * Creates a new reconnecting WebSocket listener. - * - * @param options Reconnection configuration options - * @param connectionSupplier Supplier that creates new WebSocket connections - * @param closedCheck Returns true once the owning client has been closed; connect and - * reconnect attempts made after that point fail with an {@link IllegalStateException} - * instead of being retried - */ - public ReconnectingWebSocketListener( - ReconnectingWebSocketListener.ReconnectOptions options, - Supplier connectionSupplier, - BooleanSupplier closedCheck) { - this.activeOptions = options; - this.maxEnqueuedMessages = options.maxEnqueuedMessages; - this.connectionSupplier = connectionSupplier; - this.closedCheck = closedCheck; - } - - /** - * Replaces option-derived reconnect settings without rebuilding generated clients. - * - * @param options replacement options; {@code null} is a no-op - */ - public void applyOptionsOverride(ReconnectOptions options) { - if (options != null) { - this.activeOptions = options; - } - } - - /** - * Initiates a WebSocket connection with automatic reconnection enabled. - * - * Connection behavior: - * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) - * - Thread-safe via atomic lock (returns immediately if connection in progress) - * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry - * - * Error handling: - * - TimeoutException: Includes retry attempt context - * - InterruptedException: Preserves thread interruption status - * - ExecutionException: Extracts actual cause and adds context - * - Owning client closed: reports an IllegalStateException once and stops reconnecting - */ - public void connect() { - if (!connectLock.compareAndSet(false, true)) { - return; - } - if (closedCheck.getAsBoolean()) { - shouldReconnect.set(false); - connectLock.set(false); - onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); - return; - } - ReconnectOptions options = this.activeOptions; - if (retryCount.get() > options.maxRetries) { - connectLock.set(false); - return; - } - try { - CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); - try { - webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); - } catch (TimeoutException e) { - connectionFuture.cancel(true); - TimeoutException timeoutError = - new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs - + " milliseconds" - + (retryCount.get() > 0 - ? " (retry attempt #" + retryCount.get() + ")" - : " (initial connection attempt)")); - onWebSocketFailure(null, timeoutError, null); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } catch (InterruptedException e) { - connectionFuture.cancel(true); - Thread.currentThread().interrupt(); - InterruptedException interruptError = new InterruptedException("WebSocket connection interrupted" - + (retryCount.get() > 0 - ? " during retry attempt #" + retryCount.get() - : " during initial connection")); - interruptError.initCause(e); - onWebSocketFailure(null, interruptError, null); - } catch (ExecutionException e) { - Throwable cause = e.getCause() != null ? e.getCause() : e; - String context = retryCount.get() > 0 - ? "WebSocket connection failed during retry attempt #" + retryCount.get() - : "WebSocket connection failed during initial attempt"; - RuntimeException wrappedException = new RuntimeException( - context + ": " + cause.getClass().getSimpleName() + ": " + cause.getMessage()); - wrappedException.initCause(cause); - onWebSocketFailure(null, wrappedException, null); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } - } finally { - connectLock.set(false); - } - } - - /** - * Disconnects the WebSocket and disables automatic reconnection. - * - * This method: - * - Disables automatic reconnection - * - Clears queued messages to prevent stale data - * - Closes the WebSocket with standard close code 1000 - * - Properly shuts down the reconnect executor to prevent thread leaks - * - Waits up to 5 seconds for executor termination - */ - public void disconnect() { - shouldReconnect.set(false); - messageQueue.clear(); - binaryMessageQueue.clear(); - if (webSocket != null) { - webSocket.close(1000, "Client disconnecting"); - } - reconnectExecutor.shutdown(); - try { - if (!reconnectExecutor.awaitTermination(5, SECONDS)) { - reconnectExecutor.shutdownNow(); - } - } catch (InterruptedException e) { - reconnectExecutor.shutdownNow(); - Thread.currentThread().interrupt(); - } - } - - /** - * Sends a message or queues it if not connected. - * - * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). - * - * Behavior: - * - If connected: Attempts direct send, queues if buffer full - * - If disconnected: Queues message up to maxEnqueuedMessages limit - * - If queue full: Message is dropped - * - * @param message The message to send - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean send(String message) { - return send(message, null); - } - - /** - * Sends a message or queues it if not connected, exposing the accepting socket. - * - * Behaves like {@link #send(String)}, but additionally invokes {@code onSent} with the - * WebSocket that accepted the message. The callback is only invoked when the message was - * sent directly, never when it was queued or dropped. This lets callers associate a - * protocol-level message with the specific connection it was delivered on, e.g. to decide - * in {@link #shouldReconnectAfterClose(WebSocket, int, String)} whether a later close of that same - * connection was expected. - * - * @param message The message to send - * @param onSent Callback receiving the WebSocket that accepted the message, or null - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean send(String message, Consumer onSent) { - WebSocket ws = webSocket; - if (ws != null) { - boolean sent = ws.send(message); - if (sent && onSent != null) { - onSent.accept(ws); - } - if (!sent && messageQueue.size() < maxEnqueuedMessages) { - messageQueue.offer(message); - return false; - } - return sent; - } else { - if (messageQueue.size() < maxEnqueuedMessages) { - messageQueue.offer(message); - return false; - } - return false; - } - } - - /** - * Sends binary data or queues it if not connected. - * - * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). - * - * Behavior: - * - If connected: Attempts direct send, queues if buffer full - * - If disconnected: Queues data up to maxEnqueuedMessages limit - * - If queue full: Data is dropped - * - * @param data The binary data to send - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean sendBinary(ByteString data) { - return sendBinary(data, null); - } - - /** - * Sends binary data or queues it if not connected, exposing the accepting socket. - * - * Behaves like {@link #sendBinary(ByteString)}, but additionally invokes {@code onSent} with - * the WebSocket that accepted the data. The callback is only invoked when the data was sent - * directly, never when it was queued or dropped. - * - * @param data The binary data to send - * @param onSent Callback receiving the WebSocket that accepted the data, or null - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean sendBinary(ByteString data, Consumer onSent) { - WebSocket ws = webSocket; - if (ws != null) { - boolean sent = ws.send(data); - if (sent && onSent != null) { - onSent.accept(ws); - } - if (!sent && binaryMessageQueue.size() < maxEnqueuedMessages) { - binaryMessageQueue.offer(data); - return false; - } - return sent; - } else { - if (binaryMessageQueue.size() < maxEnqueuedMessages) { - binaryMessageQueue.offer(data); - return false; - } - return false; - } - } - - /** - * Gets the current WebSocket instance. - * Thread-safe method to access the WebSocket connection. - * @return the WebSocket or null if not connected - */ - public WebSocket getWebSocket() { - return webSocket; - } - - /** - * @hidden - */ - @Override - public void onOpen(WebSocket webSocket, Response response) { - this.webSocket = webSocket; - connectionEstablishedTime = System.currentTimeMillis(); - retryCount.set(0); - flushMessageQueue(); - onWebSocketOpen(webSocket, response); - } - - @Override - public void onMessage(WebSocket webSocket, String text) { - onWebSocketMessage(webSocket, text); - } - - @Override - public void onMessage(WebSocket webSocket, ByteString bytes) { - onWebSocketBinaryMessage(webSocket, bytes); - } - - /** - * @hidden - */ - @Override - public void onFailure(WebSocket webSocket, Throwable t, Response response) { - this.webSocket = null; - long uptime = 0L; - if (connectionEstablishedTime > 0) { - uptime = System.currentTimeMillis() - connectionEstablishedTime; - if (uptime >= 5000) { - retryCount.set(0); - } - } - connectionEstablishedTime = 0L; - Throwable enhancedError = t; - if (t != null) { - String errorContext = "WebSocket connection failed"; - if (uptime > 0) { - errorContext += " after " + (uptime / 1000) + " seconds"; - } - if (response != null) { - errorContext += " with HTTP " + response.code() + " " + response.message(); - } - enhancedError = - new RuntimeException(errorContext + ": " + t.getClass().getSimpleName() + ": " + t.getMessage()); - enhancedError.initCause(t); - } - onWebSocketFailure(webSocket, enhancedError, response); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } - - /** - * Acknowledges a peer-initiated close so OkHttp can complete the close handshake and - * invoke {@link #onClosed(WebSocket, int, String)}. - * - * Code 1005 is a local "no status received" sentinel reported when the peer sent an empty - * close frame. It is not a valid code to put on the wire, so it is acknowledged with - * the normal closure code 1000 instead. - * - * @hidden - */ - @Override - public void onClosing(WebSocket webSocket, int code, String reason) { - webSocket.close(code == 1005 ? 1000 : code, reason); - } - - /** - * @hidden - */ - @Override - public void onClosed(WebSocket webSocket, int code, String reason) { - this.webSocket = null; - if (connectionEstablishedTime > 0) { - long uptime = System.currentTimeMillis() - connectionEstablishedTime; - if (uptime >= 5000) { - retryCount.set(0); - } - } - connectionEstablishedTime = 0L; - onWebSocketClosed(webSocket, code, reason); - if (shouldReconnect.get() && shouldReconnectAfterClose(webSocket, code, reason)) { - scheduleReconnect(); - } - } - - /** - * Decides whether a completed close handshake should trigger a reconnect. - * - * Only consulted when reconnection has not been disabled via {@link #disconnect()}. - * The default treats normal closure (1000) as terminal and reconnects on any - * other code. Subclasses can override this when protocol context establishes that a - * particular close is terminal, for example a no-status close following a message that - * ends the stream. - * - * @param webSocket The WebSocket that was closed - * @param code The close status code reported by OkHttp - * @param reason The close reason sent by the peer, or an empty string - * @return true to schedule a reconnect, false to stay disconnected - */ - protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { - return code != 1000; - } - - /** - * Calculates the next reconnection delay using exponential backoff. - * - * Uses 0-based retry count where: - * - 0 = initial connection (not used by this method) - * - 1 = first retry (returns minReconnectionDelayMs) - * - 2+ = exponential backoff up to maxReconnectionDelayMs - */ - private long getNextDelay() { - if (retryCount.get() == 1) { - return activeOptions.minReconnectionDelayMs; - } - ReconnectOptions options = this.activeOptions; - long delay = (long) - (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); - return Math.min(delay, options.maxReconnectionDelayMs); - } - - /** - * Schedules a reconnection attempt with appropriate delay. - * Increments retry count and uses exponential backoff. - * Does nothing once the owning client has been closed. - */ - private void scheduleReconnect() { - if (closedCheck.getAsBoolean()) { - shouldReconnect.set(false); - return; - } - retryCount.incrementAndGet(); - long delay = getNextDelay(); - reconnectExecutor.schedule(this::connect, delay, MILLISECONDS); - } - - /** - * Sends all queued messages after reconnection. - * - * Thread-safe: Synchronized to prevent race conditions with send() method. - * - * Algorithm: - * 1. Drains queue into temporary list to avoid holding lock during sends - * 2. Attempts to send each message in order - * 3. If any send fails, re-queues that message and all subsequent messages - * 4. Preserves message ordering during re-queueing - * 5. Repeats for binary message queue - */ - private synchronized void flushMessageQueue() { - WebSocket ws = webSocket; - if (ws != null) { - ArrayList tempQueue = new ArrayList<>(); - String message; - while ((message = messageQueue.poll()) != null) { - tempQueue.add(message); - } - for (int i = 0; i < tempQueue.size(); i++) { - if (!ws.send(tempQueue.get(i))) { - for (int j = i; j < tempQueue.size(); j++) { - messageQueue.offer(tempQueue.get(j)); - } - break; - } - } - ArrayList tempBinaryQueue = new ArrayList<>(); - ByteString binaryMsg; - while ((binaryMsg = binaryMessageQueue.poll()) != null) { - tempBinaryQueue.add(binaryMsg); - } - for (int i = 0; i < tempBinaryQueue.size(); i++) { - if (!ws.send(tempBinaryQueue.get(i))) { - for (int j = i; j < tempBinaryQueue.size(); j++) { - binaryMessageQueue.offer(tempBinaryQueue.get(j)); - } - break; - } - } - } - } - - protected abstract void onWebSocketOpen(WebSocket webSocket, Response response); - - protected abstract void onWebSocketMessage(WebSocket webSocket, String text); - - protected abstract void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes); - - protected abstract void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response); - - protected abstract void onWebSocketClosed(WebSocket webSocket, int code, String reason); - - /** - * Configuration options for automatic reconnection. - */ - public static final class ReconnectOptions { - public final long minReconnectionDelayMs; - - public final long maxReconnectionDelayMs; - - public final double reconnectionDelayGrowFactor; - - public final int maxRetries; - - public final int maxEnqueuedMessages; - - public final long connectionTimeoutMs; - - private ReconnectOptions(Builder builder) { - this.minReconnectionDelayMs = builder.minReconnectionDelayMs; - this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; - this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; - this.maxRetries = builder.maxRetries; - this.maxEnqueuedMessages = builder.maxEnqueuedMessages; - this.connectionTimeoutMs = builder.connectionTimeoutMs; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private long minReconnectionDelayMs; - - private long maxReconnectionDelayMs; - - private double reconnectionDelayGrowFactor; - - private int maxRetries; - - private int maxEnqueuedMessages; - - private long connectionTimeoutMs; - - public Builder() { - this.minReconnectionDelayMs = 1000; - this.maxReconnectionDelayMs = 10000; - this.reconnectionDelayGrowFactor = 1.3; - this.maxRetries = 2147483647; - this.maxEnqueuedMessages = 1000; - this.connectionTimeoutMs = 4000; - } - - public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { - this.minReconnectionDelayMs = minReconnectionDelayMs; - return this; - } - - public Builder maxReconnectionDelayMs(long maxReconnectionDelayMs) { - this.maxReconnectionDelayMs = maxReconnectionDelayMs; - return this; - } - - public Builder reconnectionDelayGrowFactor(double reconnectionDelayGrowFactor) { - this.reconnectionDelayGrowFactor = reconnectionDelayGrowFactor; - return this; - } - - public Builder maxRetries(int maxRetries) { - this.maxRetries = maxRetries; - return this; - } - - public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { - this.maxEnqueuedMessages = maxEnqueuedMessages; - return this; - } - - /** - * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. - */ - public Builder connectionTimeoutMs(long connectionTimeoutMs) { - this.connectionTimeoutMs = connectionTimeoutMs; - return this; - } - - /** - * Builds the ReconnectOptions with validation. - * - * Validates that: - * - All delay values are positive - * - minReconnectionDelayMs <= maxReconnectionDelayMs - * - reconnectionDelayGrowFactor >= 1.0 - * - maxRetries and maxEnqueuedMessages are non-negative - * - * @return The validated ReconnectOptions instance - * @throws IllegalArgumentException if configuration is invalid - */ - public ReconnectOptions build() { - if (minReconnectionDelayMs <= 0) { - throw new IllegalArgumentException("minReconnectionDelayMs must be positive"); - } - if (maxReconnectionDelayMs <= 0) { - throw new IllegalArgumentException("maxReconnectionDelayMs must be positive"); - } - if (minReconnectionDelayMs > maxReconnectionDelayMs) { - throw new IllegalArgumentException("minReconnectionDelayMs (" + minReconnectionDelayMs - + ") must not exceed maxReconnectionDelayMs (" + maxReconnectionDelayMs + ")"); - } - if (reconnectionDelayGrowFactor < 1.0) { - throw new IllegalArgumentException("reconnectionDelayGrowFactor must be >= 1.0"); - } - if (maxRetries < 0) { - throw new IllegalArgumentException("maxRetries must be non-negative"); - } - if (maxEnqueuedMessages < 0) { - throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); - } - if (connectionTimeoutMs <= 0) { - throw new IllegalArgumentException("connectionTimeoutMs must be positive"); - } - return new ReconnectOptions(this); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak deleted file mode 100644 index 5962f4b..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1AgentAudioDone.Builder.class) -public final class AgentV1AgentAudioDone { - private final Map additionalProperties; - - private AgentV1AgentAudioDone(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier indicating the agent has finished sending audio - */ - @JsonProperty("type") - public String getType() { - return "AgentAudioDone"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1AgentAudioDone; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1AgentAudioDone other) { - return this; - } - - public AgentV1AgentAudioDone build() { - return new AgentV1AgentAudioDone(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak deleted file mode 100644 index ef4f56a..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak +++ /dev/null @@ -1,317 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ConversationText.Builder.class) -public final class AgentV1ConversationText { - private final AgentV1ConversationTextRole role; - - private final String content; - - private final AgentV1ConversationTextConversationalBehavior conversationalBehavior; - - private final Optional> languagesHinted; - - private final Optional> languages; - - private final Map additionalProperties; - - private AgentV1ConversationText( - AgentV1ConversationTextRole role, - String content, - AgentV1ConversationTextConversationalBehavior conversationalBehavior, - Optional> languagesHinted, - Optional> languages, - Map additionalProperties) { - this.role = role; - this.content = content; - this.conversationalBehavior = conversationalBehavior; - this.languagesHinted = languagesHinted; - this.languages = languages; - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for conversation text - */ - @JsonProperty("type") - public String getType() { - return "ConversationText"; - } - - /** - * @return Identifies who spoke the statement - */ - @JsonProperty("role") - public AgentV1ConversationTextRole getRole() { - return role; - } - - /** - * @return The actual statement that was spoken - */ - @JsonProperty("content") - public String getContent() { - return content; - } - - /** - * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off - */ - @JsonProperty("conversational_behavior") - public Optional getConversationalBehavior() { - return Optional.of(conversationalBehavior); - } - - /** - * @return The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi. - */ - @JsonProperty("languages_hinted") - public Optional> getLanguagesHinted() { - return languagesHinted; - } - - /** - * @return Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi. - */ - @JsonProperty("languages") - public Optional> getLanguages() { - return languages; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ConversationText && equalTo((AgentV1ConversationText) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AgentV1ConversationText other) { - return role.equals(other.role) - && content.equals(other.content) - && conversationalBehavior.equals(other.conversationalBehavior) - && languagesHinted.equals(other.languagesHinted) - && languages.equals(other.languages); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.role, this.content, this.conversationalBehavior, this.languagesHinted, this.languages); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RoleStage builder() { - return new Builder(); - } - - public interface RoleStage { - /** - *

Identifies who spoke the statement

- */ - ContentStage role(@NotNull AgentV1ConversationTextRole role); - - Builder from(AgentV1ConversationText other); - } - - public interface ContentStage { - /** - *

The actual statement that was spoken

- */ - _FinalStage content(@NotNull String content); - } - - public interface ConversationalBehaviorStage { - /** - *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

- */ - _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior); - } - - public interface _FinalStage { - AgentV1ConversationText build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - default _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { - return this; - } - - default _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- */ - _FinalStage languagesHinted(Optional> languagesHinted); - - _FinalStage languagesHinted(List languagesHinted); - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- */ - _FinalStage languages(Optional> languages); - - _FinalStage languages(List languages); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RoleStage, ContentStage, ConversationalBehaviorStage, _FinalStage { - private AgentV1ConversationTextRole role; - - private String content; - - private AgentV1ConversationTextConversationalBehavior conversationalBehavior = - AgentV1ConversationTextConversationalBehavior.DEFAULT; - - private Optional> languages = Optional.empty(); - - private Optional> languagesHinted = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AgentV1ConversationText other) { - role(other.getRole()); - content(other.getContent()); - conversationalBehavior(other.getConversationalBehavior()); - languagesHinted(other.getLanguagesHinted()); - languages(other.getLanguages()); - return this; - } - - /** - *

Identifies who spoke the statement

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("role") - public ContentStage role(@NotNull AgentV1ConversationTextRole role) { - this.role = Objects.requireNonNull(role, "role must not be null"); - return this; - } - - /** - *

The actual statement that was spoken

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(@NotNull String content) { - this.content = Objects.requireNonNull(content, "content must not be null"); - return this; - } - - /** - *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) - public _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { - this.conversationalBehavior = - Objects.requireNonNull(conversationalBehavior, "conversationalBehavior must not be null"); - return this; - } - - public _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - this.conversationalBehavior = conversationalBehavior.orElse( - AgentV1ConversationTextConversationalBehavior.DEFAULT); - return this; - } - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languages(List languages) { - this.languages = Optional.ofNullable(languages); - return this; - } - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- */ - @java.lang.Override - @JsonSetter(value = "languages", nulls = Nulls.SKIP) - public _FinalStage languages(Optional> languages) { - this.languages = languages; - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languagesHinted(List languagesHinted) { - this.languagesHinted = Optional.ofNullable(languagesHinted); - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- */ - @java.lang.Override - @JsonSetter(value = "languages_hinted", nulls = Nulls.SKIP) - public _FinalStage languagesHinted(Optional> languagesHinted) { - this.languagesHinted = languagesHinted; - return this; - } - - @java.lang.Override - public AgentV1ConversationText build() { - return new AgentV1ConversationText( - role, content, conversationalBehavior, languagesHinted, languages, additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak deleted file mode 100644 index 9bd5f76..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ForceEndTurn.Builder.class) -public final class AgentV1ForceEndTurn { - private final Map additionalProperties; - - private AgentV1ForceEndTurn(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for forcing the end of the current turn - */ - @JsonProperty("type") - public String getType() { - return "ForceEndTurn"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ForceEndTurn; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ForceEndTurn other) { - return this; - } - - public AgentV1ForceEndTurn build() { - return new AgentV1ForceEndTurn(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak deleted file mode 100644 index f82f59e..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1KeepAlive.Builder.class) -public final class AgentV1KeepAlive { - private final Map additionalProperties; - - private AgentV1KeepAlive(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "KeepAlive"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1KeepAlive; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1KeepAlive other) { - return this; - } - - public AgentV1KeepAlive build() { - return new AgentV1KeepAlive(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak deleted file mode 100644 index 43b8628..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ListenUpdated.Builder.class) -public final class AgentV1ListenUpdated { - private final Map additionalProperties; - - private AgentV1ListenUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for listen update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ListenUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ListenUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ListenUpdated other) { - return this; - } - - public AgentV1ListenUpdated build() { - return new AgentV1ListenUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak deleted file mode 100644 index e6efced..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1PromptUpdated.Builder.class) -public final class AgentV1PromptUpdated { - private final Map additionalProperties; - - private AgentV1PromptUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for prompt update confirmation - */ - @JsonProperty("type") - public String getType() { - return "PromptUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1PromptUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1PromptUpdated other) { - return this; - } - - public AgentV1PromptUpdated build() { - return new AgentV1PromptUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak deleted file mode 100644 index 393f1f9..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1SettingsAgentContextListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1SettingsAgentContextListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1SettingsAgentContextListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1SettingsAgentContextListenProvider(new V1Value(value)); - } - - public static AgentV1SettingsAgentContextListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1SettingsAgentContextListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsAgentContextListenProvider - && value.equals(((AgentV1SettingsAgentContextListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak deleted file mode 100644 index 345ba2f..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1SettingsAgentListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1SettingsAgentListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1SettingsAgentListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1SettingsAgentListenProvider(new V1Value(value)); - } - - public static AgentV1SettingsAgentListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1SettingsAgentListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsAgentListenProvider - && value.equals(((AgentV1SettingsAgentListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak deleted file mode 100644 index ad1fdb2..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1SettingsApplied.Builder.class) -public final class AgentV1SettingsApplied { - private final Map additionalProperties; - - private AgentV1SettingsApplied(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for settings applied confirmation - */ - @JsonProperty("type") - public String getType() { - return "SettingsApplied"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsApplied; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1SettingsApplied other) { - return this; - } - - public AgentV1SettingsApplied build() { - return new AgentV1SettingsApplied(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak deleted file mode 100644 index 8b134b5..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1SpeakUpdated.Builder.class) -public final class AgentV1SpeakUpdated { - private final Map additionalProperties; - - private AgentV1SpeakUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for speak update confirmation - */ - @JsonProperty("type") - public String getType() { - return "SpeakUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SpeakUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1SpeakUpdated other) { - return this; - } - - public AgentV1SpeakUpdated build() { - return new AgentV1SpeakUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak deleted file mode 100644 index 98eaf74..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ThinkLiveUpdated.Builder.class) -public final class AgentV1ThinkLiveUpdated { - private final Map additionalProperties; - - private AgentV1ThinkLiveUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for Think Live model update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ThinkLiveUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ThinkLiveUpdated; - } - - @java.lang.Override - public int hashCode() { - return 1; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ThinkLiveUpdated other) { - return this; - } - - public AgentV1ThinkLiveUpdated build() { - return new AgentV1ThinkLiveUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak deleted file mode 100644 index 2d67cad..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ThinkUpdated.Builder.class) -public final class AgentV1ThinkUpdated { - private final Map additionalProperties; - - private AgentV1ThinkUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for think update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ThinkUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ThinkUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ThinkUpdated other) { - return this; - } - - public AgentV1ThinkUpdated build() { - return new AgentV1ThinkUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak deleted file mode 100644 index e739aec..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1UpdateListenListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1UpdateListenListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1UpdateListenListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1UpdateListenListenProvider(new V1Value(value)); - } - - public static AgentV1UpdateListenListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1UpdateListenListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1UpdateListenListenProvider - && value.equals(((AgentV1UpdateListenListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak deleted file mode 100644 index 3556d31..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1UserStartedSpeaking.Builder.class) -public final class AgentV1UserStartedSpeaking { - private final Map additionalProperties; - - private AgentV1UserStartedSpeaking(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier indicating that the user has begun speaking - */ - @JsonProperty("type") - public String getType() { - return "UserStartedSpeaking"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1UserStartedSpeaking; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1UserStartedSpeaking other) { - return this; - } - - public AgentV1UserStartedSpeaking build() { - return new AgentV1UserStartedSpeaking(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index b648a3e..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,981 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.agent.v1.types.AgentV1AgentAudioDone; -import com.deepgram.resources.agent.v1.types.AgentV1AgentStartedSpeaking; -import com.deepgram.resources.agent.v1.types.AgentV1AgentThinking; -import com.deepgram.resources.agent.v1.types.AgentV1ConversationText; -import com.deepgram.resources.agent.v1.types.AgentV1CustomFromThinkProvider; -import com.deepgram.resources.agent.v1.types.AgentV1CustomToThinkProvider; -import com.deepgram.resources.agent.v1.types.AgentV1Error; -import com.deepgram.resources.agent.v1.types.AgentV1ForceEndTurn; -import com.deepgram.resources.agent.v1.types.AgentV1FrustrationDetected; -import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallCancelled; -import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallRequest; -import com.deepgram.resources.agent.v1.types.AgentV1History; -import com.deepgram.resources.agent.v1.types.AgentV1InjectAgentMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectDynamicAgentMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectUserMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectionRefused; -import com.deepgram.resources.agent.v1.types.AgentV1KeepAlive; -import com.deepgram.resources.agent.v1.types.AgentV1LatencyReport; -import com.deepgram.resources.agent.v1.types.AgentV1ListenUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1PromptUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ReceiveFunctionCallResponse; -import com.deepgram.resources.agent.v1.types.AgentV1SendFunctionCallResponse; -import com.deepgram.resources.agent.v1.types.AgentV1Settings; -import com.deepgram.resources.agent.v1.types.AgentV1SettingsApplied; -import com.deepgram.resources.agent.v1.types.AgentV1SpeakUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ThinkLiveUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ThinkUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateListen; -import com.deepgram.resources.agent.v1.types.AgentV1UpdatePrompt; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateSpeak; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateThink; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateThinkLive; -import com.deepgram.resources.agent.v1.types.AgentV1UserStartedSpeaking; -import com.deepgram.resources.agent.v1.types.AgentV1Warning; -import com.deepgram.resources.agent.v1.types.AgentV1Welcome; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer listenUpdatedHandler; - - private volatile Consumer thinkUpdatedHandler; - - private volatile Consumer thinkLiveUpdatedHandler; - - private volatile Consumer frustrationDetectedHandler; - - private volatile Consumer onFunctionCallResponseHandler; - - private volatile Consumer promptUpdatedHandler; - - private volatile Consumer speakUpdatedHandler; - - private volatile Consumer injectionRefusedHandler; - - private volatile Consumer welcomeHandler; - - private volatile Consumer settingsAppliedHandler; - - private volatile Consumer conversationTextHandler; - - private volatile Consumer userStartedSpeakingHandler; - - private volatile Consumer agentThinkingHandler; - - private volatile Consumer latencyReportHandler; - - private volatile Consumer functionCallRequestHandler; - - private volatile Consumer functionCallCancelledHandler; - - private volatile Consumer agentStartedSpeakingHandler; - - private volatile Consumer agentAudioDoneHandler; - - private volatile Consumer customFromThinkProviderHandler; - - private volatile Consumer errorHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer agentV1HistoryHandler; - - private volatile Consumer agentV1AudioHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - */ - public CompletableFuture connect() { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getAgentURL(); - String fullPath = "/v1/agent/converse"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (agentV1AudioHandler != null) { - agentV1AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends an AgentV1Settings message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendSettings(AgentV1Settings message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateListen message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateListen(AgentV1UpdateListen message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateThink message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateThink(AgentV1UpdateThink message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateThinkLive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateThinkLive(AgentV1UpdateThinkLive message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateSpeak message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateSpeak(AgentV1UpdateSpeak message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectUserMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectUserMessage(AgentV1InjectUserMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectAgentMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectAgentMessage(AgentV1InjectAgentMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectDynamicAgentMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectDynamicAgentMessage(AgentV1InjectDynamicAgentMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1SendFunctionCallResponse message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFunctionCallResponse(AgentV1SendFunctionCallResponse message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1KeepAlive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendKeepAlive(AgentV1KeepAlive message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdatePrompt message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdatePrompt(AgentV1UpdatePrompt message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1ForceEndTurn message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendForceEndTurn(AgentV1ForceEndTurn message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1CustomToThinkProvider message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCustomToThinkProvider(AgentV1CustomToThinkProvider message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Registers a handler for AgentV1ListenUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onListenUpdated(Consumer handler) { - this.listenUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1ThinkUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onThinkUpdated(Consumer handler) { - this.thinkUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1ThinkLiveUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onThinkLiveUpdated(Consumer handler) { - this.thinkLiveUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1FrustrationDetected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFrustrationDetected(Consumer handler) { - this.frustrationDetectedHandler = handler; - } - - /** - * Registers a handler for AgentV1ReceiveFunctionCallResponse messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallResponse(Consumer handler) { - this.onFunctionCallResponseHandler = handler; - } - - /** - * Registers a handler for AgentV1PromptUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onPromptUpdated(Consumer handler) { - this.promptUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1SpeakUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakUpdated(Consumer handler) { - this.speakUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1InjectionRefused messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onInjectionRefused(Consumer handler) { - this.injectionRefusedHandler = handler; - } - - /** - * Registers a handler for AgentV1Welcome messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWelcome(Consumer handler) { - this.welcomeHandler = handler; - } - - /** - * Registers a handler for AgentV1SettingsApplied messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSettingsApplied(Consumer handler) { - this.settingsAppliedHandler = handler; - } - - /** - * Registers a handler for AgentV1ConversationText messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConversationText(Consumer handler) { - this.conversationTextHandler = handler; - } - - /** - * Registers a handler for AgentV1UserStartedSpeaking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onUserStartedSpeaking(Consumer handler) { - this.userStartedSpeakingHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentThinking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentThinking(Consumer handler) { - this.agentThinkingHandler = handler; - } - - /** - * Registers a handler for AgentV1LatencyReport messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onLatencyReport(Consumer handler) { - this.latencyReportHandler = handler; - } - - /** - * Registers a handler for AgentV1FunctionCallRequest messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallRequest(Consumer handler) { - this.functionCallRequestHandler = handler; - } - - /** - * Registers a handler for AgentV1FunctionCallCancelled messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallCancelled(Consumer handler) { - this.functionCallCancelledHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentStartedSpeaking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentStartedSpeaking(Consumer handler) { - this.agentStartedSpeakingHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentAudioDone messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentAudioDone(Consumer handler) { - this.agentAudioDoneHandler = handler; - } - - /** - * Registers a handler for AgentV1CustomFromThinkProvider messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onCustomFromThinkProvider(Consumer handler) { - this.customFromThinkProviderHandler = handler; - } - - /** - * Registers a handler for AgentV1Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler for AgentV1Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for AgentV1History messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentV1History(Consumer handler) { - this.agentV1HistoryHandler = handler; - } - - /** - * Registers a handler for AgentV1Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentV1Audio(Consumer handler) { - this.agentV1AudioHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { - AgentV1ConversationText conversationTextHandlerEvent = null; - try { - conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); - } catch (Exception e) { - } - if (conversationTextHandlerEvent != null) { - if (conversationTextHandler != null) { - conversationTextHandler.accept(conversationTextHandlerEvent); - } - return; - } - } - if (node.has("total_latency") - && node.has("tts_latency") - && node.has("ttt_latency") - && "AgentStartedSpeaking".equals(node.path("type").asText())) { - AgentV1AgentStartedSpeaking agentStartedSpeakingHandlerEvent = null; - try { - agentStartedSpeakingHandlerEvent = - objectMapper.treeToValue(node, AgentV1AgentStartedSpeaking.class); - } catch (Exception e) { - } - if (agentStartedSpeakingHandlerEvent != null) { - if (agentStartedSpeakingHandler != null) { - agentStartedSpeakingHandler.accept(agentStartedSpeakingHandlerEvent); - } - return; - } - } - if (node.has("count") - && node.has("escalated") - && "FrustrationDetected".equals(node.path("type").asText())) { - AgentV1FrustrationDetected frustrationDetectedHandlerEvent = null; - try { - frustrationDetectedHandlerEvent = objectMapper.treeToValue(node, AgentV1FrustrationDetected.class); - } catch (Exception e) { - } - if (frustrationDetectedHandlerEvent != null) { - if (frustrationDetectedHandler != null) { - frustrationDetectedHandler.accept(frustrationDetectedHandlerEvent); - } - return; - } - } - if (node.has("name") - && node.has("content") - && "FunctionCallResponse".equals(node.path("type").asText())) { - AgentV1ReceiveFunctionCallResponse onFunctionCallResponseHandlerEvent = null; - try { - onFunctionCallResponseHandlerEvent = - objectMapper.treeToValue(node, AgentV1ReceiveFunctionCallResponse.class); - } catch (Exception e) { - } - if (onFunctionCallResponseHandlerEvent != null) { - if (onFunctionCallResponseHandler != null) { - onFunctionCallResponseHandler.accept(onFunctionCallResponseHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Error".equals(node.path("type").asText())) { - AgentV1Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, AgentV1Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Warning".equals(node.path("type").asText())) { - AgentV1Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, AgentV1Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("message") - && "InjectionRefused".equals(node.path("type").asText())) { - AgentV1InjectionRefused injectionRefusedHandlerEvent = null; - try { - injectionRefusedHandlerEvent = objectMapper.treeToValue(node, AgentV1InjectionRefused.class); - } catch (Exception e) { - } - if (injectionRefusedHandlerEvent != null) { - if (injectionRefusedHandler != null) { - injectionRefusedHandler.accept(injectionRefusedHandlerEvent); - } - return; - } - } - if (node.has("request_id") && "Welcome".equals(node.path("type").asText())) { - AgentV1Welcome welcomeHandlerEvent = null; - try { - welcomeHandlerEvent = objectMapper.treeToValue(node, AgentV1Welcome.class); - } catch (Exception e) { - } - if (welcomeHandlerEvent != null) { - if (welcomeHandler != null) { - welcomeHandler.accept(welcomeHandlerEvent); - } - return; - } - } - if (node.has("content") && "AgentThinking".equals(node.path("type").asText())) { - AgentV1AgentThinking agentThinkingHandlerEvent = null; - try { - agentThinkingHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentThinking.class); - } catch (Exception e) { - } - if (agentThinkingHandlerEvent != null) { - if (agentThinkingHandler != null) { - agentThinkingHandler.accept(agentThinkingHandlerEvent); - } - return; - } - } - if (node.has("functions") - && "FunctionCallRequest".equals(node.path("type").asText())) { - AgentV1FunctionCallRequest functionCallRequestHandlerEvent = null; - try { - functionCallRequestHandlerEvent = objectMapper.treeToValue(node, AgentV1FunctionCallRequest.class); - } catch (Exception e) { - } - if (functionCallRequestHandlerEvent != null) { - if (functionCallRequestHandler != null) { - functionCallRequestHandler.accept(functionCallRequestHandlerEvent); - } - return; - } - } - if (node.has("functions") - && "FunctionCallCancelled".equals(node.path("type").asText())) { - AgentV1FunctionCallCancelled functionCallCancelledHandlerEvent = null; - try { - functionCallCancelledHandlerEvent = - objectMapper.treeToValue(node, AgentV1FunctionCallCancelled.class); - } catch (Exception e) { - } - if (functionCallCancelledHandlerEvent != null) { - if (functionCallCancelledHandler != null) { - functionCallCancelledHandler.accept(functionCallCancelledHandlerEvent); - } - return; - } - } - if (node.has("content") - && "__customFromThinkProvider".equals(node.path("type").asText())) { - AgentV1CustomFromThinkProvider customFromThinkProviderHandlerEvent = null; - try { - customFromThinkProviderHandlerEvent = - objectMapper.treeToValue(node, AgentV1CustomFromThinkProvider.class); - } catch (Exception e) { - } - if (customFromThinkProviderHandlerEvent != null) { - if (customFromThinkProviderHandler != null) { - customFromThinkProviderHandler.accept(customFromThinkProviderHandlerEvent); - } - return; - } - } - if ("ListenUpdated".equals(node.path("type").asText())) { - AgentV1ListenUpdated listenUpdatedHandlerEvent = null; - try { - listenUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ListenUpdated.class); - } catch (Exception e) { - } - if (listenUpdatedHandlerEvent != null) { - if (listenUpdatedHandler != null) { - listenUpdatedHandler.accept(listenUpdatedHandlerEvent); - } - return; - } - } - if ("ThinkUpdated".equals(node.path("type").asText())) { - AgentV1ThinkUpdated thinkUpdatedHandlerEvent = null; - try { - thinkUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkUpdated.class); - } catch (Exception e) { - } - if (thinkUpdatedHandlerEvent != null) { - if (thinkUpdatedHandler != null) { - thinkUpdatedHandler.accept(thinkUpdatedHandlerEvent); - } - return; - } - } - if ("ThinkLiveUpdated".equals(node.path("type").asText())) { - AgentV1ThinkLiveUpdated thinkLiveUpdatedHandlerEvent = null; - try { - thinkLiveUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkLiveUpdated.class); - } catch (Exception e) { - } - if (thinkLiveUpdatedHandlerEvent != null) { - if (thinkLiveUpdatedHandler != null) { - thinkLiveUpdatedHandler.accept(thinkLiveUpdatedHandlerEvent); - } - return; - } - } - if ("PromptUpdated".equals(node.path("type").asText())) { - AgentV1PromptUpdated promptUpdatedHandlerEvent = null; - try { - promptUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1PromptUpdated.class); - } catch (Exception e) { - } - if (promptUpdatedHandlerEvent != null) { - if (promptUpdatedHandler != null) { - promptUpdatedHandler.accept(promptUpdatedHandlerEvent); - } - return; - } - } - if ("SpeakUpdated".equals(node.path("type").asText())) { - AgentV1SpeakUpdated speakUpdatedHandlerEvent = null; - try { - speakUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1SpeakUpdated.class); - } catch (Exception e) { - } - if (speakUpdatedHandlerEvent != null) { - if (speakUpdatedHandler != null) { - speakUpdatedHandler.accept(speakUpdatedHandlerEvent); - } - return; - } - } - if ("SettingsApplied".equals(node.path("type").asText())) { - AgentV1SettingsApplied settingsAppliedHandlerEvent = null; - try { - settingsAppliedHandlerEvent = objectMapper.treeToValue(node, AgentV1SettingsApplied.class); - } catch (Exception e) { - } - if (settingsAppliedHandlerEvent != null) { - if (settingsAppliedHandler != null) { - settingsAppliedHandler.accept(settingsAppliedHandlerEvent); - } - return; - } - } - if ("UserStartedSpeaking".equals(node.path("type").asText())) { - AgentV1UserStartedSpeaking userStartedSpeakingHandlerEvent = null; - try { - userStartedSpeakingHandlerEvent = objectMapper.treeToValue(node, AgentV1UserStartedSpeaking.class); - } catch (Exception e) { - } - if (userStartedSpeakingHandlerEvent != null) { - if (userStartedSpeakingHandler != null) { - userStartedSpeakingHandler.accept(userStartedSpeakingHandlerEvent); - } - return; - } - } - if ("LatencyReport".equals(node.path("type").asText())) { - AgentV1LatencyReport latencyReportHandlerEvent = null; - try { - latencyReportHandlerEvent = objectMapper.treeToValue(node, AgentV1LatencyReport.class); - } catch (Exception e) { - } - if (latencyReportHandlerEvent != null) { - if (latencyReportHandler != null) { - latencyReportHandler.accept(latencyReportHandlerEvent); - } - return; - } - } - if ("AgentAudioDone".equals(node.path("type").asText())) { - AgentV1AgentAudioDone agentAudioDoneHandlerEvent = null; - try { - agentAudioDoneHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentAudioDone.class); - } catch (Exception e) { - } - if (agentAudioDoneHandlerEvent != null) { - if (agentAudioDoneHandler != null) { - agentAudioDoneHandler.accept(agentAudioDoneHandlerEvent); - } - return; - } - } - AgentV1History agentV1HistoryHandlerEvent = null; - try { - agentV1HistoryHandlerEvent = objectMapper.treeToValue(node, AgentV1History.class); - } catch (Exception e) { - } - if (agentV1HistoryHandlerEvent != null) { - if (agentV1HistoryHandler != null) { - agentV1HistoryHandler.accept(agentV1HistoryHandlerEvent); - } - return; - } - if (onMessageHandler == null && onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak deleted file mode 100644 index 448c459..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak +++ /dev/null @@ -1,1932 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.media.requests; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV1RequestUrl.Builder.class) -public final class ListenV1RequestUrl { - private final Optional> extra; - - private final Optional> tag; - - private final Optional> customTopic; - - private final Optional> customIntent; - - private final Optional> keyterm; - - private final Optional> keywords; - - private final Optional> languageHint; - - private final Optional> replace; - - private final Optional> search; - - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional sentiment; - - private final Optional summarize; - - private final Optional topics; - - private final Optional customTopicMode; - - private final Optional intents; - - private final Optional customIntentMode; - - private final Optional detectEntities; - - private final Optional detectLanguage; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional fillerWords; - - private final Optional language; - - private final Optional measurements; - - private final Optional model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional paragraphs; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional smartFormat; - - private final Optional utterances; - - private final Optional uttSplit; - - private final Optional version; - - private final Optional mipOptOut; - - private final String url; - - private final Map additionalProperties; - - private ListenV1RequestUrl( - Optional> extra, - Optional> tag, - Optional> customTopic, - Optional> customIntent, - Optional> keyterm, - Optional> keywords, - Optional> languageHint, - Optional> replace, - Optional> search, - Optional callback, - Optional callbackMethod, - Optional sentiment, - Optional summarize, - Optional topics, - Optional customTopicMode, - Optional intents, - Optional customIntentMode, - Optional detectEntities, - Optional detectLanguage, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional fillerWords, - Optional language, - Optional measurements, - Optional model, - Optional multichannel, - Optional numerals, - Optional paragraphs, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional smartFormat, - Optional utterances, - Optional uttSplit, - Optional version, - Optional mipOptOut, - String url, - Map additionalProperties) { - this.extra = extra; - this.tag = tag; - this.customTopic = customTopic; - this.customIntent = customIntent; - this.keyterm = keyterm; - this.keywords = keywords; - this.languageHint = languageHint; - this.replace = replace; - this.search = search; - this.callback = callback; - this.callbackMethod = callbackMethod; - this.sentiment = sentiment; - this.summarize = summarize; - this.topics = topics; - this.customTopicMode = customTopicMode; - this.intents = intents; - this.customIntentMode = customIntentMode; - this.detectEntities = detectEntities; - this.detectLanguage = detectLanguage; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.fillerWords = fillerWords; - this.language = language; - this.measurements = measurements; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.paragraphs = paragraphs; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.smartFormat = smartFormat; - this.utterances = utterances; - this.uttSplit = uttSplit; - this.version = version; - this.mipOptOut = mipOptOut; - this.url = url; - this.additionalProperties = additionalProperties; - } - - /** - * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing - */ - @JsonIgnore - public Optional> getExtra() { - return extra; - } - - /** - * @return Label your requests for the purpose of identification during usage reporting - */ - @JsonIgnore - public Optional> getTag() { - return tag; - } - - /** - * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. - */ - @JsonIgnore - public Optional> getCustomTopic() { - return customTopic; - } - - /** - * @return Custom intents you want the model to detect within your input audio if present - */ - @JsonIgnore - public Optional> getCustomIntent() { - return customIntent; - } - - /** - * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. - *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @JsonIgnore - public Optional> getKeyterm() { - return keyterm; - } - - /** - * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. - */ - @JsonIgnore - public Optional> getKeywords() { - return keywords; - } - - /** - * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. - */ - @JsonIgnore - public Optional> getLanguageHint() { - return languageHint; - } - - /** - * @return Search for terms or phrases in submitted audio and replaces them - */ - @JsonIgnore - public Optional> getReplace() { - return replace; - } - - /** - * @return Search for terms or phrases in submitted audio - */ - @JsonIgnore - public Optional> getSearch() { - return search; - } - - /** - * @return URL to which we'll make the callback request - */ - @JsonIgnore - public Optional getCallback() { - return callback; - } - - /** - * @return HTTP method by which the callback request will be made - */ - @JsonIgnore - public Optional getCallbackMethod() { - return callbackMethod; - } - - /** - * @return Recognizes the sentiment throughout a transcript or text - */ - @JsonIgnore - public Optional getSentiment() { - return sentiment; - } - - /** - * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. - */ - @JsonIgnore - public Optional getSummarize() { - return summarize; - } - - /** - * @return Detect topics throughout a transcript or text - */ - @JsonIgnore - public Optional getTopics() { - return topics; - } - - /** - * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param - */ - @JsonIgnore - public Optional getCustomTopicMode() { - return customTopicMode; - } - - /** - * @return Recognizes speaker intent throughout a transcript or text - */ - @JsonIgnore - public Optional getIntents() { - return intents; - } - - /** - * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. - */ - @JsonIgnore - public Optional getCustomIntentMode() { - return customIntentMode; - } - - /** - * @return Identifies and extracts key entities from content in submitted audio - */ - @JsonIgnore - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Identifies the dominant language spoken in submitted audio - */ - @JsonIgnore - public Optional getDetectLanguage() { - return detectLanguage; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonIgnore - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. - */ - @JsonIgnore - public Optional getDiarizeModel() { - return diarizeModel; - } - - /** - * @return Dictation mode for controlling formatting with dictated speech - */ - @JsonIgnore - public Optional getDictation() { - return dictation; - } - - /** - * @return Specify the expected encoding of your submitted audio - */ - @JsonIgnore - public Optional getEncoding() { - return encoding; - } - - /** - * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" - */ - @JsonIgnore - public Optional getFillerWords() { - return fillerWords; - } - - /** - * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available - */ - @JsonIgnore - public Optional getLanguage() { - return language; - } - - /** - * @return Spoken measurements will be converted to their corresponding abbreviations - */ - @JsonIgnore - public Optional getMeasurements() { - return measurements; - } - - /** - * @return AI model used to process submitted audio - */ - @JsonIgnore - public Optional getModel() { - return model; - } - - /** - * @return Transcribe each audio channel independently - */ - @JsonIgnore - public Optional getMultichannel() { - return multichannel; - } - - /** - * @return Numerals converts numbers from written format to numerical format - */ - @JsonIgnore - public Optional getNumerals() { - return numerals; - } - - /** - * @return Splits audio into paragraphs to improve transcript readability - */ - @JsonIgnore - public Optional getParagraphs() { - return paragraphs; - } - - /** - * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely - */ - @JsonIgnore - public Optional getProfanityFilter() { - return profanityFilter; - } - - /** - * @return Add punctuation and capitalization to the transcript - */ - @JsonIgnore - public Optional getPunctuate() { - return punctuate; - } - - /** - * @return Redaction removes sensitive information from your transcripts - */ - @JsonIgnore - public Optional getRedact() { - return redact; - } - - /** - * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability - */ - @JsonIgnore - public Optional getSmartFormat() { - return smartFormat; - } - - /** - * @return Segments speech into meaningful semantic units - */ - @JsonIgnore - public Optional getUtterances() { - return utterances; - } - - /** - * @return Seconds to wait before detecting a pause between words in submitted audio - */ - @JsonIgnore - public Optional getUttSplit() { - return uttSplit; - } - - /** - * @return Version of an AI model to use - */ - @JsonIgnore - public Optional getVersion() { - return version; - } - - /** - * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip - */ - @JsonIgnore - public Optional getMipOptOut() { - return mipOptOut; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV1RequestUrl && equalTo((ListenV1RequestUrl) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListenV1RequestUrl other) { - return extra.equals(other.extra) - && tag.equals(other.tag) - && customTopic.equals(other.customTopic) - && customIntent.equals(other.customIntent) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && languageHint.equals(other.languageHint) - && replace.equals(other.replace) - && search.equals(other.search) - && callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && sentiment.equals(other.sentiment) - && summarize.equals(other.summarize) - && topics.equals(other.topics) - && customTopicMode.equals(other.customTopicMode) - && intents.equals(other.intents) - && customIntentMode.equals(other.customIntentMode) - && detectEntities.equals(other.detectEntities) - && detectLanguage.equals(other.detectLanguage) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && fillerWords.equals(other.fillerWords) - && language.equals(other.language) - && measurements.equals(other.measurements) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && paragraphs.equals(other.paragraphs) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && smartFormat.equals(other.smartFormat) - && utterances.equals(other.utterances) - && uttSplit.equals(other.uttSplit) - && version.equals(other.version) - && mipOptOut.equals(other.mipOptOut) - && url.equals(other.url); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.extra, - this.tag, - this.customTopic, - this.customIntent, - this.keyterm, - this.keywords, - this.languageHint, - this.replace, - this.search, - this.callback, - this.callbackMethod, - this.sentiment, - this.summarize, - this.topics, - this.customTopicMode, - this.intents, - this.customIntentMode, - this.detectEntities, - this.detectLanguage, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.fillerWords, - this.language, - this.measurements, - this.model, - this.multichannel, - this.numerals, - this.paragraphs, - this.profanityFilter, - this.punctuate, - this.redact, - this.smartFormat, - this.utterances, - this.uttSplit, - this.version, - this.mipOptOut, - this.url); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UrlStage builder() { - return new Builder(); - } - - public interface UrlStage { - _FinalStage url(@NotNull String url); - - Builder from(ListenV1RequestUrl other); - } - - public interface _FinalStage { - ListenV1RequestUrl build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - _FinalStage extra(Optional> extra); - - _FinalStage extra(List extra); - - _FinalStage extra(String extra); - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - _FinalStage tag(Optional> tag); - - _FinalStage tag(List tag); - - _FinalStage tag(String tag); - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - _FinalStage customTopic(Optional> customTopic); - - _FinalStage customTopic(List customTopic); - - _FinalStage customTopic(String customTopic); - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - _FinalStage customIntent(Optional> customIntent); - - _FinalStage customIntent(List customIntent); - - _FinalStage customIntent(String customIntent); - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - _FinalStage keyterm(Optional> keyterm); - - _FinalStage keyterm(List keyterm); - - _FinalStage keyterm(String keyterm); - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - _FinalStage keywords(Optional> keywords); - - _FinalStage keywords(List keywords); - - _FinalStage keywords(String keywords); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } - - default _FinalStage languageHint(List languageHint) { - return this; - } - - default _FinalStage languageHint(String languageHint) { - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - _FinalStage replace(Optional> replace); - - _FinalStage replace(List replace); - - _FinalStage replace(String replace); - - /** - *

Search for terms or phrases in submitted audio

- */ - _FinalStage search(Optional> search); - - _FinalStage search(List search); - - _FinalStage search(String search); - - /** - *

URL to which we'll make the callback request

- */ - _FinalStage callback(Optional callback); - - _FinalStage callback(String callback); - - /** - *

HTTP method by which the callback request will be made

- */ - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - _FinalStage sentiment(Optional sentiment); - - _FinalStage sentiment(Boolean sentiment); - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - _FinalStage summarize(Optional summarize); - - _FinalStage summarize(MediaTranscribeRequestSummarize summarize); - - /** - *

Detect topics throughout a transcript or text

- */ - _FinalStage topics(Optional topics); - - _FinalStage topics(Boolean topics); - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - _FinalStage customTopicMode(Optional customTopicMode); - - _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - _FinalStage intents(Optional intents); - - _FinalStage intents(Boolean intents); - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - _FinalStage customIntentMode(Optional customIntentMode); - - _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(Boolean detectEntities); - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - _FinalStage detectLanguage(Optional detectLanguage); - - _FinalStage detectLanguage(Boolean detectLanguage); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(Boolean diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(Boolean dictation); - - /** - *

Specify the expected encoding of your submitted audio

- */ - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(MediaTranscribeRequestEncoding encoding); - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - _FinalStage fillerWords(Optional fillerWords); - - _FinalStage fillerWords(Boolean fillerWords); - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - _FinalStage language(Optional language); - - _FinalStage language(String language); - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - _FinalStage measurements(Optional measurements); - - _FinalStage measurements(Boolean measurements); - - /** - *

AI model used to process submitted audio

- */ - _FinalStage model(Optional model); - - _FinalStage model(MediaTranscribeRequestModel model); - - /** - *

Transcribe each audio channel independently

- */ - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(Boolean multichannel); - - /** - *

Numerals converts numbers from written format to numerical format

- */ - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(Boolean numerals); - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - _FinalStage paragraphs(Optional paragraphs); - - _FinalStage paragraphs(Boolean paragraphs); - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(Boolean profanityFilter); - - /** - *

Add punctuation and capitalization to the transcript

- */ - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(Boolean punctuate); - - /** - *

Redaction removes sensitive information from your transcripts

- */ - _FinalStage redact(Optional redact); - - _FinalStage redact(String redact); - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(Boolean smartFormat); - - /** - *

Segments speech into meaningful semantic units

- */ - _FinalStage utterances(Optional utterances); - - _FinalStage utterances(Boolean utterances); - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - _FinalStage uttSplit(Optional uttSplit); - - _FinalStage uttSplit(Double uttSplit); - - /** - *

Version of an AI model to use

- */ - _FinalStage version(Optional version); - - _FinalStage version(MediaTranscribeRequestVersion version); - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(Boolean mipOptOut); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, _FinalStage { - private String url; - - private Optional mipOptOut = Optional.empty(); - - private Optional version = Optional.empty(); - - private Optional uttSplit = Optional.empty(); - - private Optional utterances = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional paragraphs = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional model = Optional.empty(); - - private Optional measurements = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional fillerWords = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectLanguage = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional customIntentMode = Optional.empty(); - - private Optional intents = Optional.empty(); - - private Optional customTopicMode = Optional.empty(); - - private Optional topics = Optional.empty(); - - private Optional summarize = Optional.empty(); - - private Optional sentiment = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - private Optional> search = Optional.empty(); - - private Optional> replace = Optional.empty(); - - private Optional> languageHint = Optional.empty(); - - private Optional> keywords = Optional.empty(); - - private Optional> keyterm = Optional.empty(); - - private Optional> customIntent = Optional.empty(); - - private Optional> customTopic = Optional.empty(); - - private Optional> tag = Optional.empty(); - - private Optional> extra = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListenV1RequestUrl other) { - extra(other.getExtra()); - tag(other.getTag()); - customTopic(other.getCustomTopic()); - customIntent(other.getCustomIntent()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - languageHint(other.getLanguageHint()); - replace(other.getReplace()); - search(other.getSearch()); - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - sentiment(other.getSentiment()); - summarize(other.getSummarize()); - topics(other.getTopics()); - customTopicMode(other.getCustomTopicMode()); - intents(other.getIntents()); - customIntentMode(other.getCustomIntentMode()); - detectEntities(other.getDetectEntities()); - detectLanguage(other.getDetectLanguage()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - fillerWords(other.getFillerWords()); - language(other.getLanguage()); - measurements(other.getMeasurements()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - paragraphs(other.getParagraphs()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - smartFormat(other.getSmartFormat()); - utterances(other.getUtterances()); - uttSplit(other.getUttSplit()); - version(other.getVersion()); - mipOptOut(other.getMipOptOut()); - url(other.getUrl()); - return this; - } - - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(@NotNull String url) { - this.url = Objects.requireNonNull(url, "url must not be null"); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage mipOptOut(Boolean mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - /** - *

Version of an AI model to use

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage version(MediaTranscribeRequestVersion version) { - this.version = Optional.ofNullable(version); - return this; - } - - /** - *

Version of an AI model to use

- */ - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage uttSplit(Double uttSplit) { - this.uttSplit = Optional.ofNullable(uttSplit); - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) - public _FinalStage uttSplit(Optional uttSplit) { - this.uttSplit = uttSplit; - return this; - } - - /** - *

Segments speech into meaningful semantic units

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage utterances(Boolean utterances) { - this.utterances = Optional.ofNullable(utterances); - return this; - } - - /** - *

Segments speech into meaningful semantic units

- */ - @java.lang.Override - @JsonSetter(value = "utterances", nulls = Nulls.SKIP) - public _FinalStage utterances(Optional utterances) { - this.utterances = utterances; - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage smartFormat(Boolean smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage redact(String redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- */ - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- */ - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profanityFilter(Boolean profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage paragraphs(Boolean paragraphs) { - this.paragraphs = Optional.ofNullable(paragraphs); - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - @java.lang.Override - @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) - public _FinalStage paragraphs(Optional paragraphs) { - this.paragraphs = paragraphs; - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage numerals(Boolean numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- */ - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - /** - *

Transcribe each audio channel independently

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage multichannel(Boolean multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - /** - *

Transcribe each audio channel independently

- */ - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - /** - *

AI model used to process submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage model(MediaTranscribeRequestModel model) { - this.model = Optional.ofNullable(model); - return this; - } - - /** - *

AI model used to process submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public _FinalStage model(Optional model) { - this.model = model; - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage measurements(Boolean measurements) { - this.measurements = Optional.ofNullable(measurements); - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - @java.lang.Override - @JsonSetter(value = "measurements", nulls = Nulls.SKIP) - public _FinalStage measurements(Optional measurements) { - this.measurements = measurements; - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage language(String language) { - this.language = Optional.ofNullable(language); - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fillerWords(Boolean fillerWords) { - this.fillerWords = Optional.ofNullable(fillerWords); - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - @java.lang.Override - @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) - public _FinalStage fillerWords(Optional fillerWords) { - this.fillerWords = fillerWords; - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage dictation(Boolean dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(Boolean diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectLanguage(Boolean detectLanguage) { - this.detectLanguage = Optional.ofNullable(detectLanguage); - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) - public _FinalStage detectLanguage(Optional detectLanguage) { - this.detectLanguage = detectLanguage; - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectEntities(Boolean detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { - this.customIntentMode = Optional.ofNullable(customIntentMode); - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) - public _FinalStage customIntentMode(Optional customIntentMode) { - this.customIntentMode = customIntentMode; - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage intents(Boolean intents) { - this.intents = Optional.ofNullable(intents); - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "intents", nulls = Nulls.SKIP) - public _FinalStage intents(Optional intents) { - this.intents = intents; - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { - this.customTopicMode = Optional.ofNullable(customTopicMode); - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) - public _FinalStage customTopicMode(Optional customTopicMode) { - this.customTopicMode = customTopicMode; - return this; - } - - /** - *

Detect topics throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage topics(Boolean topics) { - this.topics = Optional.ofNullable(topics); - return this; - } - - /** - *

Detect topics throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "topics", nulls = Nulls.SKIP) - public _FinalStage topics(Optional topics) { - this.topics = topics; - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { - this.summarize = Optional.ofNullable(summarize); - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - @java.lang.Override - @JsonSetter(value = "summarize", nulls = Nulls.SKIP) - public _FinalStage summarize(Optional summarize) { - this.summarize = summarize; - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sentiment(Boolean sentiment) { - this.sentiment = Optional.ofNullable(sentiment); - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) - public _FinalStage sentiment(Optional sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - *

HTTP method by which the callback request will be made

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - /** - *

HTTP method by which the callback request will be made

- */ - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - /** - *

URL to which we'll make the callback request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callback(String callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - /** - *

URL to which we'll make the callback request

- */ - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public _FinalStage search(String search) { - this.search = Optional.of(Collections.singletonList(search)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage search(List search) { - this.search = Optional.ofNullable(search); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional> search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage replace(String replace) { - this.replace = Optional.of(Collections.singletonList(replace)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage replace(List replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional> replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(String languageHint) { - this.languageHint = Optional.of(Collections.singletonList(languageHint)); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageHint(List languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional> languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage keywords(String keywords) { - this.keywords = Optional.of(Collections.singletonList(keywords)); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keywords(List keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional> keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(String keyterm) { - this.keyterm = Optional.of(Collections.singletonList(keyterm)); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keyterm(List keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional> keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage customIntent(String customIntent) { - this.customIntent = Optional.of(Collections.singletonList(customIntent)); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntent(List customIntent) { - this.customIntent = Optional.ofNullable(customIntent); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) - public _FinalStage customIntent(Optional> customIntent) { - this.customIntent = customIntent; - return this; - } - - @java.lang.Override - public _FinalStage customTopic(String customTopic) { - this.customTopic = Optional.of(Collections.singletonList(customTopic)); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopic(List customTopic) { - this.customTopic = Optional.ofNullable(customTopic); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) - public _FinalStage customTopic(Optional> customTopic) { - this.customTopic = customTopic; - return this; - } - - @java.lang.Override - public _FinalStage tag(String tag) { - this.tag = Optional.of(Collections.singletonList(tag)); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tag(List tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional> tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage extra(String extra) { - this.extra = Optional.of(Collections.singletonList(extra)); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage extra(List extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional> extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public ListenV1RequestUrl build() { - return new ListenV1RequestUrl( - extra, - tag, - customTopic, - customIntent, - keyterm, - keywords, - languageHint, - replace, - search, - callback, - callbackMethod, - sentiment, - summarize, - topics, - customTopicMode, - intents, - customIntentMode, - detectEntities, - detectLanguage, - diarize, - diarizeModel, - dictation, - encoding, - fillerWords, - language, - measurements, - model, - multichannel, - numerals, - paragraphs, - profanityFilter, - punctuate, - redact, - smartFormat, - utterances, - uttSplit, - version, - mipOptOut, - url, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak deleted file mode 100644 index f094b06..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak +++ /dev/null @@ -1,1931 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.media.requests; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = MediaTranscribeRequestOctetStream.Builder.class) -public final class MediaTranscribeRequestOctetStream { - private final Optional> extra; - - private final Optional> tag; - - private final Optional> customTopic; - - private final Optional> customIntent; - - private final Optional> keyterm; - - private final Optional> keywords; - - private final Optional> languageHint; - - private final Optional> replace; - - private final Optional> search; - - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional sentiment; - - private final Optional summarize; - - private final Optional topics; - - private final Optional customTopicMode; - - private final Optional intents; - - private final Optional customIntentMode; - - private final Optional detectEntities; - - private final Optional detectLanguage; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional fillerWords; - - private final Optional language; - - private final Optional measurements; - - private final Optional model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional paragraphs; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional smartFormat; - - private final Optional utterances; - - private final Optional uttSplit; - - private final Optional version; - - private final Optional mipOptOut; - - private final byte[] body; - - private final Map additionalProperties; - - private MediaTranscribeRequestOctetStream( - Optional> extra, - Optional> tag, - Optional> customTopic, - Optional> customIntent, - Optional> keyterm, - Optional> keywords, - Optional> languageHint, - Optional> replace, - Optional> search, - Optional callback, - Optional callbackMethod, - Optional sentiment, - Optional summarize, - Optional topics, - Optional customTopicMode, - Optional intents, - Optional customIntentMode, - Optional detectEntities, - Optional detectLanguage, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional fillerWords, - Optional language, - Optional measurements, - Optional model, - Optional multichannel, - Optional numerals, - Optional paragraphs, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional smartFormat, - Optional utterances, - Optional uttSplit, - Optional version, - Optional mipOptOut, - byte[] body, - Map additionalProperties) { - this.extra = extra; - this.tag = tag; - this.customTopic = customTopic; - this.customIntent = customIntent; - this.keyterm = keyterm; - this.keywords = keywords; - this.languageHint = languageHint; - this.replace = replace; - this.search = search; - this.callback = callback; - this.callbackMethod = callbackMethod; - this.sentiment = sentiment; - this.summarize = summarize; - this.topics = topics; - this.customTopicMode = customTopicMode; - this.intents = intents; - this.customIntentMode = customIntentMode; - this.detectEntities = detectEntities; - this.detectLanguage = detectLanguage; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.fillerWords = fillerWords; - this.language = language; - this.measurements = measurements; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.paragraphs = paragraphs; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.smartFormat = smartFormat; - this.utterances = utterances; - this.uttSplit = uttSplit; - this.version = version; - this.mipOptOut = mipOptOut; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing - */ - @JsonProperty("extra") - public Optional> getExtra() { - return extra; - } - - /** - * @return Label your requests for the purpose of identification during usage reporting - */ - @JsonProperty("tag") - public Optional> getTag() { - return tag; - } - - /** - * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. - */ - @JsonProperty("custom_topic") - public Optional> getCustomTopic() { - return customTopic; - } - - /** - * @return Custom intents you want the model to detect within your input audio if present - */ - @JsonProperty("custom_intent") - public Optional> getCustomIntent() { - return customIntent; - } - - /** - * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. - *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @JsonProperty("keyterm") - public Optional> getKeyterm() { - return keyterm; - } - - /** - * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. - */ - @JsonProperty("keywords") - public Optional> getKeywords() { - return keywords; - } - - /** - * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. - */ - @JsonProperty("language_hint") - public Optional> getLanguageHint() { - return languageHint; - } - - /** - * @return Search for terms or phrases in submitted audio and replaces them - */ - @JsonProperty("replace") - public Optional> getReplace() { - return replace; - } - - /** - * @return Search for terms or phrases in submitted audio - */ - @JsonProperty("search") - public Optional> getSearch() { - return search; - } - - /** - * @return URL to which we'll make the callback request - */ - @JsonProperty("callback") - public Optional getCallback() { - return callback; - } - - /** - * @return HTTP method by which the callback request will be made - */ - @JsonProperty("callback_method") - public Optional getCallbackMethod() { - return callbackMethod; - } - - /** - * @return Recognizes the sentiment throughout a transcript or text - */ - @JsonProperty("sentiment") - public Optional getSentiment() { - return sentiment; - } - - /** - * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. - */ - @JsonProperty("summarize") - public Optional getSummarize() { - return summarize; - } - - /** - * @return Detect topics throughout a transcript or text - */ - @JsonProperty("topics") - public Optional getTopics() { - return topics; - } - - /** - * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param - */ - @JsonProperty("custom_topic_mode") - public Optional getCustomTopicMode() { - return customTopicMode; - } - - /** - * @return Recognizes speaker intent throughout a transcript or text - */ - @JsonProperty("intents") - public Optional getIntents() { - return intents; - } - - /** - * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. - */ - @JsonProperty("custom_intent_mode") - public Optional getCustomIntentMode() { - return customIntentMode; - } - - /** - * @return Identifies and extracts key entities from content in submitted audio - */ - @JsonProperty("detect_entities") - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Identifies the dominant language spoken in submitted audio - */ - @JsonProperty("detect_language") - public Optional getDetectLanguage() { - return detectLanguage; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonProperty("diarize") - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. - */ - @JsonProperty("diarize_model") - public Optional getDiarizeModel() { - return diarizeModel; - } - - /** - * @return Dictation mode for controlling formatting with dictated speech - */ - @JsonProperty("dictation") - public Optional getDictation() { - return dictation; - } - - /** - * @return Specify the expected encoding of your submitted audio - */ - @JsonProperty("encoding") - public Optional getEncoding() { - return encoding; - } - - /** - * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" - */ - @JsonProperty("filler_words") - public Optional getFillerWords() { - return fillerWords; - } - - /** - * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available - */ - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - /** - * @return Spoken measurements will be converted to their corresponding abbreviations - */ - @JsonProperty("measurements") - public Optional getMeasurements() { - return measurements; - } - - /** - * @return AI model used to process submitted audio - */ - @JsonProperty("model") - public Optional getModel() { - return model; - } - - /** - * @return Transcribe each audio channel independently - */ - @JsonProperty("multichannel") - public Optional getMultichannel() { - return multichannel; - } - - /** - * @return Numerals converts numbers from written format to numerical format - */ - @JsonProperty("numerals") - public Optional getNumerals() { - return numerals; - } - - /** - * @return Splits audio into paragraphs to improve transcript readability - */ - @JsonProperty("paragraphs") - public Optional getParagraphs() { - return paragraphs; - } - - /** - * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely - */ - @JsonProperty("profanity_filter") - public Optional getProfanityFilter() { - return profanityFilter; - } - - /** - * @return Add punctuation and capitalization to the transcript - */ - @JsonProperty("punctuate") - public Optional getPunctuate() { - return punctuate; - } - - /** - * @return Redaction removes sensitive information from your transcripts - */ - @JsonProperty("redact") - public Optional getRedact() { - return redact; - } - - /** - * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability - */ - @JsonProperty("smart_format") - public Optional getSmartFormat() { - return smartFormat; - } - - /** - * @return Segments speech into meaningful semantic units - */ - @JsonProperty("utterances") - public Optional getUtterances() { - return utterances; - } - - /** - * @return Seconds to wait before detecting a pause between words in submitted audio - */ - @JsonProperty("utt_split") - public Optional getUttSplit() { - return uttSplit; - } - - /** - * @return Version of an AI model to use - */ - @JsonProperty("version") - public Optional getVersion() { - return version; - } - - /** - * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip - */ - @JsonProperty("mip_opt_out") - public Optional getMipOptOut() { - return mipOptOut; - } - - @JsonProperty("body") - public byte[] getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MediaTranscribeRequestOctetStream && equalTo((MediaTranscribeRequestOctetStream) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MediaTranscribeRequestOctetStream other) { - return extra.equals(other.extra) - && tag.equals(other.tag) - && customTopic.equals(other.customTopic) - && customIntent.equals(other.customIntent) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && languageHint.equals(other.languageHint) - && replace.equals(other.replace) - && search.equals(other.search) - && callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && sentiment.equals(other.sentiment) - && summarize.equals(other.summarize) - && topics.equals(other.topics) - && customTopicMode.equals(other.customTopicMode) - && intents.equals(other.intents) - && customIntentMode.equals(other.customIntentMode) - && detectEntities.equals(other.detectEntities) - && detectLanguage.equals(other.detectLanguage) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && fillerWords.equals(other.fillerWords) - && language.equals(other.language) - && measurements.equals(other.measurements) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && paragraphs.equals(other.paragraphs) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && smartFormat.equals(other.smartFormat) - && utterances.equals(other.utterances) - && uttSplit.equals(other.uttSplit) - && version.equals(other.version) - && mipOptOut.equals(other.mipOptOut) - && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.extra, - this.tag, - this.customTopic, - this.customIntent, - this.keyterm, - this.keywords, - this.languageHint, - this.replace, - this.search, - this.callback, - this.callbackMethod, - this.sentiment, - this.summarize, - this.topics, - this.customTopicMode, - this.intents, - this.customIntentMode, - this.detectEntities, - this.detectLanguage, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.fillerWords, - this.language, - this.measurements, - this.model, - this.multichannel, - this.numerals, - this.paragraphs, - this.profanityFilter, - this.punctuate, - this.redact, - this.smartFormat, - this.utterances, - this.uttSplit, - this.version, - this.mipOptOut, - this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static BodyStage builder() { - return new Builder(); - } - - public interface BodyStage { - _FinalStage body(@NotNull byte[] body); - - Builder from(MediaTranscribeRequestOctetStream other); - } - - public interface _FinalStage { - MediaTranscribeRequestOctetStream build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - _FinalStage extra(Optional> extra); - - _FinalStage extra(List extra); - - _FinalStage extra(String extra); - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - _FinalStage tag(Optional> tag); - - _FinalStage tag(List tag); - - _FinalStage tag(String tag); - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - _FinalStage customTopic(Optional> customTopic); - - _FinalStage customTopic(List customTopic); - - _FinalStage customTopic(String customTopic); - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - _FinalStage customIntent(Optional> customIntent); - - _FinalStage customIntent(List customIntent); - - _FinalStage customIntent(String customIntent); - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - _FinalStage keyterm(Optional> keyterm); - - _FinalStage keyterm(List keyterm); - - _FinalStage keyterm(String keyterm); - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - _FinalStage keywords(Optional> keywords); - - _FinalStage keywords(List keywords); - - _FinalStage keywords(String keywords); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } - - default _FinalStage languageHint(List languageHint) { - return this; - } - - default _FinalStage languageHint(String languageHint) { - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - _FinalStage replace(Optional> replace); - - _FinalStage replace(List replace); - - _FinalStage replace(String replace); - - /** - *

Search for terms or phrases in submitted audio

- */ - _FinalStage search(Optional> search); - - _FinalStage search(List search); - - _FinalStage search(String search); - - /** - *

URL to which we'll make the callback request

- */ - _FinalStage callback(Optional callback); - - _FinalStage callback(String callback); - - /** - *

HTTP method by which the callback request will be made

- */ - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - _FinalStage sentiment(Optional sentiment); - - _FinalStage sentiment(Boolean sentiment); - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - _FinalStage summarize(Optional summarize); - - _FinalStage summarize(MediaTranscribeRequestSummarize summarize); - - /** - *

Detect topics throughout a transcript or text

- */ - _FinalStage topics(Optional topics); - - _FinalStage topics(Boolean topics); - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - _FinalStage customTopicMode(Optional customTopicMode); - - _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - _FinalStage intents(Optional intents); - - _FinalStage intents(Boolean intents); - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - _FinalStage customIntentMode(Optional customIntentMode); - - _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(Boolean detectEntities); - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - _FinalStage detectLanguage(Optional detectLanguage); - - _FinalStage detectLanguage(Boolean detectLanguage); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(Boolean diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(Boolean dictation); - - /** - *

Specify the expected encoding of your submitted audio

- */ - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(MediaTranscribeRequestEncoding encoding); - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - _FinalStage fillerWords(Optional fillerWords); - - _FinalStage fillerWords(Boolean fillerWords); - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - _FinalStage language(Optional language); - - _FinalStage language(String language); - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - _FinalStage measurements(Optional measurements); - - _FinalStage measurements(Boolean measurements); - - /** - *

AI model used to process submitted audio

- */ - _FinalStage model(Optional model); - - _FinalStage model(MediaTranscribeRequestModel model); - - /** - *

Transcribe each audio channel independently

- */ - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(Boolean multichannel); - - /** - *

Numerals converts numbers from written format to numerical format

- */ - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(Boolean numerals); - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - _FinalStage paragraphs(Optional paragraphs); - - _FinalStage paragraphs(Boolean paragraphs); - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(Boolean profanityFilter); - - /** - *

Add punctuation and capitalization to the transcript

- */ - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(Boolean punctuate); - - /** - *

Redaction removes sensitive information from your transcripts

- */ - _FinalStage redact(Optional redact); - - _FinalStage redact(String redact); - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(Boolean smartFormat); - - /** - *

Segments speech into meaningful semantic units

- */ - _FinalStage utterances(Optional utterances); - - _FinalStage utterances(Boolean utterances); - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - _FinalStage uttSplit(Optional uttSplit); - - _FinalStage uttSplit(Double uttSplit); - - /** - *

Version of an AI model to use

- */ - _FinalStage version(Optional version); - - _FinalStage version(MediaTranscribeRequestVersion version); - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(Boolean mipOptOut); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements BodyStage, _FinalStage { - private byte[] body; - - private Optional mipOptOut = Optional.empty(); - - private Optional version = Optional.empty(); - - private Optional uttSplit = Optional.empty(); - - private Optional utterances = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional paragraphs = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional model = Optional.empty(); - - private Optional measurements = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional fillerWords = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectLanguage = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional customIntentMode = Optional.empty(); - - private Optional intents = Optional.empty(); - - private Optional customTopicMode = Optional.empty(); - - private Optional topics = Optional.empty(); - - private Optional summarize = Optional.empty(); - - private Optional sentiment = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - private Optional> search = Optional.empty(); - - private Optional> replace = Optional.empty(); - - private Optional> languageHint = Optional.empty(); - - private Optional> keywords = Optional.empty(); - - private Optional> keyterm = Optional.empty(); - - private Optional> customIntent = Optional.empty(); - - private Optional> customTopic = Optional.empty(); - - private Optional> tag = Optional.empty(); - - private Optional> extra = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MediaTranscribeRequestOctetStream other) { - extra(other.getExtra()); - tag(other.getTag()); - customTopic(other.getCustomTopic()); - customIntent(other.getCustomIntent()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - languageHint(other.getLanguageHint()); - replace(other.getReplace()); - search(other.getSearch()); - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - sentiment(other.getSentiment()); - summarize(other.getSummarize()); - topics(other.getTopics()); - customTopicMode(other.getCustomTopicMode()); - intents(other.getIntents()); - customIntentMode(other.getCustomIntentMode()); - detectEntities(other.getDetectEntities()); - detectLanguage(other.getDetectLanguage()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - fillerWords(other.getFillerWords()); - language(other.getLanguage()); - measurements(other.getMeasurements()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - paragraphs(other.getParagraphs()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - smartFormat(other.getSmartFormat()); - utterances(other.getUtterances()); - uttSplit(other.getUttSplit()); - version(other.getVersion()); - mipOptOut(other.getMipOptOut()); - body(other.getBody()); - return this; - } - - @java.lang.Override - @JsonSetter("body") - public _FinalStage body(@NotNull byte[] body) { - this.body = Objects.requireNonNull(body, "body must not be null"); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage mipOptOut(Boolean mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - /** - *

Version of an AI model to use

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage version(MediaTranscribeRequestVersion version) { - this.version = Optional.ofNullable(version); - return this; - } - - /** - *

Version of an AI model to use

- */ - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage uttSplit(Double uttSplit) { - this.uttSplit = Optional.ofNullable(uttSplit); - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) - public _FinalStage uttSplit(Optional uttSplit) { - this.uttSplit = uttSplit; - return this; - } - - /** - *

Segments speech into meaningful semantic units

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage utterances(Boolean utterances) { - this.utterances = Optional.ofNullable(utterances); - return this; - } - - /** - *

Segments speech into meaningful semantic units

- */ - @java.lang.Override - @JsonSetter(value = "utterances", nulls = Nulls.SKIP) - public _FinalStage utterances(Optional utterances) { - this.utterances = utterances; - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage smartFormat(Boolean smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage redact(String redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- */ - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- */ - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profanityFilter(Boolean profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage paragraphs(Boolean paragraphs) { - this.paragraphs = Optional.ofNullable(paragraphs); - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - @java.lang.Override - @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) - public _FinalStage paragraphs(Optional paragraphs) { - this.paragraphs = paragraphs; - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage numerals(Boolean numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- */ - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - /** - *

Transcribe each audio channel independently

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage multichannel(Boolean multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - /** - *

Transcribe each audio channel independently

- */ - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - /** - *

AI model used to process submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage model(MediaTranscribeRequestModel model) { - this.model = Optional.ofNullable(model); - return this; - } - - /** - *

AI model used to process submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public _FinalStage model(Optional model) { - this.model = model; - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage measurements(Boolean measurements) { - this.measurements = Optional.ofNullable(measurements); - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - @java.lang.Override - @JsonSetter(value = "measurements", nulls = Nulls.SKIP) - public _FinalStage measurements(Optional measurements) { - this.measurements = measurements; - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage language(String language) { - this.language = Optional.ofNullable(language); - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fillerWords(Boolean fillerWords) { - this.fillerWords = Optional.ofNullable(fillerWords); - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - @java.lang.Override - @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) - public _FinalStage fillerWords(Optional fillerWords) { - this.fillerWords = fillerWords; - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage dictation(Boolean dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(Boolean diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectLanguage(Boolean detectLanguage) { - this.detectLanguage = Optional.ofNullable(detectLanguage); - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) - public _FinalStage detectLanguage(Optional detectLanguage) { - this.detectLanguage = detectLanguage; - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectEntities(Boolean detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { - this.customIntentMode = Optional.ofNullable(customIntentMode); - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) - public _FinalStage customIntentMode(Optional customIntentMode) { - this.customIntentMode = customIntentMode; - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage intents(Boolean intents) { - this.intents = Optional.ofNullable(intents); - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "intents", nulls = Nulls.SKIP) - public _FinalStage intents(Optional intents) { - this.intents = intents; - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { - this.customTopicMode = Optional.ofNullable(customTopicMode); - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) - public _FinalStage customTopicMode(Optional customTopicMode) { - this.customTopicMode = customTopicMode; - return this; - } - - /** - *

Detect topics throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage topics(Boolean topics) { - this.topics = Optional.ofNullable(topics); - return this; - } - - /** - *

Detect topics throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "topics", nulls = Nulls.SKIP) - public _FinalStage topics(Optional topics) { - this.topics = topics; - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { - this.summarize = Optional.ofNullable(summarize); - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - @java.lang.Override - @JsonSetter(value = "summarize", nulls = Nulls.SKIP) - public _FinalStage summarize(Optional summarize) { - this.summarize = summarize; - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sentiment(Boolean sentiment) { - this.sentiment = Optional.ofNullable(sentiment); - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) - public _FinalStage sentiment(Optional sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - *

HTTP method by which the callback request will be made

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - /** - *

HTTP method by which the callback request will be made

- */ - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - /** - *

URL to which we'll make the callback request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callback(String callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - /** - *

URL to which we'll make the callback request

- */ - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public _FinalStage search(String search) { - this.search = Optional.of(Collections.singletonList(search)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage search(List search) { - this.search = Optional.ofNullable(search); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional> search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage replace(String replace) { - this.replace = Optional.of(Collections.singletonList(replace)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage replace(List replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional> replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(String languageHint) { - this.languageHint = Optional.of(Collections.singletonList(languageHint)); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageHint(List languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional> languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage keywords(String keywords) { - this.keywords = Optional.of(Collections.singletonList(keywords)); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keywords(List keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional> keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(String keyterm) { - this.keyterm = Optional.of(Collections.singletonList(keyterm)); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keyterm(List keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional> keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage customIntent(String customIntent) { - this.customIntent = Optional.of(Collections.singletonList(customIntent)); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntent(List customIntent) { - this.customIntent = Optional.ofNullable(customIntent); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) - public _FinalStage customIntent(Optional> customIntent) { - this.customIntent = customIntent; - return this; - } - - @java.lang.Override - public _FinalStage customTopic(String customTopic) { - this.customTopic = Optional.of(Collections.singletonList(customTopic)); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopic(List customTopic) { - this.customTopic = Optional.ofNullable(customTopic); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) - public _FinalStage customTopic(Optional> customTopic) { - this.customTopic = customTopic; - return this; - } - - @java.lang.Override - public _FinalStage tag(String tag) { - this.tag = Optional.of(Collections.singletonList(tag)); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tag(List tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional> tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage extra(String extra) { - this.extra = Optional.of(Collections.singletonList(extra)); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage extra(List extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional> extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public MediaTranscribeRequestOctetStream build() { - return new MediaTranscribeRequestOctetStream( - extra, - tag, - customTopic, - customIntent, - keyterm, - keywords, - languageHint, - replace, - search, - callback, - callbackMethod, - sentiment, - summarize, - topics, - customTopicMode, - intents, - customIntentMode, - detectEntities, - detectLanguage, - diarize, - diarizeModel, - dictation, - encoding, - fillerWords, - language, - measurements, - model, - multichannel, - numerals, - paragraphs, - profanityFilter, - punctuate, - redact, - smartFormat, - utterances, - uttSplit, - version, - mipOptOut, - body, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak deleted file mode 100644 index 2694721..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak +++ /dev/null @@ -1,1129 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.websocket; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.types.DiarizeModel; -import com.deepgram.types.ListenV1Callback; -import com.deepgram.types.ListenV1CallbackMethod; -import com.deepgram.types.ListenV1Channels; -import com.deepgram.types.ListenV1DetectEntities; -import com.deepgram.types.ListenV1Diarize; -import com.deepgram.types.ListenV1Dictation; -import com.deepgram.types.ListenV1Encoding; -import com.deepgram.types.ListenV1Endpointing; -import com.deepgram.types.ListenV1Extra; -import com.deepgram.types.ListenV1InterimResults; -import com.deepgram.types.ListenV1Keyterm; -import com.deepgram.types.ListenV1Keywords; -import com.deepgram.types.ListenV1Language; -import com.deepgram.types.ListenV1LanguageHint; -import com.deepgram.types.ListenV1MipOptOut; -import com.deepgram.types.ListenV1Model; -import com.deepgram.types.ListenV1Multichannel; -import com.deepgram.types.ListenV1Numerals; -import com.deepgram.types.ListenV1ProfanityFilter; -import com.deepgram.types.ListenV1Punctuate; -import com.deepgram.types.ListenV1Redact; -import com.deepgram.types.ListenV1Replace; -import com.deepgram.types.ListenV1SampleRate; -import com.deepgram.types.ListenV1Search; -import com.deepgram.types.ListenV1SmartFormat; -import com.deepgram.types.ListenV1Tag; -import com.deepgram.types.ListenV1UtteranceEndMs; -import com.deepgram.types.ListenV1VadEvents; -import com.deepgram.types.ListenV1Version; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1ConnectOptions.Builder.class) -public final class V1ConnectOptions { - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional channels; - - private final Optional detectEntities; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional endpointing; - - private final Optional extra; - - private final Optional interimResults; - - private final Optional keyterm; - - private final Optional keywords; - - private final Optional language; - - private final Optional languageHint; - - private final Optional mipOptOut; - - private final ListenV1Model model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional replace; - - private final Optional sampleRate; - - private final Optional search; - - private final Optional smartFormat; - - private final Optional tag; - - private final Optional utteranceEndMs; - - private final Optional vadEvents; - - private final Optional version; - - private final Map additionalProperties; - - private V1ConnectOptions( - Optional callback, - Optional callbackMethod, - Optional channels, - Optional detectEntities, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional endpointing, - Optional extra, - Optional interimResults, - Optional keyterm, - Optional keywords, - Optional language, - Optional languageHint, - Optional mipOptOut, - ListenV1Model model, - Optional multichannel, - Optional numerals, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional replace, - Optional sampleRate, - Optional search, - Optional smartFormat, - Optional tag, - Optional utteranceEndMs, - Optional vadEvents, - Optional version, - Map additionalProperties) { - this.callback = callback; - this.callbackMethod = callbackMethod; - this.channels = channels; - this.detectEntities = detectEntities; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.endpointing = endpointing; - this.extra = extra; - this.interimResults = interimResults; - this.keyterm = keyterm; - this.keywords = keywords; - this.language = language; - this.languageHint = languageHint; - this.mipOptOut = mipOptOut; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.replace = replace; - this.sampleRate = sampleRate; - this.search = search; - this.smartFormat = smartFormat; - this.tag = tag; - this.utteranceEndMs = utteranceEndMs; - this.vadEvents = vadEvents; - this.version = version; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("callback") - public Optional getCallback() { - return callback; - } - - @JsonProperty("callback_method") - public Optional getCallbackMethod() { - return callbackMethod; - } - - @JsonProperty("channels") - public Optional getChannels() { - return channels; - } - - @JsonProperty("detect_entities") - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonProperty("diarize") - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error. - */ - @JsonProperty("diarize_model") - public Optional getDiarizeModel() { - return diarizeModel; - } - - @JsonProperty("dictation") - public Optional getDictation() { - return dictation; - } - - @JsonProperty("encoding") - public Optional getEncoding() { - return encoding; - } - - @JsonProperty("endpointing") - public Optional getEndpointing() { - return endpointing; - } - - @JsonProperty("extra") - public Optional getExtra() { - return extra; - } - - @JsonProperty("interim_results") - public Optional getInterimResults() { - return interimResults; - } - - @JsonProperty("keyterm") - public Optional getKeyterm() { - return keyterm; - } - - @JsonProperty("keywords") - public Optional getKeywords() { - return keywords; - } - - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - @JsonProperty("language_hint") - public Optional getLanguageHint() { - return languageHint; - } - - @JsonProperty("mip_opt_out") - public Optional getMipOptOut() { - return mipOptOut; - } - - /** - * @return AI model to use for the transcription - */ - @JsonProperty("model") - public ListenV1Model getModel() { - return model; - } - - @JsonProperty("multichannel") - public Optional getMultichannel() { - return multichannel; - } - - @JsonProperty("numerals") - public Optional getNumerals() { - return numerals; - } - - @JsonProperty("profanity_filter") - public Optional getProfanityFilter() { - return profanityFilter; - } - - @JsonProperty("punctuate") - public Optional getPunctuate() { - return punctuate; - } - - @JsonProperty("redact") - public Optional getRedact() { - return redact; - } - - @JsonProperty("replace") - public Optional getReplace() { - return replace; - } - - @JsonProperty("sample_rate") - public Optional getSampleRate() { - return sampleRate; - } - - @JsonProperty("search") - public Optional getSearch() { - return search; - } - - @JsonProperty("smart_format") - public Optional getSmartFormat() { - return smartFormat; - } - - @JsonProperty("tag") - public Optional getTag() { - return tag; - } - - @JsonProperty("utterance_end_ms") - public Optional getUtteranceEndMs() { - return utteranceEndMs; - } - - @JsonProperty("vad_events") - public Optional getVadEvents() { - return vadEvents; - } - - @JsonProperty("version") - public Optional getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1ConnectOptions && equalTo((V1ConnectOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1ConnectOptions other) { - return callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && channels.equals(other.channels) - && detectEntities.equals(other.detectEntities) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && endpointing.equals(other.endpointing) - && extra.equals(other.extra) - && interimResults.equals(other.interimResults) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && language.equals(other.language) - && languageHint.equals(other.languageHint) - && mipOptOut.equals(other.mipOptOut) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && replace.equals(other.replace) - && sampleRate.equals(other.sampleRate) - && search.equals(other.search) - && smartFormat.equals(other.smartFormat) - && tag.equals(other.tag) - && utteranceEndMs.equals(other.utteranceEndMs) - && vadEvents.equals(other.vadEvents) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.callback, - this.callbackMethod, - this.channels, - this.detectEntities, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.endpointing, - this.extra, - this.interimResults, - this.keyterm, - this.keywords, - this.language, - this.languageHint, - this.mipOptOut, - this.model, - this.multichannel, - this.numerals, - this.profanityFilter, - this.punctuate, - this.redact, - this.replace, - this.sampleRate, - this.search, - this.smartFormat, - this.tag, - this.utteranceEndMs, - this.vadEvents, - this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ModelStage builder() { - return new Builder(); - } - - public interface ModelStage { - /** - *

AI model to use for the transcription

- */ - _FinalStage model(@NotNull ListenV1Model model); - - Builder from(V1ConnectOptions other); - } - - public interface _FinalStage { - V1ConnectOptions build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - _FinalStage callback(Optional callback); - - _FinalStage callback(ListenV1Callback callback); - - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod); - - _FinalStage channels(Optional channels); - - _FinalStage channels(ListenV1Channels channels); - - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(ListenV1DetectEntities detectEntities); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(ListenV1Diarize diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(DiarizeModel diarizeModel); - - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(ListenV1Dictation dictation); - - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(ListenV1Encoding encoding); - - _FinalStage endpointing(Optional endpointing); - - _FinalStage endpointing(ListenV1Endpointing endpointing); - - _FinalStage extra(Optional extra); - - _FinalStage extra(ListenV1Extra extra); - - _FinalStage interimResults(Optional interimResults); - - _FinalStage interimResults(ListenV1InterimResults interimResults); - - _FinalStage keyterm(Optional keyterm); - - _FinalStage keyterm(ListenV1Keyterm keyterm); - - _FinalStage keywords(Optional keywords); - - _FinalStage keywords(ListenV1Keywords keywords); - - _FinalStage language(Optional language); - - _FinalStage language(ListenV1Language language); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional languageHint) { - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(ListenV1LanguageHint languageHint) { - return this; - } - - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut); - - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(ListenV1Multichannel multichannel); - - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(ListenV1Numerals numerals); - - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter); - - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(ListenV1Punctuate punctuate); - - _FinalStage redact(Optional redact); - - _FinalStage redact(ListenV1Redact redact); - - _FinalStage replace(Optional replace); - - _FinalStage replace(ListenV1Replace replace); - - _FinalStage sampleRate(Optional sampleRate); - - _FinalStage sampleRate(ListenV1SampleRate sampleRate); - - _FinalStage search(Optional search); - - _FinalStage search(ListenV1Search search); - - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(ListenV1SmartFormat smartFormat); - - _FinalStage tag(Optional tag); - - _FinalStage tag(ListenV1Tag tag); - - _FinalStage utteranceEndMs(Optional utteranceEndMs); - - _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs); - - _FinalStage vadEvents(Optional vadEvents); - - _FinalStage vadEvents(ListenV1VadEvents vadEvents); - - _FinalStage version(Optional version); - - _FinalStage version(ListenV1Version version); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ModelStage, _FinalStage { - private ListenV1Model model; - - private Optional version = Optional.empty(); - - private Optional vadEvents = Optional.empty(); - - private Optional utteranceEndMs = Optional.empty(); - - private Optional tag = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional search = Optional.empty(); - - private Optional sampleRate = Optional.empty(); - - private Optional replace = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional mipOptOut = Optional.empty(); - - private Optional languageHint = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional keywords = Optional.empty(); - - private Optional keyterm = Optional.empty(); - - private Optional interimResults = Optional.empty(); - - private Optional extra = Optional.empty(); - - private Optional endpointing = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional channels = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(V1ConnectOptions other) { - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - channels(other.getChannels()); - detectEntities(other.getDetectEntities()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - endpointing(other.getEndpointing()); - extra(other.getExtra()); - interimResults(other.getInterimResults()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - language(other.getLanguage()); - languageHint(other.getLanguageHint()); - mipOptOut(other.getMipOptOut()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - replace(other.getReplace()); - sampleRate(other.getSampleRate()); - search(other.getSearch()); - smartFormat(other.getSmartFormat()); - tag(other.getTag()); - utteranceEndMs(other.getUtteranceEndMs()); - vadEvents(other.getVadEvents()); - version(other.getVersion()); - return this; - } - - /** - *

AI model to use for the transcription

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("model") - public _FinalStage model(@NotNull ListenV1Model model) { - this.model = Objects.requireNonNull(model, "model must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage version(ListenV1Version version) { - this.version = Optional.ofNullable(version); - return this; - } - - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - @java.lang.Override - public _FinalStage vadEvents(ListenV1VadEvents vadEvents) { - this.vadEvents = Optional.ofNullable(vadEvents); - return this; - } - - @java.lang.Override - @JsonSetter(value = "vad_events", nulls = Nulls.SKIP) - public _FinalStage vadEvents(Optional vadEvents) { - this.vadEvents = vadEvents; - return this; - } - - @java.lang.Override - public _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs) { - this.utteranceEndMs = Optional.ofNullable(utteranceEndMs); - return this; - } - - @java.lang.Override - @JsonSetter(value = "utterance_end_ms", nulls = Nulls.SKIP) - public _FinalStage utteranceEndMs(Optional utteranceEndMs) { - this.utteranceEndMs = utteranceEndMs; - return this; - } - - @java.lang.Override - public _FinalStage tag(ListenV1Tag tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage smartFormat(ListenV1SmartFormat smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - @java.lang.Override - public _FinalStage search(ListenV1Search search) { - this.search = Optional.ofNullable(search); - return this; - } - - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage sampleRate(ListenV1SampleRate sampleRate) { - this.sampleRate = Optional.ofNullable(sampleRate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "sample_rate", nulls = Nulls.SKIP) - public _FinalStage sampleRate(Optional sampleRate) { - this.sampleRate = sampleRate; - return this; - } - - @java.lang.Override - public _FinalStage replace(ListenV1Replace replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage redact(ListenV1Redact redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - @java.lang.Override - public _FinalStage punctuate(ListenV1Punctuate punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - @java.lang.Override - public _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - @java.lang.Override - public _FinalStage numerals(ListenV1Numerals numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - @java.lang.Override - public _FinalStage multichannel(ListenV1Multichannel multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - @java.lang.Override - public _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(ListenV1LanguageHint languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage language(ListenV1Language language) { - this.language = Optional.ofNullable(language); - return this; - } - - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - @java.lang.Override - public _FinalStage keywords(ListenV1Keywords keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(ListenV1Keyterm keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage interimResults(ListenV1InterimResults interimResults) { - this.interimResults = Optional.ofNullable(interimResults); - return this; - } - - @java.lang.Override - @JsonSetter(value = "interim_results", nulls = Nulls.SKIP) - public _FinalStage interimResults(Optional interimResults) { - this.interimResults = interimResults; - return this; - } - - @java.lang.Override - public _FinalStage extra(ListenV1Extra extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public _FinalStage endpointing(ListenV1Endpointing endpointing) { - this.endpointing = Optional.ofNullable(endpointing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "endpointing", nulls = Nulls.SKIP) - public _FinalStage endpointing(Optional endpointing) { - this.endpointing = endpointing; - return this; - } - - @java.lang.Override - public _FinalStage encoding(ListenV1Encoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - @java.lang.Override - public _FinalStage dictation(ListenV1Dictation dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(DiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(ListenV1Diarize diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - @java.lang.Override - public _FinalStage detectEntities(ListenV1DetectEntities detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - @java.lang.Override - public _FinalStage channels(ListenV1Channels channels) { - this.channels = Optional.ofNullable(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - @java.lang.Override - public _FinalStage callback(ListenV1Callback callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public V1ConnectOptions build() { - return new V1ConnectOptions( - callback, - callbackMethod, - channels, - detectEntities, - diarize, - diarizeModel, - dictation, - encoding, - endpointing, - extra, - interimResults, - keyterm, - keywords, - language, - languageHint, - mipOptOut, - model, - multichannel, - numerals, - profanityFilter, - punctuate, - redact, - replace, - sampleRate, - search, - smartFormat, - tag, - utteranceEndMs, - vadEvents, - version, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index 885f60c..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,650 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.listen.v1.types.ListenV1CloseStream; -import com.deepgram.resources.listen.v1.types.ListenV1Configure; -import com.deepgram.resources.listen.v1.types.ListenV1ConfigureFailure; -import com.deepgram.resources.listen.v1.types.ListenV1ConfigureSuccess; -import com.deepgram.resources.listen.v1.types.ListenV1Error; -import com.deepgram.resources.listen.v1.types.ListenV1Finalize; -import com.deepgram.resources.listen.v1.types.ListenV1KeepAlive; -import com.deepgram.resources.listen.v1.types.ListenV1Metadata; -import com.deepgram.resources.listen.v1.types.ListenV1Results; -import com.deepgram.resources.listen.v1.types.ListenV1SpeechStarted; -import com.deepgram.resources.listen.v1.types.ListenV1UtteranceEnd; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer resultsHandler; - - private volatile Consumer metadataHandler; - - private volatile Consumer utteranceEndHandler; - - private volatile Consumer speechStartedHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V1ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v1/listen"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - if (options.getCallback() != null && options.getCallback().isPresent()) { - urlBuilder.addQueryParameter( - "callback", String.valueOf(options.getCallback().get())); - } - if (options.getCallbackMethod() != null && options.getCallbackMethod().isPresent()) { - urlBuilder.addQueryParameter( - "callback_method", - String.valueOf(options.getCallbackMethod().get())); - } - if (options.getChannels() != null && options.getChannels().isPresent()) { - urlBuilder.addQueryParameter( - "channels", String.valueOf(options.getChannels().get())); - } - if (options.getDetectEntities() != null && options.getDetectEntities().isPresent()) { - urlBuilder.addQueryParameter( - "detect_entities", - String.valueOf(options.getDetectEntities().get())); - } - if (options.getDiarize() != null && options.getDiarize().isPresent()) { - urlBuilder.addQueryParameter( - "diarize", String.valueOf(options.getDiarize().get())); - } - if (options.getDiarizeModel() != null && options.getDiarizeModel().isPresent()) { - urlBuilder.addQueryParameter( - "diarize_model", String.valueOf(options.getDiarizeModel().get())); - } - if (options.getDictation() != null && options.getDictation().isPresent()) { - urlBuilder.addQueryParameter( - "dictation", String.valueOf(options.getDictation().get())); - } - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getEndpointing() != null && options.getEndpointing().isPresent()) { - urlBuilder.addQueryParameter( - "endpointing", String.valueOf(options.getEndpointing().get())); - } - if (options.getExtra() != null && options.getExtra().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); - } - if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { - urlBuilder.addQueryParameter( - "interim_results", - String.valueOf(options.getInterimResults().get())); - } - if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); - } - if (options.getKeywords() != null && options.getKeywords().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); - } - if (options.getLanguage() != null && options.getLanguage().isPresent()) { - urlBuilder.addQueryParameter( - "language", String.valueOf(options.getLanguage().get())); - } - if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getMultichannel() != null && options.getMultichannel().isPresent()) { - urlBuilder.addQueryParameter( - "multichannel", String.valueOf(options.getMultichannel().get())); - } - if (options.getNumerals() != null && options.getNumerals().isPresent()) { - urlBuilder.addQueryParameter( - "numerals", String.valueOf(options.getNumerals().get())); - } - if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { - urlBuilder.addQueryParameter( - "profanity_filter", - String.valueOf(options.getProfanityFilter().get())); - } - if (options.getPunctuate() != null && options.getPunctuate().isPresent()) { - urlBuilder.addQueryParameter( - "punctuate", String.valueOf(options.getPunctuate().get())); - } - if (options.getRedact() != null && options.getRedact().isPresent()) { - urlBuilder.addQueryParameter( - "redact", String.valueOf(options.getRedact().get())); - } - if (options.getReplace() != null && options.getReplace().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSearch() != null && options.getSearch().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); - } - if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { - urlBuilder.addQueryParameter( - "smart_format", String.valueOf(options.getSmartFormat().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { - urlBuilder.addQueryParameter( - "utterance_end_ms", - String.valueOf(options.getUtteranceEndMs().get())); - } - if (options.getVadEvents() != null && options.getVadEvents().isPresent()) { - urlBuilder.addQueryParameter( - "vad_events", String.valueOf(options.getVadEvents().get())); - } - if (options.getVersion() != null && options.getVersion().isPresent()) { - urlBuilder.addQueryParameter( - "version", String.valueOf(options.getVersion().get())); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a ListenV1Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Sends a ListenV1Finalize message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFinalize(ListenV1Finalize message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1CloseStream message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCloseStream(ListenV1CloseStream message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1KeepAlive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendKeepAlive(ListenV1KeepAlive message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(ListenV1Configure message) { - return sendMessage(message); - } - - /** - * Registers a handler for ListenV1ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for ListenV1ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for ListenV1Results messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onResults(Consumer handler) { - this.resultsHandler = handler; - } - - /** - * Registers a handler for ListenV1Metadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onMetadata(Consumer handler) { - this.metadataHandler = handler; - } - - /** - * Registers a handler for ListenV1UtteranceEnd messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onUtteranceEnd(Consumer handler) { - this.utteranceEndHandler = handler; - } - - /** - * Registers a handler for ListenV1SpeechStarted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechStarted(Consumer handler) { - this.speechStartedHandler = handler; - } - - /** - * Registers a handler for ListenV1Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("transaction_key") - && node.has("request_id") - && node.has("sha256") - && node.has("created") - && node.has("duration") - && node.has("channels") - && "Metadata".equals(node.path("type").asText())) { - ListenV1Metadata metadataHandlerEvent = null; - try { - metadataHandlerEvent = objectMapper.treeToValue(node, ListenV1Metadata.class); - } catch (Exception e) { - } - if (metadataHandlerEvent != null) { - if (metadataHandler != null) { - metadataHandler.accept(metadataHandlerEvent); - } - return; - } - } - if (node.has("channel_index") - && node.has("duration") - && node.has("start") - && node.has("channel") - && node.has("metadata") - && "Results".equals(node.path("type").asText())) { - ListenV1Results resultsHandlerEvent = null; - try { - resultsHandlerEvent = objectMapper.treeToValue(node, ListenV1Results.class); - } catch (Exception e) { - } - if (resultsHandlerEvent != null) { - if (resultsHandler != null) { - resultsHandler.accept(resultsHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("code") - && node.has("description") - && "ConfigureFailure".equals(node.path("type").asText())) { - ListenV1ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); - } - return; - } - } - if (node.has("channel") - && node.has("last_word_end") - && "UtteranceEnd".equals(node.path("type").asText())) { - ListenV1UtteranceEnd utteranceEndHandlerEvent = null; - try { - utteranceEndHandlerEvent = objectMapper.treeToValue(node, ListenV1UtteranceEnd.class); - } catch (Exception e) { - } - if (utteranceEndHandlerEvent != null) { - if (utteranceEndHandler != null) { - utteranceEndHandler.accept(utteranceEndHandlerEvent); - } - return; - } - } - if (node.has("channel") - && node.has("timestamp") - && "SpeechStarted".equals(node.path("type").asText())) { - ListenV1SpeechStarted speechStartedHandlerEvent = null; - try { - speechStartedHandlerEvent = objectMapper.treeToValue(node, ListenV1SpeechStarted.class); - } catch (Exception e) { - } - if (speechStartedHandlerEvent != null) { - if (speechStartedHandler != null) { - speechStartedHandler.accept(speechStartedHandlerEvent); - } - return; - } - } - if (node.has("variant") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - ListenV1Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, ListenV1Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); - } - return; - } - } - if (node.has("request_id") - && "ConfigureSuccess".equals(node.path("type").asText())) { - ListenV1ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak deleted file mode 100644 index c9f2f35..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV2CloseStream.Builder.class) -public final class ListenV2CloseStream { - private final Map additionalProperties; - - private ListenV2CloseStream(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "CloseStream"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV2CloseStream; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListenV2CloseStream other) { - return this; - } - - public ListenV2CloseStream build() { - return new ListenV2CloseStream(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak deleted file mode 100644 index 894bd3c..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV2ForceEndTurn.Builder.class) -public final class ListenV2ForceEndTurn { - private final Map additionalProperties; - - private ListenV2ForceEndTurn(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "ForceEndTurn"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV2ForceEndTurn; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListenV2ForceEndTurn other) { - return this; - } - - public ListenV2ForceEndTurn build() { - return new ListenV2ForceEndTurn(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak deleted file mode 100644 index 5f55fea..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak +++ /dev/null @@ -1,563 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.listen.v2.types.ListenV2CloseStream; -import com.deepgram.resources.listen.v2.types.ListenV2Configure; -import com.deepgram.resources.listen.v2.types.ListenV2ConfigureFailure; -import com.deepgram.resources.listen.v2.types.ListenV2ConfigureSuccess; -import com.deepgram.resources.listen.v2.types.ListenV2Connected; -import com.deepgram.resources.listen.v2.types.ListenV2FatalError; -import com.deepgram.resources.listen.v2.types.ListenV2ForceEndTurn; -import com.deepgram.resources.listen.v2.types.ListenV2TurnInfo; -import com.deepgram.resources.listen.v2.types.ListenV2Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v2 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V2WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private final AtomicReference closeStreamSocket = new AtomicReference<>(); - - private volatile Consumer connectedHandler; - - private volatile Consumer turnInfoHandler; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v2 channel. - */ - public V2WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V2ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - closeStreamSocket.set(null); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v2/listen"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getEagerEotThreshold() != null - && options.getEagerEotThreshold().isPresent()) { - urlBuilder.addQueryParameter( - "eager_eot_threshold", - String.valueOf(options.getEagerEotThreshold().get())); - } - if (options.getEotThreshold() != null && options.getEotThreshold().isPresent()) { - urlBuilder.addQueryParameter( - "eot_threshold", String.valueOf(options.getEotThreshold().get())); - } - if (options.getEotTimeoutMs() != null && options.getEotTimeoutMs().isPresent()) { - urlBuilder.addQueryParameter( - "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); - } - if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "keyterm", options.getKeyterm().get().get(), true); - } - if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); - } - if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { - urlBuilder.addQueryParameter( - "profanity_filter", - String.valueOf(options.getProfanityFilter().get())); - } - if (options.getNumerals() != null && options.getNumerals().isPresent()) { - urlBuilder.addQueryParameter( - "numerals", String.valueOf(options.getNumerals().get())); - } - if (options.getRedact() != null && options.getRedact().isPresent()) { - urlBuilder.addQueryParameter( - "redact", String.valueOf(options.getRedact().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - closeStreamSocket.set(null); - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - - @Override - protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { - return super.shouldReconnectAfterClose(webSocket, code, reason) - && (code != 1005 || closeStreamSocket.get() != webSocket); - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a ListenV2Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does - * not suppress reconnects because it might never reach the server. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCloseStream(ListenV2CloseStream message) { - return sendMessage(message, closeStreamSocket::set); - } - - /** - * Sends a ListenV2ForceEndTurn message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendForceEndTurn(ListenV2ForceEndTurn message) { - return sendMessage(message); - } - - /** - * Sends a ListenV2Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(ListenV2Configure message) { - return sendMessage(message); - } - - /** - * Registers a handler for ListenV2Connected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConnected(Consumer handler) { - this.connectedHandler = handler; - } - - /** - * Registers a handler for ListenV2TurnInfo messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onTurnInfo(Consumer handler) { - this.turnInfoHandler = handler; - } - - /** - * Registers a handler for ListenV2ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for ListenV2ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for ListenV2Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for ListenV2FatalError messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - return sendMessage(body, null); - } - - private CompletableFuture sendMessage(Object body, Consumer onSent) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json, onSent); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("request_id") - && node.has("sequence_id") - && node.has("event") - && node.has("turn_index") - && node.has("audio_window_start") - && node.has("audio_window_end") - && node.has("transcript") - && node.has("words") - && node.has("end_of_turn_confidence") - && "TurnInfo".equals(node.path("type").asText())) { - ListenV2TurnInfo turnInfoHandlerEvent = null; - try { - turnInfoHandlerEvent = objectMapper.treeToValue(node, ListenV2TurnInfo.class); - } catch (Exception e) { - } - if (turnInfoHandlerEvent != null) { - if (turnInfoHandler != null) { - turnInfoHandler.accept(turnInfoHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("thresholds") - && node.has("keyterms") - && node.has("sequence_id") - && "ConfigureSuccess".equals(node.path("type").asText())) { - ListenV2ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && node.has("code") - && node.has("description") - && "Warning".equals(node.path("type").asText())) { - ListenV2Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, ListenV2Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("sequence_id") - && node.has("code") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - ListenV2FatalError errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, ListenV2FatalError.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && "Connected".equals(node.path("type").asText())) { - ListenV2Connected connectedHandlerEvent = null; - try { - connectedHandlerEvent = objectMapper.treeToValue(node, ListenV2Connected.class); - } catch (Exception e) { - } - if (connectedHandlerEvent != null) { - if (connectedHandler != null) { - connectedHandler.accept(connectedHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && "ConfigureFailure".equals(node.path("type").asText())) { - ListenV2ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } - return; - } - } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index e6824a3..0000000 --- a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,467 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.speak.v1.types.SpeakV1Clear; -import com.deepgram.resources.speak.v1.types.SpeakV1Cleared; -import com.deepgram.resources.speak.v1.types.SpeakV1Close; -import com.deepgram.resources.speak.v1.types.SpeakV1Flush; -import com.deepgram.resources.speak.v1.types.SpeakV1Flushed; -import com.deepgram.resources.speak.v1.types.SpeakV1Metadata; -import com.deepgram.resources.speak.v1.types.SpeakV1Text; -import com.deepgram.resources.speak.v1.types.SpeakV1Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer speakV1AudioHandler; - - private volatile Consumer metadataHandler; - - private volatile Consumer flushedHandler; - - private volatile Consumer clearedHandler; - - private volatile Consumer warningHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V1ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v1/speak"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getModel() != null && options.getModel().isPresent()) { - urlBuilder.addQueryParameter( - "model", String.valueOf(options.getModel().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSpeed() != null && options.getSpeed().isPresent()) { - urlBuilder.addQueryParameter( - "speed", String.valueOf(options.getSpeed().get())); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (speakV1AudioHandler != null) { - speakV1AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Establishes the WebSocket connection asynchronously with default options. - * @return a CompletableFuture that completes when the connection is established - */ - public CompletableFuture connect() { - return connect(V1ConnectOptions.builder().build()); - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a SpeakV1Text message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendText(SpeakV1Text message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Flush message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFlush(SpeakV1Flush message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Clear message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClear(SpeakV1Clear message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Close message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClose(SpeakV1Close message) { - return sendMessage(message); - } - - /** - * Registers a handler for SpeakV1Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakV1Audio(Consumer handler) { - this.speakV1AudioHandler = handler; - } - - /** - * Registers a handler for SpeakV1Metadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onMetadata(Consumer handler) { - this.metadataHandler = handler; - } - - /** - * Registers a handler for SpeakV1Flushed messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFlushed(Consumer handler) { - this.flushedHandler = handler; - } - - /** - * Registers a handler for SpeakV1Cleared messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onCleared(Consumer handler) { - this.clearedHandler = handler; - } - - /** - * Registers a handler for SpeakV1Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("request_id") - && node.has("model_name") - && node.has("model_version") - && node.has("model_uuid") - && "Metadata".equals(node.path("type").asText())) { - SpeakV1Metadata metadataHandlerEvent = null; - try { - metadataHandlerEvent = objectMapper.treeToValue(node, SpeakV1Metadata.class); - } catch (Exception e) { - } - if (metadataHandlerEvent != null) { - if (metadataHandler != null) { - metadataHandler.accept(metadataHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Warning".equals(node.path("type").asText())) { - SpeakV1Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, SpeakV1Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("type") && node.has("sequence_id")) { - SpeakV1Flushed flushedHandlerEvent = null; - try { - flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Flushed.class); - } catch (Exception e) { - } - if (flushedHandlerEvent != null) { - if (flushedHandler != null) { - flushedHandler.accept(flushedHandlerEvent); - } - return; - } - } - if (node.has("type") && node.has("sequence_id")) { - SpeakV1Cleared clearedHandlerEvent = null; - try { - clearedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Cleared.class); - } catch (Exception e) { - } - if (clearedHandlerEvent != null) { - if (clearedHandler != null) { - clearedHandler.accept(clearedHandlerEvent); - } - return; - } - } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak deleted file mode 100644 index 7fecd79..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SpeakV2Close.Builder.class) -public final class SpeakV2Close { - private final Map additionalProperties; - - private SpeakV2Close(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "Close"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SpeakV2Close; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SpeakV2Close other) { - return this; - } - - public SpeakV2Close build() { - return new SpeakV2Close(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak deleted file mode 100644 index f678e97..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class SpeakV2ConfigureFailureCode { - public static final SpeakV2ConfigureFailureCode CONTROL_COMBINATION_INVALID = - new SpeakV2ConfigureFailureCode(Value.CONTROL_COMBINATION_INVALID, "CONTROL_COMBINATION_INVALID"); - - public static final SpeakV2ConfigureFailureCode SPEED_OUT_OF_RANGE = - new SpeakV2ConfigureFailureCode(Value.SPEED_OUT_OF_RANGE, "SPEED_OUT_OF_RANGE"); - - public static final SpeakV2ConfigureFailureCode SPEED_INCREMENT_INVALID = - new SpeakV2ConfigureFailureCode(Value.SPEED_INCREMENT_INVALID, "SPEED_INCREMENT_INVALID"); - - public static final SpeakV2ConfigureFailureCode INTERNAL_ERROR = - new SpeakV2ConfigureFailureCode(Value.INTERNAL_ERROR, "INTERNAL_ERROR"); - - public static final SpeakV2ConfigureFailureCode SPEED_NOT_SUPPORTED = - new SpeakV2ConfigureFailureCode(Value.SPEED_NOT_SUPPORTED, "SPEED_NOT_SUPPORTED"); - - private final Value value; - - private final String string; - - SpeakV2ConfigureFailureCode(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof SpeakV2ConfigureFailureCode - && this.string.equals(((SpeakV2ConfigureFailureCode) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case CONTROL_COMBINATION_INVALID: - return visitor.visitControlCombinationInvalid(); - case SPEED_OUT_OF_RANGE: - return visitor.visitSpeedOutOfRange(); - case SPEED_INCREMENT_INVALID: - return visitor.visitSpeedIncrementInvalid(); - case INTERNAL_ERROR: - return visitor.visitInternalError(); - case SPEED_NOT_SUPPORTED: - return visitor.visitSpeedNotSupported(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static SpeakV2ConfigureFailureCode valueOf(String value) { - switch (value) { - case "CONTROL_COMBINATION_INVALID": - return CONTROL_COMBINATION_INVALID; - case "SPEED_OUT_OF_RANGE": - return SPEED_OUT_OF_RANGE; - case "SPEED_INCREMENT_INVALID": - return SPEED_INCREMENT_INVALID; - case "INTERNAL_ERROR": - return INTERNAL_ERROR; - case "SPEED_NOT_SUPPORTED": - return SPEED_NOT_SUPPORTED; - default: - return new SpeakV2ConfigureFailureCode(Value.UNKNOWN, value); - } - } - - public enum Value { - SPEED_OUT_OF_RANGE, - - SPEED_INCREMENT_INVALID, - - SPEED_NOT_SUPPORTED, - - CONTROL_COMBINATION_INVALID, - - INTERNAL_ERROR, - - UNKNOWN - } - - public interface Visitor { - T visitSpeedOutOfRange(); - - T visitSpeedIncrementInvalid(); - - T visitSpeedNotSupported(); - - default T visitControlCombinationInvalid() { - return visitUnknown("CONTROL_COMBINATION_INVALID"); - } - - T visitInternalError(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak deleted file mode 100644 index 130da0d..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SpeakV2Flush.Builder.class) -public final class SpeakV2Flush { - private final Map additionalProperties; - - private SpeakV2Flush(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "Flush"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SpeakV2Flush; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SpeakV2Flush other) { - return this; - } - - public SpeakV2Flush build() { - return new SpeakV2Flush(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak deleted file mode 100644 index b4e01f7..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak +++ /dev/null @@ -1,630 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.speak.v2.types.SpeakV2Close; -import com.deepgram.resources.speak.v2.types.SpeakV2Configure; -import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureFailure; -import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureSuccess; -import com.deepgram.resources.speak.v2.types.SpeakV2Connected; -import com.deepgram.resources.speak.v2.types.SpeakV2Error; -import com.deepgram.resources.speak.v2.types.SpeakV2Flush; -import com.deepgram.resources.speak.v2.types.SpeakV2Flushed; -import com.deepgram.resources.speak.v2.types.SpeakV2Interrupt; -import com.deepgram.resources.speak.v2.types.SpeakV2SessionMetadata; -import com.deepgram.resources.speak.v2.types.SpeakV2Speak; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechInterrupted; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechMetadata; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechStarted; -import com.deepgram.resources.speak.v2.types.SpeakV2Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v2 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V2WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer speakV2AudioHandler; - - private volatile Consumer connectedHandler; - - private volatile Consumer speechStartedHandler; - - private volatile Consumer speechMetadataHandler; - - private volatile Consumer speechInterruptedHandler; - - private volatile Consumer flushedHandler; - - private volatile Consumer sessionMetadataHandler; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v2 channel. - */ - public V2WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V2ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v2/speak"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSpeed() != null && options.getSpeed().isPresent()) { - urlBuilder.addQueryParameter( - "speed", String.valueOf(options.getSpeed().get())); - } - if (options.getExpressivity() != null && options.getExpressivity().isPresent()) { - urlBuilder.addQueryParameter( - "expressivity", String.valueOf(options.getExpressivity().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (speakV2AudioHandler != null) { - speakV2AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a SpeakV2Speak message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendSpeak(SpeakV2Speak message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Flush message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFlush(SpeakV2Flush message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Interrupt message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInterrupt(SpeakV2Interrupt message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(SpeakV2Configure message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Close message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClose(SpeakV2Close message) { - return sendMessage(message); - } - - /** - * Registers a handler for SpeakV2Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakV2Audio(Consumer handler) { - this.speakV2AudioHandler = handler; - } - - /** - * Registers a handler for SpeakV2Connected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConnected(Consumer handler) { - this.connectedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechStarted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechStarted(Consumer handler) { - this.speechStartedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechMetadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechMetadata(Consumer handler) { - this.speechMetadataHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechInterrupted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechInterrupted(Consumer handler) { - this.speechInterruptedHandler = handler; - } - - /** - * Registers a handler for SpeakV2Flushed messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFlushed(Consumer handler) { - this.flushedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SessionMetadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSessionMetadata(Consumer handler) { - this.sessionMetadataHandler = handler; - } - - /** - * Registers a handler for SpeakV2ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for SpeakV2ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for SpeakV2Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for SpeakV2Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("speech_id") - && node.has("audio_duration_ms") - && node.has("input_character_count") - && node.has("billable_character_count") - && node.has("controls_applied") - && "SpeechMetadata".equals(node.path("type").asText())) { - SpeakV2SpeechMetadata speechMetadataHandlerEvent = null; - try { - speechMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechMetadata.class); - } catch (Exception e) { - } - if (speechMetadataHandlerEvent != null) { - if (speechMetadataHandler != null) { - speechMetadataHandler.accept(speechMetadataHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("model_name") - && node.has("model_version") - && node.has("model_uuids") - && "Connected".equals(node.path("type").asText())) { - SpeakV2Connected connectedHandlerEvent = null; - try { - connectedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Connected.class); - } catch (Exception e) { - } - if (connectedHandlerEvent != null) { - if (connectedHandler != null) { - connectedHandler.accept(connectedHandlerEvent); - } - return; - } - } - if (node.has("total_audio_duration_ms") - && node.has("total_input_character_count") - && node.has("total_billable_character_count") - && "SessionMetadata".equals(node.path("type").asText())) { - SpeakV2SessionMetadata sessionMetadataHandlerEvent = null; - try { - sessionMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SessionMetadata.class); - } catch (Exception e) { - } - if (sessionMetadataHandlerEvent != null) { - if (sessionMetadataHandler != null) { - sessionMetadataHandler.accept(sessionMetadataHandlerEvent); - } - return; - } - } - if (node.has("audio_played_ms") - && node.has("metadata") - && "SpeechInterrupted".equals(node.path("type").asText())) { - SpeakV2SpeechInterrupted speechInterruptedHandlerEvent = null; - try { - speechInterruptedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechInterrupted.class); - } catch (Exception e) { - } - if (speechInterruptedHandlerEvent != null) { - if (speechInterruptedHandler != null) { - speechInterruptedHandler.accept(speechInterruptedHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "ConfigureFailure".equals(node.path("type").asText())) { - SpeakV2ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "Warning".equals(node.path("type").asText())) { - SpeakV2Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, SpeakV2Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - SpeakV2Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, SpeakV2Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("speech_id") - && "SpeechStarted".equals(node.path("type").asText())) { - SpeakV2SpeechStarted speechStartedHandlerEvent = null; - try { - speechStartedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechStarted.class); - } catch (Exception e) { - } - if (speechStartedHandlerEvent != null) { - if (speechStartedHandler != null) { - speechStartedHandler.accept(speechStartedHandlerEvent); - } - return; - } - } - if (node.has("speech_id") && "Flushed".equals(node.path("type").asText())) { - SpeakV2Flushed flushedHandlerEvent = null; - try { - flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Flushed.class); - } catch (Exception e) { - } - if (flushedHandlerEvent != null) { - if (flushedHandler != null) { - flushedHandler.accept(flushedHandlerEvent); - } - return; - } - } - if (node.has("applied") - && "ConfigureSuccess".equals(node.path("type").asText())) { - SpeakV2ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java.bak b/src/main/java/com/deepgram/types/DeepgramModel.java.bak deleted file mode 100644 index 9fa2f8b..0000000 --- a/src/main/java/com/deepgram/types/DeepgramModel.java.bak +++ /dev/null @@ -1,1081 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class DeepgramModel { - public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); - - public static final DeepgramModel AURA2HERA_EN = new DeepgramModel(Value.AURA2HERA_EN, "aura-2-hera-en"); - - public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); - - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); - - public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); - - public static final DeepgramModel AURA2HARMONIA_EN = - new DeepgramModel(Value.AURA2HARMONIA_EN, "aura-2-harmonia-en"); - - public static final DeepgramModel AURA2CARINA_ES = new DeepgramModel(Value.AURA2CARINA_ES, "aura-2-carina-es"); - - public static final DeepgramModel FLUX_MEENA_EN = new DeepgramModel(Value.FLUX_MEENA_EN, "flux-meena-en"); - - public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); - - public static final DeepgramModel AURA_ZEUS_EN = new DeepgramModel(Value.AURA_ZEUS_EN, "aura-zeus-en"); - - public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); - - public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); - - public static final DeepgramModel AURA2NEPTUNE_EN = new DeepgramModel(Value.AURA2NEPTUNE_EN, "aura-2-neptune-en"); - - public static final DeepgramModel FLUX_BROOKE_EN = new DeepgramModel(Value.FLUX_BROOKE_EN, "flux-brooke-en"); - - public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); - - public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); - - public static final DeepgramModel AURA2CALLISTA_EN = - new DeepgramModel(Value.AURA2CALLISTA_EN, "aura-2-callista-en"); - - public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); - - public static final DeepgramModel AURA2OPHELIA_EN = new DeepgramModel(Value.AURA2OPHELIA_EN, "aura-2-ophelia-en"); - - public static final DeepgramModel FLUX_BRUCE_EN = new DeepgramModel(Value.FLUX_BRUCE_EN, "flux-bruce-en"); - - public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); - - public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); - - public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); - - public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); - - public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); - - public static final DeepgramModel FLUX_MARCUS_EN = new DeepgramModel(Value.FLUX_MARCUS_EN, "flux-marcus-en"); - - public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); - - public static final DeepgramModel FLUX_PAIGE_EN = new DeepgramModel(Value.FLUX_PAIGE_EN, "flux-paige-en"); - - public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); - - public static final DeepgramModel FLUX_DREW_EN = new DeepgramModel(Value.FLUX_DREW_EN, "flux-drew-en"); - - public static final DeepgramModel AURA2JAVIER_ES = new DeepgramModel(Value.AURA2JAVIER_ES, "aura-2-javier-es"); - - public static final DeepgramModel AURA2ANDROMEDA_EN = - new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); - - public static final DeepgramModel AURA2SATURN_EN = new DeepgramModel(Value.AURA2SATURN_EN, "aura-2-saturn-en"); - - public static final DeepgramModel AURA2IRIS_EN = new DeepgramModel(Value.AURA2IRIS_EN, "aura-2-iris-en"); - - public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); - - public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); - - public static final DeepgramModel FLUX_BRITTANY_EN = new DeepgramModel(Value.FLUX_BRITTANY_EN, "flux-brittany-en"); - - public static final DeepgramModel FLUX_SEAN_EN = new DeepgramModel(Value.FLUX_SEAN_EN, "flux-sean-en"); - - public static final DeepgramModel AURA2HELENA_EN = new DeepgramModel(Value.AURA2HELENA_EN, "aura-2-helena-en"); - - public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); - - public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); - - public static final DeepgramModel FLUX_JACK_EN = new DeepgramModel(Value.FLUX_JACK_EN, "flux-jack-en"); - - public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); - - public static final DeepgramModel FLUX_PRIYA_EN = new DeepgramModel(Value.FLUX_PRIYA_EN, "flux-priya-en"); - - public static final DeepgramModel AURA_HELIOS_EN = new DeepgramModel(Value.AURA_HELIOS_EN, "aura-helios-en"); - - public static final DeepgramModel AURA2JANUS_EN = new DeepgramModel(Value.AURA2JANUS_EN, "aura-2-janus-en"); - - public static final DeepgramModel AURA2NESTOR_ES = new DeepgramModel(Value.AURA2NESTOR_ES, "aura-2-nestor-es"); - - public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); - - public static final DeepgramModel AURA2MINERVA_EN = new DeepgramModel(Value.AURA2MINERVA_EN, "aura-2-minerva-en"); - - public static final DeepgramModel AURA2ALVARO_ES = new DeepgramModel(Value.AURA2ALVARO_ES, "aura-2-alvaro-es"); - - public static final DeepgramModel AURA_PERSEUS_EN = new DeepgramModel(Value.AURA_PERSEUS_EN, "aura-perseus-en"); - - public static final DeepgramModel AURA2VESTA_EN = new DeepgramModel(Value.AURA2VESTA_EN, "aura-2-vesta-en"); - - public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); - - public static final DeepgramModel AURA2ZEUS_EN = new DeepgramModel(Value.AURA2ZEUS_EN, "aura-2-zeus-en"); - - public static final DeepgramModel AURA2ORPHEUS_EN = new DeepgramModel(Value.AURA2ORPHEUS_EN, "aura-2-orpheus-en"); - - public static final DeepgramModel AURA2THALIA_EN = new DeepgramModel(Value.AURA2THALIA_EN, "aura-2-thalia-en"); - - public static final DeepgramModel FLUX_NAVEEN_EN = new DeepgramModel(Value.FLUX_NAVEEN_EN, "flux-naveen-en"); - - public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); - - public static final DeepgramModel AURA2SELENA_ES = new DeepgramModel(Value.AURA2SELENA_ES, "aura-2-selena-es"); - - public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); - - public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); - - public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); - - public static final DeepgramModel AURA_LUNA_EN = new DeepgramModel(Value.AURA_LUNA_EN, "aura-luna-en"); - - public static final DeepgramModel AURA_ORPHEUS_EN = new DeepgramModel(Value.AURA_ORPHEUS_EN, "aura-orpheus-en"); - - public static final DeepgramModel AURA2AMALTHEA_EN = - new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); - - public static final DeepgramModel FLUX_DONOVAN_EN = new DeepgramModel(Value.FLUX_DONOVAN_EN, "flux-donovan-en"); - - public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); - - public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); - - public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); - - public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); - - public static final DeepgramModel AURA2PHOEBE_EN = new DeepgramModel(Value.AURA2PHOEBE_EN, "aura-2-phoebe-en"); - - public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); - - public static final DeepgramModel AURA2DIANA_ES = new DeepgramModel(Value.AURA2DIANA_ES, "aura-2-diana-es"); - - public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); - - public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); - - public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); - - public static final DeepgramModel AURA2THEIA_EN = new DeepgramModel(Value.AURA2THEIA_EN, "aura-2-theia-en"); - - public static final DeepgramModel FLUX_WADE_EN = new DeepgramModel(Value.FLUX_WADE_EN, "flux-wade-en"); - - public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); - - public static final DeepgramModel FLUX_CLIFF_EN = new DeepgramModel(Value.FLUX_CLIFF_EN, "flux-cliff-en"); - - public static final DeepgramModel AURA2JUPITER_EN = new DeepgramModel(Value.AURA2JUPITER_EN, "aura-2-jupiter-en"); - - public static final DeepgramModel FLUX_KIT_EN = new DeepgramModel(Value.FLUX_KIT_EN, "flux-kit-en"); - - public static final DeepgramModel AURA2AQUILA_ES = new DeepgramModel(Value.AURA2AQUILA_ES, "aura-2-aquila-es"); - - public static final DeepgramModel AURA2CORA_EN = new DeepgramModel(Value.AURA2CORA_EN, "aura-2-cora-en"); - - public static final DeepgramModel AURA2CORDELIA_EN = - new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); - - public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); - - public static final DeepgramModel AURA2HYPERION_EN = - new DeepgramModel(Value.AURA2HYPERION_EN, "aura-2-hyperion-en"); - - public static final DeepgramModel AURA2CELESTE_ES = new DeepgramModel(Value.AURA2CELESTE_ES, "aura-2-celeste-es"); - - public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); - - public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); - - public static final DeepgramModel AURA2ARCAS_EN = new DeepgramModel(Value.AURA2ARCAS_EN, "aura-2-arcas-en"); - - public static final DeepgramModel FLUX_COLIN_EN = new DeepgramModel(Value.FLUX_COLIN_EN, "flux-colin-en"); - - public static final DeepgramModel AURA_ATHENA_EN = new DeepgramModel(Value.AURA_ATHENA_EN, "aura-athena-en"); - - public static final DeepgramModel AURA2ODYSSEUS_EN = - new DeepgramModel(Value.AURA2ODYSSEUS_EN, "aura-2-odysseus-en"); - - public static final DeepgramModel AURA2PANDORA_EN = new DeepgramModel(Value.AURA2PANDORA_EN, "aura-2-pandora-en"); - - public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); - - public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); - - public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); - - public static final DeepgramModel FLUX_GEMMA_EN = new DeepgramModel(Value.FLUX_GEMMA_EN, "flux-gemma-en"); - - public static final DeepgramModel AURA2ESTRELLA_ES = - new DeepgramModel(Value.AURA2ESTRELLA_ES, "aura-2-estrella-es"); - - private final Value value; - - private final String string; - - DeepgramModel(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof DeepgramModel && this.string.equals(((DeepgramModel) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case AURA2SIRIO_ES: - return visitor.visitAura2SirioEs(); - case AURA2HERA_EN: - return visitor.visitAura2HeraEn(); - case FLUX_KELSEY_EN: - return visitor.visitFluxKelseyEn(); - case FLUX_RENEE_EN: - return visitor.visitFluxReneeEn(); - case FLUX_SIENNA_EN: - return visitor.visitFluxSiennaEn(); - case AURA2HARMONIA_EN: - return visitor.visitAura2HarmoniaEn(); - case AURA2CARINA_ES: - return visitor.visitAura2CarinaEs(); - case FLUX_MEENA_EN: - return visitor.visitFluxMeenaEn(); - case FLUX_MEGHAN_EN: - return visitor.visitFluxMeghanEn(); - case AURA_ZEUS_EN: - return visitor.visitAuraZeusEn(); - case AURA2HERMES_EN: - return visitor.visitAura2HermesEn(); - case FLUX_CONOR_EN: - return visitor.visitFluxConorEn(); - case AURA2NEPTUNE_EN: - return visitor.visitAura2NeptuneEn(); - case FLUX_BROOKE_EN: - return visitor.visitFluxBrookeEn(); - case FLUX_RUFUS_EN: - return visitor.visitFluxRufusEn(); - case FLUX_WES_EN: - return visitor.visitFluxWesEn(); - case AURA2CALLISTA_EN: - return visitor.visitAura2CallistaEn(); - case AURA2AURORA_EN: - return visitor.visitAura2AuroraEn(); - case AURA2OPHELIA_EN: - return visitor.visitAura2OpheliaEn(); - case FLUX_BRUCE_EN: - return visitor.visitFluxBruceEn(); - case AURA2APOLLO_EN: - return visitor.visitAura2ApolloEn(); - case AURA2DELIA_EN: - return visitor.visitAura2DeliaEn(); - case AURA2MARS_EN: - return visitor.visitAura2MarsEn(); - case AURA_HERA_EN: - return visitor.visitAuraHeraEn(); - case FLUX_MAEVE_EN: - return visitor.visitFluxMaeveEn(); - case FLUX_MARCUS_EN: - return visitor.visitFluxMarcusEn(); - case AURA2ARIES_EN: - return visitor.visitAura2AriesEn(); - case FLUX_PAIGE_EN: - return visitor.visitFluxPaigeEn(); - case AURA2JUNO_EN: - return visitor.visitAura2JunoEn(); - case FLUX_DREW_EN: - return visitor.visitFluxDrewEn(); - case AURA2JAVIER_ES: - return visitor.visitAura2JavierEs(); - case AURA2ANDROMEDA_EN: - return visitor.visitAura2AndromedaEn(); - case AURA2SATURN_EN: - return visitor.visitAura2SaturnEn(); - case AURA2IRIS_EN: - return visitor.visitAura2IrisEn(); - case AURA_ANGUS_EN: - return visitor.visitAuraAngusEn(); - case FLUX_KAI_EN: - return visitor.visitFluxKaiEn(); - case FLUX_BRITTANY_EN: - return visitor.visitFluxBrittanyEn(); - case FLUX_SEAN_EN: - return visitor.visitFluxSeanEn(); - case AURA2HELENA_EN: - return visitor.visitAura2HelenaEn(); - case FLUX_HALEY_EN: - return visitor.visitFluxHaleyEn(); - case AURA_STELLA_EN: - return visitor.visitAuraStellaEn(); - case FLUX_JACK_EN: - return visitor.visitFluxJackEn(); - case AURA2DRACO_EN: - return visitor.visitAura2DracoEn(); - case FLUX_PRIYA_EN: - return visitor.visitFluxPriyaEn(); - case AURA_HELIOS_EN: - return visitor.visitAuraHeliosEn(); - case AURA2JANUS_EN: - return visitor.visitAura2JanusEn(); - case AURA2NESTOR_ES: - return visitor.visitAura2NestorEs(); - case AURA2ORION_EN: - return visitor.visitAura2OrionEn(); - case AURA2MINERVA_EN: - return visitor.visitAura2MinervaEn(); - case AURA2ALVARO_ES: - return visitor.visitAura2AlvaroEs(); - case AURA_PERSEUS_EN: - return visitor.visitAuraPerseusEn(); - case AURA2VESTA_EN: - return visitor.visitAura2VestaEn(); - case FLUX_COLE_EN: - return visitor.visitFluxColeEn(); - case AURA2ZEUS_EN: - return visitor.visitAura2ZeusEn(); - case AURA2ORPHEUS_EN: - return visitor.visitAura2OrpheusEn(); - case AURA2THALIA_EN: - return visitor.visitAura2ThaliaEn(); - case FLUX_NAVEEN_EN: - return visitor.visitFluxNaveenEn(); - case AURA2ASTERIA_EN: - return visitor.visitAura2AsteriaEn(); - case AURA2SELENA_ES: - return visitor.visitAura2SelenaEs(); - case FLUX_MARCELO_EN: - return visitor.visitFluxMarceloEn(); - case FLUX_ELISE_EN: - return visitor.visitFluxEliseEn(); - case FLUX_ALEXIS_EN: - return visitor.visitFluxAlexisEn(); - case AURA_LUNA_EN: - return visitor.visitAuraLunaEn(); - case AURA_ORPHEUS_EN: - return visitor.visitAuraOrpheusEn(); - case AURA2AMALTHEA_EN: - return visitor.visitAura2AmaltheaEn(); - case FLUX_DONOVAN_EN: - return visitor.visitFluxDonovanEn(); - case AURA2SELENE_EN: - return visitor.visitAura2SeleneEn(); - case FLUX_TANNER_EN: - return visitor.visitFluxTannerEn(); - case FLUX_SHARON_EN: - return visitor.visitFluxSharonEn(); - case AURA2LUNA_EN: - return visitor.visitAura2LunaEn(); - case AURA2PHOEBE_EN: - return visitor.visitAura2PhoebeEn(); - case FLUX_HANNAH_EN: - return visitor.visitFluxHannahEn(); - case AURA2DIANA_ES: - return visitor.visitAura2DianaEs(); - case AURA_ORION_EN: - return visitor.visitAuraOrionEn(); - case AURA2ATHENA_EN: - return visitor.visitAura2AthenaEn(); - case AURA_ARCAS_EN: - return visitor.visitAuraArcasEn(); - case AURA2THEIA_EN: - return visitor.visitAura2TheiaEn(); - case FLUX_WADE_EN: - return visitor.visitFluxWadeEn(); - case FLUX_HEATHER_EN: - return visitor.visitFluxHeatherEn(); - case FLUX_CLIFF_EN: - return visitor.visitFluxCliffEn(); - case AURA2JUPITER_EN: - return visitor.visitAura2JupiterEn(); - case FLUX_KIT_EN: - return visitor.visitFluxKitEn(); - case AURA2AQUILA_ES: - return visitor.visitAura2AquilaEs(); - case AURA2CORA_EN: - return visitor.visitAura2CoraEn(); - case AURA2CORDELIA_EN: - return visitor.visitAura2CordeliaEn(); - case AURA2ATLAS_EN: - return visitor.visitAura2AtlasEn(); - case AURA2HYPERION_EN: - return visitor.visitAura2HyperionEn(); - case AURA2CELESTE_ES: - return visitor.visitAura2CelesteEs(); - case AURA2PLUTO_EN: - return visitor.visitAura2PlutoEn(); - case FLUX_BREE_EN: - return visitor.visitFluxBreeEn(); - case AURA2ARCAS_EN: - return visitor.visitAura2ArcasEn(); - case FLUX_COLIN_EN: - return visitor.visitFluxColinEn(); - case AURA_ATHENA_EN: - return visitor.visitAuraAthenaEn(); - case AURA2ODYSSEUS_EN: - return visitor.visitAura2OdysseusEn(); - case AURA2PANDORA_EN: - return visitor.visitAura2PandoraEn(); - case FLUX_MILES_EN: - return visitor.visitFluxMilesEn(); - case AURA_ASTERIA_EN: - return visitor.visitAuraAsteriaEn(); - case AURA2ELECTRA_EN: - return visitor.visitAura2ElectraEn(); - case FLUX_GEMMA_EN: - return visitor.visitFluxGemmaEn(); - case AURA2ESTRELLA_ES: - return visitor.visitAura2EstrellaEs(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DeepgramModel valueOf(String value) { - switch (value) { - case "aura-2-sirio-es": - return AURA2SIRIO_ES; - case "aura-2-hera-en": - return AURA2HERA_EN; - case "flux-kelsey-en": - return FLUX_KELSEY_EN; - case "flux-renee-en": - return FLUX_RENEE_EN; - case "flux-sienna-en": - return FLUX_SIENNA_EN; - case "aura-2-harmonia-en": - return AURA2HARMONIA_EN; - case "aura-2-carina-es": - return AURA2CARINA_ES; - case "flux-meena-en": - return FLUX_MEENA_EN; - case "flux-meghan-en": - return FLUX_MEGHAN_EN; - case "aura-zeus-en": - return AURA_ZEUS_EN; - case "aura-2-hermes-en": - return AURA2HERMES_EN; - case "flux-conor-en": - return FLUX_CONOR_EN; - case "aura-2-neptune-en": - return AURA2NEPTUNE_EN; - case "flux-brooke-en": - return FLUX_BROOKE_EN; - case "flux-rufus-en": - return FLUX_RUFUS_EN; - case "flux-wes-en": - return FLUX_WES_EN; - case "aura-2-callista-en": - return AURA2CALLISTA_EN; - case "aura-2-aurora-en": - return AURA2AURORA_EN; - case "aura-2-ophelia-en": - return AURA2OPHELIA_EN; - case "flux-bruce-en": - return FLUX_BRUCE_EN; - case "aura-2-apollo-en": - return AURA2APOLLO_EN; - case "aura-2-delia-en": - return AURA2DELIA_EN; - case "aura-2-mars-en": - return AURA2MARS_EN; - case "aura-hera-en": - return AURA_HERA_EN; - case "flux-maeve-en": - return FLUX_MAEVE_EN; - case "flux-marcus-en": - return FLUX_MARCUS_EN; - case "aura-2-aries-en": - return AURA2ARIES_EN; - case "flux-paige-en": - return FLUX_PAIGE_EN; - case "aura-2-juno-en": - return AURA2JUNO_EN; - case "flux-drew-en": - return FLUX_DREW_EN; - case "aura-2-javier-es": - return AURA2JAVIER_ES; - case "aura-2-andromeda-en": - return AURA2ANDROMEDA_EN; - case "aura-2-saturn-en": - return AURA2SATURN_EN; - case "aura-2-iris-en": - return AURA2IRIS_EN; - case "aura-angus-en": - return AURA_ANGUS_EN; - case "flux-kai-en": - return FLUX_KAI_EN; - case "flux-brittany-en": - return FLUX_BRITTANY_EN; - case "flux-sean-en": - return FLUX_SEAN_EN; - case "aura-2-helena-en": - return AURA2HELENA_EN; - case "flux-haley-en": - return FLUX_HALEY_EN; - case "aura-stella-en": - return AURA_STELLA_EN; - case "flux-jack-en": - return FLUX_JACK_EN; - case "aura-2-draco-en": - return AURA2DRACO_EN; - case "flux-priya-en": - return FLUX_PRIYA_EN; - case "aura-helios-en": - return AURA_HELIOS_EN; - case "aura-2-janus-en": - return AURA2JANUS_EN; - case "aura-2-nestor-es": - return AURA2NESTOR_ES; - case "aura-2-orion-en": - return AURA2ORION_EN; - case "aura-2-minerva-en": - return AURA2MINERVA_EN; - case "aura-2-alvaro-es": - return AURA2ALVARO_ES; - case "aura-perseus-en": - return AURA_PERSEUS_EN; - case "aura-2-vesta-en": - return AURA2VESTA_EN; - case "flux-cole-en": - return FLUX_COLE_EN; - case "aura-2-zeus-en": - return AURA2ZEUS_EN; - case "aura-2-orpheus-en": - return AURA2ORPHEUS_EN; - case "aura-2-thalia-en": - return AURA2THALIA_EN; - case "flux-naveen-en": - return FLUX_NAVEEN_EN; - case "aura-2-asteria-en": - return AURA2ASTERIA_EN; - case "aura-2-selena-es": - return AURA2SELENA_ES; - case "flux-marcelo-en": - return FLUX_MARCELO_EN; - case "flux-elise-en": - return FLUX_ELISE_EN; - case "flux-alexis-en": - return FLUX_ALEXIS_EN; - case "aura-luna-en": - return AURA_LUNA_EN; - case "aura-orpheus-en": - return AURA_ORPHEUS_EN; - case "aura-2-amalthea-en": - return AURA2AMALTHEA_EN; - case "flux-donovan-en": - return FLUX_DONOVAN_EN; - case "aura-2-selene-en": - return AURA2SELENE_EN; - case "flux-tanner-en": - return FLUX_TANNER_EN; - case "flux-sharon-en": - return FLUX_SHARON_EN; - case "aura-2-luna-en": - return AURA2LUNA_EN; - case "aura-2-phoebe-en": - return AURA2PHOEBE_EN; - case "flux-hannah-en": - return FLUX_HANNAH_EN; - case "aura-2-diana-es": - return AURA2DIANA_ES; - case "aura-orion-en": - return AURA_ORION_EN; - case "aura-2-athena-en": - return AURA2ATHENA_EN; - case "aura-arcas-en": - return AURA_ARCAS_EN; - case "aura-2-theia-en": - return AURA2THEIA_EN; - case "flux-wade-en": - return FLUX_WADE_EN; - case "flux-heather-en": - return FLUX_HEATHER_EN; - case "flux-cliff-en": - return FLUX_CLIFF_EN; - case "aura-2-jupiter-en": - return AURA2JUPITER_EN; - case "flux-kit-en": - return FLUX_KIT_EN; - case "aura-2-aquila-es": - return AURA2AQUILA_ES; - case "aura-2-cora-en": - return AURA2CORA_EN; - case "aura-2-cordelia-en": - return AURA2CORDELIA_EN; - case "aura-2-atlas-en": - return AURA2ATLAS_EN; - case "aura-2-hyperion-en": - return AURA2HYPERION_EN; - case "aura-2-celeste-es": - return AURA2CELESTE_ES; - case "aura-2-pluto-en": - return AURA2PLUTO_EN; - case "flux-bree-en": - return FLUX_BREE_EN; - case "aura-2-arcas-en": - return AURA2ARCAS_EN; - case "flux-colin-en": - return FLUX_COLIN_EN; - case "aura-athena-en": - return AURA_ATHENA_EN; - case "aura-2-odysseus-en": - return AURA2ODYSSEUS_EN; - case "aura-2-pandora-en": - return AURA2PANDORA_EN; - case "flux-miles-en": - return FLUX_MILES_EN; - case "aura-asteria-en": - return AURA_ASTERIA_EN; - case "aura-2-electra-en": - return AURA2ELECTRA_EN; - case "flux-gemma-en": - return FLUX_GEMMA_EN; - case "aura-2-estrella-es": - return AURA2ESTRELLA_ES; - default: - return new DeepgramModel(Value.UNKNOWN, value); - } - } - - public enum Value { - AURA_ASTERIA_EN, - - AURA_LUNA_EN, - - AURA_STELLA_EN, - - AURA_ATHENA_EN, - - AURA_HERA_EN, - - AURA_ORION_EN, - - AURA_ARCAS_EN, - - AURA_PERSEUS_EN, - - AURA_ANGUS_EN, - - AURA_ORPHEUS_EN, - - AURA_HELIOS_EN, - - AURA_ZEUS_EN, - - AURA2AMALTHEA_EN, - - AURA2ANDROMEDA_EN, - - AURA2APOLLO_EN, - - AURA2ARCAS_EN, - - AURA2ARIES_EN, - - AURA2ASTERIA_EN, - - AURA2ATHENA_EN, - - AURA2ATLAS_EN, - - AURA2AURORA_EN, - - AURA2CALLISTA_EN, - - AURA2CORA_EN, - - AURA2CORDELIA_EN, - - AURA2DELIA_EN, - - AURA2DRACO_EN, - - AURA2ELECTRA_EN, - - AURA2HARMONIA_EN, - - AURA2HELENA_EN, - - AURA2HERA_EN, - - AURA2HERMES_EN, - - AURA2HYPERION_EN, - - AURA2IRIS_EN, - - AURA2JANUS_EN, - - AURA2JUNO_EN, - - AURA2JUPITER_EN, - - AURA2LUNA_EN, - - AURA2MARS_EN, - - AURA2MINERVA_EN, - - AURA2NEPTUNE_EN, - - AURA2ODYSSEUS_EN, - - AURA2OPHELIA_EN, - - AURA2ORION_EN, - - AURA2ORPHEUS_EN, - - AURA2PANDORA_EN, - - AURA2PHOEBE_EN, - - AURA2PLUTO_EN, - - AURA2SATURN_EN, - - AURA2SELENE_EN, - - AURA2THALIA_EN, - - AURA2THEIA_EN, - - AURA2VESTA_EN, - - AURA2ZEUS_EN, - - AURA2SIRIO_ES, - - AURA2NESTOR_ES, - - AURA2CARINA_ES, - - AURA2CELESTE_ES, - - AURA2ALVARO_ES, - - AURA2DIANA_ES, - - AURA2AQUILA_ES, - - AURA2SELENA_ES, - - AURA2ESTRELLA_ES, - - AURA2JAVIER_ES, - - FLUX_ALEXIS_EN, - - FLUX_BREE_EN, - - FLUX_BRITTANY_EN, - - FLUX_BROOKE_EN, - - FLUX_BRUCE_EN, - - FLUX_CLIFF_EN, - - FLUX_COLE_EN, - - FLUX_COLIN_EN, - - FLUX_CONOR_EN, - - FLUX_DONOVAN_EN, - - FLUX_DREW_EN, - - FLUX_ELISE_EN, - - FLUX_GEMMA_EN, - - FLUX_HALEY_EN, - - FLUX_HANNAH_EN, - - FLUX_HEATHER_EN, - - FLUX_JACK_EN, - - FLUX_KAI_EN, - - FLUX_KELSEY_EN, - - FLUX_RENEE_EN, - - FLUX_KIT_EN, - - FLUX_MAEVE_EN, - - FLUX_MARCELO_EN, - - FLUX_MARCUS_EN, - - FLUX_MEENA_EN, - - FLUX_MEGHAN_EN, - - FLUX_MILES_EN, - - FLUX_NAVEEN_EN, - - FLUX_PAIGE_EN, - - FLUX_PRIYA_EN, - - FLUX_RUFUS_EN, - - FLUX_SEAN_EN, - - FLUX_SHARON_EN, - - FLUX_SIENNA_EN, - - FLUX_TANNER_EN, - - FLUX_WADE_EN, - - FLUX_WES_EN, - - UNKNOWN - } - - public interface Visitor { - T visitAuraAsteriaEn(); - - T visitAuraLunaEn(); - - T visitAuraStellaEn(); - - T visitAuraAthenaEn(); - - T visitAuraHeraEn(); - - T visitAuraOrionEn(); - - T visitAuraArcasEn(); - - T visitAuraPerseusEn(); - - T visitAuraAngusEn(); - - T visitAuraOrpheusEn(); - - T visitAuraHeliosEn(); - - T visitAuraZeusEn(); - - T visitAura2AmaltheaEn(); - - T visitAura2AndromedaEn(); - - T visitAura2ApolloEn(); - - T visitAura2ArcasEn(); - - T visitAura2AriesEn(); - - T visitAura2AsteriaEn(); - - T visitAura2AthenaEn(); - - T visitAura2AtlasEn(); - - T visitAura2AuroraEn(); - - T visitAura2CallistaEn(); - - T visitAura2CoraEn(); - - T visitAura2CordeliaEn(); - - T visitAura2DeliaEn(); - - T visitAura2DracoEn(); - - T visitAura2ElectraEn(); - - T visitAura2HarmoniaEn(); - - T visitAura2HelenaEn(); - - T visitAura2HeraEn(); - - T visitAura2HermesEn(); - - T visitAura2HyperionEn(); - - T visitAura2IrisEn(); - - T visitAura2JanusEn(); - - T visitAura2JunoEn(); - - T visitAura2JupiterEn(); - - T visitAura2LunaEn(); - - T visitAura2MarsEn(); - - T visitAura2MinervaEn(); - - T visitAura2NeptuneEn(); - - T visitAura2OdysseusEn(); - - T visitAura2OpheliaEn(); - - T visitAura2OrionEn(); - - T visitAura2OrpheusEn(); - - T visitAura2PandoraEn(); - - T visitAura2PhoebeEn(); - - T visitAura2PlutoEn(); - - T visitAura2SaturnEn(); - - T visitAura2SeleneEn(); - - T visitAura2ThaliaEn(); - - T visitAura2TheiaEn(); - - T visitAura2VestaEn(); - - T visitAura2ZeusEn(); - - T visitAura2SirioEs(); - - T visitAura2NestorEs(); - - T visitAura2CarinaEs(); - - T visitAura2CelesteEs(); - - T visitAura2AlvaroEs(); - - T visitAura2DianaEs(); - - T visitAura2AquilaEs(); - - T visitAura2SelenaEs(); - - T visitAura2EstrellaEs(); - - T visitAura2JavierEs(); - - T visitFluxAlexisEn(); - - T visitFluxBreeEn(); - - T visitFluxBrittanyEn(); - - T visitFluxBrookeEn(); - - T visitFluxBruceEn(); - - T visitFluxCliffEn(); - - T visitFluxColeEn(); - - T visitFluxColinEn(); - - T visitFluxConorEn(); - - T visitFluxDonovanEn(); - - T visitFluxDrewEn(); - - T visitFluxEliseEn(); - - T visitFluxGemmaEn(); - - T visitFluxHaleyEn(); - - T visitFluxHannahEn(); - - T visitFluxHeatherEn(); - - T visitFluxJackEn(); - - T visitFluxKaiEn(); - - T visitFluxKelseyEn(); - - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - T visitFluxReneeEn(); - - T visitFluxKitEn(); - - T visitFluxMaeveEn(); - - T visitFluxMarceloEn(); - - T visitFluxMarcusEn(); - - T visitFluxMeenaEn(); - - T visitFluxMeghanEn(); - - T visitFluxMilesEn(); - - T visitFluxNaveenEn(); - - T visitFluxPaigeEn(); - - T visitFluxPriyaEn(); - - T visitFluxRufusEn(); - - T visitFluxSeanEn(); - - T visitFluxSharonEn(); - - T visitFluxSiennaEn(); - - T visitFluxTannerEn(); - - T visitFluxWadeEn(); - - T visitFluxWesEn(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java index e0db2fe..41c0977 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java @@ -27,7 +27,7 @@ public final class DeepgramThinkProvider { private final Optional temperature; - private final Optional reasoningMode; + private final Optional reasoningMode; private final Optional voicePromptOptOut; @@ -37,7 +37,7 @@ private DeepgramThinkProvider( Optional version, DeepgramThinkProviderModel model, Optional temperature, - Optional reasoningMode, + Optional reasoningMode, Optional voicePromptOptOut, Map additionalProperties) { this.version = version; @@ -69,7 +69,7 @@ public Optional getTemperature() { } @JsonProperty("reasoning_mode") - public Optional getReasoningMode() { + public Optional getReasoningMode() { return reasoningMode; } @@ -132,9 +132,9 @@ public interface _FinalStage { _FinalStage temperature(Double temperature); - _FinalStage reasoningMode(Optional reasoningMode); + _FinalStage reasoningMode(Optional reasoningMode); - _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode); + _FinalStage reasoningMode(DeepgramThinkProviderReasoningMode reasoningMode); _FinalStage voicePromptOptOut(Optional voicePromptOptOut); @@ -147,7 +147,7 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional voicePromptOptOut = Optional.empty(); - private Optional reasoningMode = Optional.empty(); + private Optional reasoningMode = Optional.empty(); private Optional temperature = Optional.empty(); @@ -189,14 +189,14 @@ public _FinalStage voicePromptOptOut(Optional voicePromptOptOut) { } @java.lang.Override - public _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode) { + public _FinalStage reasoningMode(DeepgramThinkProviderReasoningMode reasoningMode) { this.reasoningMode = Optional.ofNullable(reasoningMode); return this; } @java.lang.Override @JsonSetter(value = "reasoning_mode", nulls = Nulls.SKIP) - public _FinalStage reasoningMode(Optional reasoningMode) { + public _FinalStage reasoningMode(Optional reasoningMode) { this.reasoningMode = reasoningMode; return this; } diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak deleted file mode 100644 index e0db2fe..0000000 --- a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java.bak +++ /dev/null @@ -1,248 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DeepgramThinkProvider.Builder.class) -public final class DeepgramThinkProvider { - private final Optional version; - - private final DeepgramThinkProviderModel model; - - private final Optional temperature; - - private final Optional reasoningMode; - - private final Optional voicePromptOptOut; - - private final Map additionalProperties; - - private DeepgramThinkProvider( - Optional version, - DeepgramThinkProviderModel model, - Optional temperature, - Optional reasoningMode, - Optional voicePromptOptOut, - Map additionalProperties) { - this.version = version; - this.model = model; - this.temperature = temperature; - this.reasoningMode = reasoningMode; - this.voicePromptOptOut = voicePromptOptOut; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("type") - public String getType() { - return "deepgram"; - } - - @JsonProperty("version") - public Optional getVersion() { - return version; - } - - @JsonProperty("model") - public DeepgramThinkProviderModel getModel() { - return model; - } - - @JsonProperty("temperature") - public Optional getTemperature() { - return temperature; - } - - @JsonProperty("reasoning_mode") - public Optional getReasoningMode() { - return reasoningMode; - } - - @JsonProperty("voice_prompt_opt_out") - public Optional getVoicePromptOptOut() { - return voicePromptOptOut; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeepgramThinkProvider && equalTo((DeepgramThinkProvider) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeepgramThinkProvider other) { - return version.equals(other.version) - && model.equals(other.model) - && temperature.equals(other.temperature) - && reasoningMode.equals(other.reasoningMode) - && voicePromptOptOut.equals(other.voicePromptOptOut); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.version, this.model, this.temperature, this.reasoningMode, this.voicePromptOptOut); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ModelStage builder() { - return new Builder(); - } - - public interface ModelStage { - _FinalStage model(@NotNull DeepgramThinkProviderModel model); - - Builder from(DeepgramThinkProvider other); - } - - public interface _FinalStage { - DeepgramThinkProvider build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - _FinalStage version(Optional version); - - _FinalStage version(String version); - - _FinalStage temperature(Optional temperature); - - _FinalStage temperature(Double temperature); - - _FinalStage reasoningMode(Optional reasoningMode); - - _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode); - - _FinalStage voicePromptOptOut(Optional voicePromptOptOut); - - _FinalStage voicePromptOptOut(Boolean voicePromptOptOut); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ModelStage, _FinalStage { - private DeepgramThinkProviderModel model; - - private Optional voicePromptOptOut = Optional.empty(); - - private Optional reasoningMode = Optional.empty(); - - private Optional temperature = Optional.empty(); - - private Optional version = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeepgramThinkProvider other) { - version(other.getVersion()); - model(other.getModel()); - temperature(other.getTemperature()); - reasoningMode(other.getReasoningMode()); - voicePromptOptOut(other.getVoicePromptOptOut()); - return this; - } - - @java.lang.Override - @JsonSetter("model") - public _FinalStage model(@NotNull DeepgramThinkProviderModel model) { - this.model = Objects.requireNonNull(model, "model must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage voicePromptOptOut(Boolean voicePromptOptOut) { - this.voicePromptOptOut = Optional.ofNullable(voicePromptOptOut); - return this; - } - - @java.lang.Override - @JsonSetter(value = "voice_prompt_opt_out", nulls = Nulls.SKIP) - public _FinalStage voicePromptOptOut(Optional voicePromptOptOut) { - this.voicePromptOptOut = voicePromptOptOut; - return this; - } - - @java.lang.Override - public _FinalStage reasoningMode(DeepgramReasoningMode reasoningMode) { - this.reasoningMode = Optional.ofNullable(reasoningMode); - return this; - } - - @java.lang.Override - @JsonSetter(value = "reasoning_mode", nulls = Nulls.SKIP) - public _FinalStage reasoningMode(Optional reasoningMode) { - this.reasoningMode = reasoningMode; - return this; - } - - @java.lang.Override - public _FinalStage temperature(Double temperature) { - this.temperature = Optional.ofNullable(temperature); - return this; - } - - @java.lang.Override - @JsonSetter(value = "temperature", nulls = Nulls.SKIP) - public _FinalStage temperature(Optional temperature) { - this.temperature = temperature; - return this; - } - - @java.lang.Override - public _FinalStage version(String version) { - this.version = Optional.ofNullable(version); - return this; - } - - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - @java.lang.Override - public DeepgramThinkProvider build() { - return new DeepgramThinkProvider( - version, model, temperature, reasoningMode, voicePromptOptOut, additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak deleted file mode 100644 index f9f00eb..0000000 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java.bak +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class DeepgramThinkProviderModel { - public static final DeepgramThinkProviderModel THINK_FAST = - new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); - - public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA_2_FP8 = - new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); - - private final Value value; - - private final String string; - - DeepgramThinkProviderModel(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof DeepgramThinkProviderModel - && this.string.equals(((DeepgramThinkProviderModel) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case THINK_FAST: - return visitor.visitThinkFast(); - case PHONELLM_MINI_ALPHA_2_FP8: - return visitor.visitPhonellmMiniAlpha2Fp8(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DeepgramThinkProviderModel valueOf(String value) { - switch (value) { - case "think-fast": - return THINK_FAST; - case "phonellm-mini-alpha-2-fp8": - return PHONELLM_MINI_ALPHA_2_FP8; - default: - return new DeepgramThinkProviderModel(Value.UNKNOWN, value); - } - } - - public enum Value { - THINK_FAST, - - PHONELLM_MINI_ALPHA_2_FP8, - - UNKNOWN - } - - public interface Visitor { - T visitThinkFast(); - - T visitPhonellmMiniAlpha2Fp8(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak deleted file mode 100644 index d093a02..0000000 --- a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak +++ /dev/null @@ -1,458 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class ThinkSettingsV1Provider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private ThinkSettingsV1Provider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static ThinkSettingsV1Provider openAi(OpenAiThinkProvider value) { - return new ThinkSettingsV1Provider(new OpenAiValue(value)); - } - - public static ThinkSettingsV1Provider awsBedrock(AwsBedrockThinkProvider value) { - return new ThinkSettingsV1Provider(new AwsBedrockValue(value)); - } - - public static ThinkSettingsV1Provider anthropic(Anthropic value) { - return new ThinkSettingsV1Provider(new AnthropicValue(value)); - } - - public static ThinkSettingsV1Provider google(Google value) { - return new ThinkSettingsV1Provider(new GoogleValue(value)); - } - - public static ThinkSettingsV1Provider groq(Groq value) { - return new ThinkSettingsV1Provider(new GroqValue(value)); - } - - public static ThinkSettingsV1Provider deepgram(DeepgramThinkProvider value) { - return new ThinkSettingsV1Provider(new DeepgramValue(value)); - } - - public boolean isOpenAi() { - return value instanceof OpenAiValue; - } - - public boolean isAwsBedrock() { - return value instanceof AwsBedrockValue; - } - - public boolean isAnthropic() { - return value instanceof AnthropicValue; - } - - public boolean isGoogle() { - return value instanceof GoogleValue; - } - - public boolean isGroq() { - return value instanceof GroqValue; - } - - public boolean isDeepgram() { - return value instanceof DeepgramValue; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getOpenAi() { - if (isOpenAi()) { - return Optional.of(((OpenAiValue) value).value); - } - return Optional.empty(); - } - - public Optional getAwsBedrock() { - if (isAwsBedrock()) { - return Optional.of(((AwsBedrockValue) value).value); - } - return Optional.empty(); - } - - public Optional getAnthropic() { - if (isAnthropic()) { - return Optional.of(((AnthropicValue) value).value); - } - return Optional.empty(); - } - - public Optional getGoogle() { - if (isGoogle()) { - return Optional.of(((GoogleValue) value).value); - } - return Optional.empty(); - } - - public Optional getGroq() { - if (isGroq()) { - return Optional.of(((GroqValue) value).value); - } - return Optional.empty(); - } - - public Optional getDeepgram() { - if (isDeepgram()) { - return Optional.of(((DeepgramValue) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ThinkSettingsV1Provider && value.equals(((ThinkSettingsV1Provider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitOpenAi(OpenAiThinkProvider openAi); - - T visitAwsBedrock(AwsBedrockThinkProvider awsBedrock); - - T visitAnthropic(Anthropic anthropic); - - T visitGoogle(Google google); - - T visitGroq(Groq groq); - - default T visitDeepgram(DeepgramThinkProvider deepgram) { - return _visitUnknown(deepgram); - } - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) - @JsonSubTypes({ - @JsonSubTypes.Type(OpenAiValue.class), - @JsonSubTypes.Type(AwsBedrockValue.class), - @JsonSubTypes.Type(AnthropicValue.class), - @JsonSubTypes.Type(GoogleValue.class), - @JsonSubTypes.Type(GroqValue.class), - @JsonSubTypes.Type(DeepgramValue.class) - }) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("open_ai") - @JsonIgnoreProperties("type") - private static final class OpenAiValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private OpenAiThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private OpenAiValue() {} - - private OpenAiValue(OpenAiThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitOpenAi(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OpenAiValue && equalTo((OpenAiValue) other); - } - - private boolean equalTo(OpenAiValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("aws_bedrock") - @JsonIgnoreProperties("type") - private static final class AwsBedrockValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private AwsBedrockThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private AwsBedrockValue() {} - - private AwsBedrockValue(AwsBedrockThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitAwsBedrock(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AwsBedrockValue && equalTo((AwsBedrockValue) other); - } - - private boolean equalTo(AwsBedrockValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("anthropic") - @JsonIgnoreProperties("type") - private static final class AnthropicValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Anthropic value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private AnthropicValue() {} - - private AnthropicValue(Anthropic value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitAnthropic(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AnthropicValue && equalTo((AnthropicValue) other); - } - - private boolean equalTo(AnthropicValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("google") - @JsonIgnoreProperties("type") - private static final class GoogleValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Google value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private GoogleValue() {} - - private GoogleValue(Google value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitGoogle(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GoogleValue && equalTo((GoogleValue) other); - } - - private boolean equalTo(GoogleValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("groq") - @JsonIgnoreProperties("type") - private static final class GroqValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Groq value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private GroqValue() {} - - private GroqValue(Groq value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitGroq(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GroqValue && equalTo((GroqValue) other); - } - - private boolean equalTo(GroqValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("deepgram") - @JsonIgnoreProperties("type") - private static final class DeepgramValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private DeepgramThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private DeepgramValue() {} - - private DeepgramValue(DeepgramThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitDeepgram(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeepgramValue && equalTo((DeepgramValue) other); - } - - private boolean equalTo(DeepgramValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("type") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/test/java/com/deepgram/AgentV1ThinkLiveWireTest.java b/src/test/java/com/deepgram/AgentV1ThinkLiveWireTest.java index 15d7f31..dce4db0 100644 --- a/src/test/java/com/deepgram/AgentV1ThinkLiveWireTest.java +++ b/src/test/java/com/deepgram/AgentV1ThinkLiveWireTest.java @@ -22,7 +22,7 @@ import com.deepgram.types.DeepgramThinkLiveProviderV1; import com.deepgram.types.DeepgramThinkProvider; import com.deepgram.types.DeepgramThinkProviderModel; -import com.deepgram.types.DeepgramReasoningMode; +import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.OpenAiThinkProvider; import com.deepgram.types.OpenAiThinkProviderModel; import com.deepgram.types.ThinkLiveSettingsV1; @@ -220,7 +220,7 @@ public void onClosing(WebSocket webSocket, int code, String reason) { .model(DeepgramThinkProviderModel.THINK_FAST) .version("v1") .temperature(0.7) - .reasoningMode(DeepgramReasoningMode.LOW) + .reasoningMode(DeepgramThinkProviderReasoningMode.LOW) .voicePromptOptOut(true) .build(); AgentV1Settings settings = AgentV1Settings.builder() diff --git a/src/test/java/com/deepgram/RegenTypesTest.java b/src/test/java/com/deepgram/RegenTypesTest.java index 4bc62fc..3c8e4b0 100644 --- a/src/test/java/com/deepgram/RegenTypesTest.java +++ b/src/test/java/com/deepgram/RegenTypesTest.java @@ -34,7 +34,7 @@ import com.deepgram.types.Deepgram; import com.deepgram.types.DeepgramListenProviderV2; import com.deepgram.types.DeepgramModel; -import com.deepgram.types.DeepgramReasoningMode; +import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.DeepgramThinkProvider; import com.deepgram.types.DeepgramThinkProviderModel; import com.deepgram.types.Google; @@ -283,7 +283,7 @@ void phoneLlmRoundTrips() throws Exception { .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8) .version("v1") .temperature(0.4) - .reasoningMode(DeepgramReasoningMode.NONE) + .reasoningMode(DeepgramThinkProviderReasoningMode.NONE) .build(); ThinkSettingsV1 settings = ThinkSettingsV1.builder() .provider(ThinkSettingsV1Provider.deepgram(provider)) @@ -308,7 +308,7 @@ void thinkFastRoundTrips() throws Exception { .model(DeepgramThinkProviderModel.THINK_FAST) .version("v1") .temperature(0.7) - .reasoningMode(DeepgramReasoningMode.LOW) + .reasoningMode(DeepgramThinkProviderReasoningMode.LOW) .voicePromptOptOut(true) .build(); From ed1165cf0c9e5abac95225e6b15dd600c42f9306 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 17:44:02 +0000 Subject: [PATCH 6/9] chore: restore release-managed SDK version --- .fern/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.fern/metadata.json b/.fern/metadata.json index 8e40cb5..465a289 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -15,5 +15,5 @@ "originGitCommit": "596e7bdfa377f40f3301b1d394c9f0215af5f6d4", "originGitCommitIsDirty": true, "invokedBy": "manual", - "sdkVersion": "0.11.4" -} \ No newline at end of file + "sdkVersion": "0.11.3" +} From 6e7347034672bc58f4f67cc0ec2d3b6c403f1002 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 17:52:44 +0000 Subject: [PATCH 7/9] test(agent): cover Deepgram Think provider settings --- .../IntegrationTestAgentThinkProvider.java | 114 ++++++++++++++++++ .../java/com/deepgram/RegenTypesTest.java | 15 +++ 2 files changed, 129 insertions(+) create mode 100644 src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java diff --git a/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java new file mode 100644 index 0000000..f49570b --- /dev/null +++ b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java @@ -0,0 +1,114 @@ +package com.deepgram; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.deepgram.resources.agent.v1.types.AgentV1Settings; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsAgent; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsAgentContext; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsAgentContextThink; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsAudio; +import com.deepgram.resources.agent.v1.websocket.V1WebSocketClient; +import com.deepgram.types.DeepgramThinkProvider; +import com.deepgram.types.DeepgramThinkProviderModel; +import com.deepgram.types.DeepgramThinkProviderReasoningMode; +import com.deepgram.types.ThinkSettingsV1; +import com.deepgram.types.ThinkSettingsV1Provider; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +/** Live integration coverage for the Deepgram-hosted Think provider. */ +class IntegrationTestAgentThinkProvider { + private DeepgramClient client; + + @BeforeEach + void setUp() { + String apiKey = System.getenv("DEEPGRAM_API_KEY"); + org.junit.jupiter.api.Assumptions.assumeTrue( + apiKey != null && !apiKey.isEmpty(), "DEEPGRAM_API_KEY not set, skipping integration test"); + String enabled = System.getenv("DEEPGRAM_AGENT_THINK_PROVIDER"); + org.junit.jupiter.api.Assumptions.assumeTrue( + enabled != null && !enabled.isEmpty(), "DEEPGRAM_AGENT_THINK_PROVIDER not set, skipping integration test"); + client = DeepgramClient.builder().apiKey(apiKey).build(); + } + + @Test + @DisplayName("Deepgram Think accepts Think Fast and PhoneLLM settings") + void appliesSettingsForBothDeepgramThinkModels() throws Exception { + assertSettingsApplied( + DeepgramThinkProviderModel.THINK_FAST, DeepgramThinkProviderReasoningMode.LOW, true); + assertSettingsApplied( + DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8, + DeepgramThinkProviderReasoningMode.NONE, + false); + } + + private void assertSettingsApplied( + DeepgramThinkProviderModel model, + DeepgramThinkProviderReasoningMode reasoningMode, + boolean voicePromptOptOut) + throws Exception { + V1WebSocketClient webSocket = client.agent().v1().v1WebSocket(); + CountDownLatch completed = new CountDownLatch(1); + AtomicReference failure = new AtomicReference<>(); + + webSocket.onWelcome(ignored -> webSocket + .sendSettings(settings(model, reasoningMode, voicePromptOptOut)) + .whenComplete((unused, throwable) -> { + if (throwable != null) { + failure.compareAndSet(null, throwable); + completed.countDown(); + } + })); + webSocket.onSettingsApplied(ignored -> completed.countDown()); + webSocket.onErrorMessage(error -> { + failure.compareAndSet(null, new IllegalStateException(error.toString())); + completed.countDown(); + }); + webSocket.onError(error -> { + failure.compareAndSet(null, error); + completed.countDown(); + }); + webSocket.onDisconnected(reason -> { + failure.compareAndSet( + null, new IllegalStateException("Agent disconnected before applying Think settings: " + reason)); + completed.countDown(); + }); + + try { + webSocket.connect().get(10, TimeUnit.SECONDS); + + assertThat(completed.await(20, TimeUnit.SECONDS)) + .withFailMessage("Agent did not apply settings for model %s", model) + .isTrue(); + assertThat(failure.get()).isNull(); + } finally { + webSocket.disconnect(); + } + } + + private AgentV1Settings settings( + DeepgramThinkProviderModel model, + DeepgramThinkProviderReasoningMode reasoningMode, + boolean voicePromptOptOut) { + DeepgramThinkProvider provider = DeepgramThinkProvider.builder() + .model(model) + .version("v1") + .temperature(0.2) + .reasoningMode(reasoningMode) + .voicePromptOptOut(voicePromptOptOut) + .build(); + return AgentV1Settings.builder() + .audio(AgentV1SettingsAudio.builder().build()) + .agent(AgentV1SettingsAgent.of(AgentV1SettingsAgentContext.builder() + .think(AgentV1SettingsAgentContextThink.of(ThinkSettingsV1.builder() + .provider(ThinkSettingsV1Provider.deepgram(provider)) + .prompt("Keep responses brief.") + .build())) + .build())) + .build(); + } +} diff --git a/src/test/java/com/deepgram/RegenTypesTest.java b/src/test/java/com/deepgram/RegenTypesTest.java index 3c8e4b0..afad449 100644 --- a/src/test/java/com/deepgram/RegenTypesTest.java +++ b/src/test/java/com/deepgram/RegenTypesTest.java @@ -323,6 +323,21 @@ void thinkFastRoundTrips() throws Exception { assertThat(json).contains("\"voice_prompt_opt_out\":true"); assertThat(parsed.getProvider().getDeepgram()).contains(provider); } + + @Test + @DisplayName("all reasoning modes round-trip their wire values") + void reasoningModesRoundTrip() throws Exception { + for (DeepgramThinkProviderReasoningMode reasoningMode : List.of( + DeepgramThinkProviderReasoningMode.NONE, + DeepgramThinkProviderReasoningMode.MINIMAL, + DeepgramThinkProviderReasoningMode.LOW, + DeepgramThinkProviderReasoningMode.MEDIUM, + DeepgramThinkProviderReasoningMode.HIGH)) { + String json = MAPPER.writeValueAsString(reasoningMode); + + assertThat(MAPPER.readValue(json, DeepgramThinkProviderReasoningMode.class)).isEqualTo(reasoningMode); + } + } } @Nested From 32e044c0cdadda5f95b64c576f2d295d2c8f2199 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Fri, 30 Oct 2026 18:06:48 +0000 Subject: [PATCH 8/9] test(agent): cover all Think reasoning modes --- .../IntegrationTestAgentThinkProvider.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java index f49570b..3ab78f0 100644 --- a/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java +++ b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java @@ -13,6 +13,7 @@ import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.ThinkSettingsV1; import com.deepgram.types.ThinkSettingsV1Provider; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -36,14 +37,20 @@ void setUp() { } @Test - @DisplayName("Deepgram Think accepts Think Fast and PhoneLLM settings") - void appliesSettingsForBothDeepgramThinkModels() throws Exception { - assertSettingsApplied( - DeepgramThinkProviderModel.THINK_FAST, DeepgramThinkProviderReasoningMode.LOW, true); - assertSettingsApplied( - DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8, + @DisplayName("Deepgram Think accepts every model and reasoning mode") + void appliesSettingsForEveryDeepgramThinkModelAndReasoningMode() throws Exception { + List reasoningModes = List.of( DeepgramThinkProviderReasoningMode.NONE, - false); + DeepgramThinkProviderReasoningMode.MINIMAL, + DeepgramThinkProviderReasoningMode.LOW, + DeepgramThinkProviderReasoningMode.MEDIUM, + DeepgramThinkProviderReasoningMode.HIGH); + for (DeepgramThinkProviderModel model : List.of( + DeepgramThinkProviderModel.THINK_FAST, DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8)) { + for (DeepgramThinkProviderReasoningMode reasoningMode : reasoningModes) { + assertSettingsApplied(model, reasoningMode, model.equals(DeepgramThinkProviderModel.THINK_FAST)); + } + } } private void assertSettingsApplied( From 45369a04854cfb850da3903ce973d71aeb46f08b Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Mon, 2 Nov 2026 11:33:24 +0000 Subject: [PATCH 9/9] fix(regen): unfreeze generated Think provider types --- .fernignore | 6 ++---- AGENTS.md | 2 +- src/test/java/com/deepgram/RegenTypesTest.java | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.fernignore b/.fernignore index b0b2ff9..b7b416f 100644 --- a/.fernignore +++ b/.fernignore @@ -71,11 +71,9 @@ src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeReq # Preserve existing AgentV1ConversationText builder implementations after adding conversationalBehavior. src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java -# The spec's Deepgram Think/Speak title collision makes Fern use the TTS-shaped Deepgram type for Think. -# Restore the distinct Think provider/model types until the spec produces them; retain the Visitor default until Fern does. +# Fern now generates the distinct Deepgram Think provider and model types. Keep the union frozen only to preserve the +# default Visitor method for source and binary compatibility with callers compiled before the Deepgram provider existed. src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java -src/main/java/com/deepgram/types/DeepgramThinkProvider.java -src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java # Restores the FLUX_RENEE_EN constant that generator 4.18.0 dropped. The voice is live: # POST /v2/speak?model=flux-renee-en returns 200 with valid audio, and the name resolves in the diff --git a/AGENTS.md b/AGENTS.md index e7f30ca..a5e697a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,7 +51,7 @@ Current temporarily frozen files: - `src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java` - Agent V1 already delivers every raw control frame through `onMessage(String)`. Suppress generic errors for unknown frames only when a raw handler is registered; otherwise retain legacy `onError` delivery. Preserve the generated Think Live, dynamic-injection, and frustration handlers during reconciliation. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java` restores the legacy `content(...): _FinalStage` builder stage and defaults omitted or empty `conversational_behavior` to `default`. The schema now requires the wire field, while this shim preserves source and binary compatibility for callers compiled before Think Live existed. `ConversationalBehaviorStage` remains as an intentionally retained generated type, even though the restored legacy stage no longer returns it. -- `src/main/java/com/deepgram/types/{ThinkSettingsV1Provider,DeepgramThinkProvider,DeepgramThinkProviderModel}.java` patches a Fern title collision: the AsyncAPI overrides name both `DeepgramThinkProvider` and `DeepgramSpeakProvider` "Deepgram", so Fern routes the Think union through the TTS-shaped `Deepgram` type. The patch restores the distinct Think provider/model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`, and makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`; once regeneration produces the provider and model types, unfreeze only those files. Retain the frozen `ThinkSettingsV1Provider` default method until Fern generates it or the next major release. +- `src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java` makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility with implementations compiled before the provider existed. Fern now generates the distinct Think provider and model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`; retain only this Visitor default until Fern generates it or the next major release. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java` - fields-less event type with a manual `hashCode()` patch. Fern generates `equals()` but no matching `hashCode()`, violating the Object contract; retain the patch, freeze entry, and `RegenTypesTest.FieldsLessMessageContract` assertion until Fern fixes the pattern. - `src/main/java/com/deepgram/core/ClientOptions.java` - preserves release-please version markers, correct SDK header constants, and the accurate `close()` lifecycle Javadoc that Fern currently overwrites; use the standard `.bak` swap/restore workflow during regen review. Since generator 4.18.0 Fern emits a `getSdkVersion()` helper reading `Package.getImplementationVersion()` instead of a literal. That *does* resolve in the published artifact (CI publishes via `./mvnw deploy -P release`, and `pom.xml`'s maven-jar-plugin sets `addDefaultImplementationEntries=true`, so the JAR manifest carries `Implementation-Version`), but it resolves to `null` under Gradle and in tests, where it silently falls back to a hardcoded literal the generator does not keep current. We keep the explicit literals because they are correct in every context and because `.github/release-please-config.json` already lists this file in `extra-files`, so release-please bumps it alongside `pom.xml`, `build.gradle`, and `.fern/metadata.json`. Fern also emits `User-Agent` with a `com.deepgram.` prefix while leaving `X-Fern-SDK-Name` on the `com.deepgram:` Maven-coordinate form; we keep both on the colon form. Fern 4.22.1 tracks and closes child WebSockets before shutting down SDK-owned OkHttp resources; the permanent custom client wrappers inherit it, so do not add wrapper-local lifecycle code and retain Fern's lifecycle implementation during reconciliation. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` - carries bug fixes for `maxRetries(0)` semantics ("connect once, don't retry") and a configurable `connectionTimeoutMs` field (was hardcoded 4000ms), plus an `applyOptionsOverride(...)` hook used by `TransportWebSocketFactory` to apply per-transport reconnect policy; pull this back out once the fixes are upstreamed into the Fern generator. Use the standard `.bak` swap/restore workflow during regen review. diff --git a/src/test/java/com/deepgram/RegenTypesTest.java b/src/test/java/com/deepgram/RegenTypesTest.java index afad449..913dc50 100644 --- a/src/test/java/com/deepgram/RegenTypesTest.java +++ b/src/test/java/com/deepgram/RegenTypesTest.java @@ -34,9 +34,9 @@ import com.deepgram.types.Deepgram; import com.deepgram.types.DeepgramListenProviderV2; import com.deepgram.types.DeepgramModel; -import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.DeepgramThinkProvider; import com.deepgram.types.DeepgramThinkProviderModel; +import com.deepgram.types.DeepgramThinkProviderReasoningMode; import com.deepgram.types.Google; import com.deepgram.types.GoogleModel; import com.deepgram.types.GoogleVersion;