Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"enable-wire-tests": true,
"runtime-version": true
},
"originGitCommit": "56f50652950bce4294c5388be6f25055749f55a7",
"originGitCommit": "596e7bdfa377f40f3301b1d394c9f0215af5f6d4",
"originGitCommitIsDirty": true,
"invokedBy": "manual",
"sdkVersion": "0.11.3"
Expand Down
8 changes: 7 additions & 1 deletion .fern/replay.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/agent/ProviderCombinations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/deepgram/types/DeepgramThinkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class DeepgramThinkProvider {

private final Optional<Double> temperature;

private final Optional<DeepgramReasoningMode> reasoningMode;
private final Optional<DeepgramThinkProviderReasoningMode> reasoningMode;

private final Optional<Boolean> voicePromptOptOut;

Expand All @@ -37,7 +37,7 @@ private DeepgramThinkProvider(
Optional<String> version,
DeepgramThinkProviderModel model,
Optional<Double> temperature,
Optional<DeepgramReasoningMode> reasoningMode,
Optional<DeepgramThinkProviderReasoningMode> reasoningMode,
Optional<Boolean> voicePromptOptOut,
Map<String, Object> additionalProperties) {
this.version = version;
Expand Down Expand Up @@ -69,7 +69,7 @@ public Optional<Double> getTemperature() {
}

@JsonProperty("reasoning_mode")
public Optional<DeepgramReasoningMode> getReasoningMode() {
public Optional<DeepgramThinkProviderReasoningMode> getReasoningMode() {
return reasoningMode;
}

Expand Down Expand Up @@ -132,9 +132,9 @@ public interface _FinalStage {

_FinalStage temperature(Double temperature);

_FinalStage reasoningMode(Optional<DeepgramReasoningMode> reasoningMode);
_FinalStage reasoningMode(Optional<DeepgramThinkProviderReasoningMode> reasoningMode);

_FinalStage reasoningMode(DeepgramReasoningMode reasoningMode);
_FinalStage reasoningMode(DeepgramThinkProviderReasoningMode reasoningMode);

_FinalStage voicePromptOptOut(Optional<Boolean> voicePromptOptOut);

Expand All @@ -147,7 +147,7 @@ public static final class Builder implements ModelStage, _FinalStage {

private Optional<Boolean> voicePromptOptOut = Optional.empty();

private Optional<DeepgramReasoningMode> reasoningMode = Optional.empty();
private Optional<DeepgramThinkProviderReasoningMode> reasoningMode = Optional.empty();

private Optional<Double> temperature = Optional.empty();

Expand Down Expand Up @@ -189,14 +189,14 @@ public _FinalStage voicePromptOptOut(Optional<Boolean> 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<DeepgramReasoningMode> reasoningMode) {
public _FinalStage reasoningMode(Optional<DeepgramThinkProviderReasoningMode> reasoningMode) {
this.reasoningMode = reasoningMode;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -67,7 +72,7 @@ public <T> T visit(Visitor<T> visitor) {
}

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static DeepgramReasoningMode valueOf(String value) {
public static DeepgramThinkProviderReasoningMode valueOf(String value) {
switch (value) {
case "medium":
return MEDIUM;
Expand All @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/deepgram/AgentV1ThinkLiveWireTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
121 changes: 121 additions & 0 deletions src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java
Original file line number Diff line number Diff line change
@@ -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<DeepgramThinkProviderReasoningMode> 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<Throwable> 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();
}
}
Loading
Loading