diff --git a/.fern/metadata.json b/.fern/metadata.json index 159adaf..465a289 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -12,7 +12,7 @@ "enable-wire-tests": true, "runtime-version": true }, - "originGitCommit": "56f50652950bce4294c5388be6f25055749f55a7", + "originGitCommit": "596e7bdfa377f40f3301b1d394c9f0215af5f6d4", "originGitCommitIsDirty": true, "invokedBy": "manual", "sdkVersion": "0.11.3" 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: [] 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/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/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/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); } } 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/IntegrationTestAgentThinkProvider.java b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java new file mode 100644 index 0000000..3ab78f0 --- /dev/null +++ b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java @@ -0,0 +1,121 @@ +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.List; +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 every model and reasoning mode") + void appliesSettingsForEveryDeepgramThinkModelAndReasoningMode() throws Exception { + List reasoningModes = List.of( + DeepgramThinkProviderReasoningMode.NONE, + 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( + 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 4bc62fc..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.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.GoogleVersion; @@ -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(); @@ -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