Skip to content
Open
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 @@ -11,7 +11,7 @@
},
"enable-wire-tests": true
},
"originGitCommit": "0052a020a7becd03b349857664c9f4a89b6c449a",
"originGitCommit": "d228f82e93aaa8aa77f978d458cf912f3daaa8c1",
"originGitCommitIsDirty": true,
"invokedBy": "manual",
"sdkVersion": "0.4.1"
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/com/deepgram/core/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
package com.deepgram.core;

public final class Environment {
public static final Environment PRODUCTION =
new Environment("https://api.deepgram.com", "wss://api.deepgram.com", "wss://agent.deepgram.com");

public static final Environment AGENT =
new Environment("https://agent.deepgram.com", "wss://api.deepgram.com", "wss://agent.deepgram.com");
public static final Environment PRODUCTION = new Environment(
"https://api.deepgram.com",
"wss://api.deepgram.com",
"wss://agent.deepgram.com",
"https://agent.deepgram.com");

private final String base;

private final String production;

private final String agent;

Environment(String base, String production, String agent) {
private final String agentRest;

Environment(String base, String production, String agent, String agentRest) {
this.base = base;
this.production = production;
this.agent = agent;
this.agentRest = agentRest;
}

public String getBaseURL() {
Expand All @@ -34,6 +37,10 @@ public String getAgentURL() {
return this.agent;
}

public String getAgentRestURL() {
return this.agentRest;
}

public static Builder custom() {
return new Builder();
}
Expand All @@ -45,6 +52,8 @@ public static class Builder {

private String agent;

private String agentRest;

public Builder base(String base) {
this.base = base;
return this;
Expand All @@ -60,8 +69,13 @@ public Builder agent(String agent) {
return this;
}

public Builder agentRest(String agentRest) {
this.agentRest = agentRest;
return this;
}

public Environment build() {
return new Environment(base, production, agent);
return new Environment(base, production, agent, agentRest);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public CompletableFuture<DeepgramApiHttpResponse<AgentThinkModelsV1Response>> li
* Retrieves the available think models that can be used for AI agent processing
*/
public CompletableFuture<DeepgramApiHttpResponse<AgentThinkModelsV1Response>> list(RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentURL())
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentRestURL())
.newBuilder()
.addPathSegments("v1/agent/settings/think/models");
if (requestOptions != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list() {
* Retrieves the available think models that can be used for AI agent processing
*/
public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list(RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentURL())
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAgentRestURL())
.newBuilder()
.addPathSegments("v1/agent/settings/think/models");
if (requestOptions != null) {
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/com/deepgram/ClientBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ void testDefaultEnvironment() {
}

@Test
@DisplayName("accepts AGENT environment")
@DisplayName("accepts an agent-shaped environment")
void testAgentEnvironment() {
Environment agent = Environment.custom()
.base("https://agent.deepgram.com")
.agent("wss://agent.deepgram.com")
.production("wss://api.deepgram.com")
.agentRest("https://agent.deepgram.com")
.build();

DeepgramClient client = DeepgramClient.builder()
.apiKey("test-key")
.environment(Environment.AGENT)
.environment(agent)
.build();

assertThat(client).isNotNull();
Expand Down
17 changes: 13 additions & 4 deletions src/test/java/com/deepgram/core/EnvironmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,34 @@ void testProductionUrl() {
}

@Nested
@DisplayName("AGENT environment")
@DisplayName("Agent-shaped custom environment")
class AgentEnvironment {

private Environment agent() {
return Environment.custom()
.base("https://agent.deepgram.com")
.agent("wss://agent.deepgram.com")
.production("wss://api.deepgram.com")
.agentRest("https://agent.deepgram.com")
.build();
}

@Test
@DisplayName("base URL points to agent.deepgram.com")
void testBaseUrl() {
assertThat(Environment.AGENT.getBaseURL()).isEqualTo("https://agent.deepgram.com");
assertThat(agent().getBaseURL()).isEqualTo("https://agent.deepgram.com");
}

@Test
@DisplayName("agent URL points to wss://agent.deepgram.com")
void testAgentUrl() {
assertThat(Environment.AGENT.getAgentURL()).isEqualTo("wss://agent.deepgram.com");
assertThat(agent().getAgentURL()).isEqualTo("wss://agent.deepgram.com");
}

@Test
@DisplayName("production URL uses wss://api.deepgram.com")
void testProductionUrl() {
assertThat(Environment.AGENT.getProductionURL()).isEqualTo("wss://api.deepgram.com");
assertThat(agent().getProductionURL()).isEqualTo("wss://api.deepgram.com");
}
}

Expand Down
Loading