Skip to content

Commit

Permalink
🌿 Fern Regeneration -- May 22, 2024 (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 22, 2024
1 parent c032a1d commit 196eb9c
Show file tree
Hide file tree
Showing 15 changed files with 1,035 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

API reference documentation is available [here](https://www.assemblyai.com/docs/).

## Requirements

Java 8+

## Installation

### Gradle
Expand Down Expand Up @@ -49,10 +53,9 @@ AssemblyAI aai = AssemblyAI.builder()
.apiKey("YOUR_API_KEY")
.build();

TranscriptResponse transcriptResponse =
aai.transcript().get("transcript-id");
Transcript transcript = aai.transcripts().get("transcript-id");

System.out.printlin("Received response!" + transcriptResponse);
System.out.printlin("Received response!" + transcript);
```

### Handling Errors
Expand Down
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ publishing {
maven(MavenPublication) {
groupId = 'com.assemblyai'
artifactId = 'assemblyai-java'
version = '1.1.1'
version = '1.1.2'
from components.java
pom {
scm {
connection = 'scm:git:git://github.com/AssemblyAI/assemblyai-java-sdk.git'
developerConnection = 'scm:git:git://github.com/AssemblyAI/assemblyai-java-sdk.git'
url = 'https://github.com/AssemblyAI/assemblyai-java-sdk'
}
}
}
}
repositories {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/assemblyai/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ private ClientOptions(
this.environment = environment;
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.putAll(Map.of(
"X-Fern-SDK-Name",
"com.assemblyai.fern:api-sdk",
"X-Fern-SDK-Version",
"1.0.9",
"X-Fern-Language",
"JAVA"));
this.headers.putAll(new HashMap<String, String>() {
{
put("X-Fern-SDK-Name", "com.assemblyai.fern:api-sdk");
put("X-Fern-SDK-Version", "1.0.9");
put("X-Fern-Language", "JAVA");
}
});
this.headerSuppliers = headerSuppliers;
this.httpClient = httpClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class FilesClient {
protected final ClientOptions clientOptions;
Expand All @@ -24,14 +25,14 @@ public FilesClient(ClientOptions clientOptions) {
}

/**
* Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
* Upload a media file to AssemblyAI's servers.
*/
public UploadedFile upload(byte[] request) {
return upload(request, null);
}

/**
* Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
* Upload a media file to AssemblyAI's servers.
*/
public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
Expand All @@ -51,12 +52,14 @@ public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), UploadedFile.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UploadedFile.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
47 changes: 31 additions & 16 deletions src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class LemurClient {
protected final ClientOptions clientOptions;
Expand Down Expand Up @@ -66,33 +67,38 @@ public LemurTaskResponse task(LemurTaskParams request, RequestOptions requestOpt
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), LemurTaskResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurTaskResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
* Custom Summary allows you to distill a piece of audio into a few impactful sentences.
* You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
*/
public LemurSummaryResponse summary() {
return summary(LemurSummaryParams.builder().build());
}

/**
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
* Custom Summary allows you to distill a piece of audio into a few impactful sentences.
* You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
*/
public LemurSummaryResponse summary(LemurSummaryParams request) {
return summary(request, null);
}

/**
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
* Custom Summary allows you to distill a piece of audio into a few impactful sentences.
* You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
*/
public LemurSummaryResponse summary(LemurSummaryParams request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
Expand All @@ -118,26 +124,30 @@ public LemurSummaryResponse summary(LemurSummaryParams request, RequestOptions r
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), LemurSummaryResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurSummaryResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts.
* The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
*/
public LemurQuestionAnswerResponse questionAnswer(LemurQuestionAnswerParams request) {
return questionAnswer(request, null);
}

/**
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts.
* The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
*/
public LemurQuestionAnswerResponse questionAnswer(
LemurQuestionAnswerParams request, RequestOptions requestOptions) {
Expand All @@ -164,12 +174,14 @@ public LemurQuestionAnswerResponse questionAnswer(
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), LemurQuestionAnswerResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurQuestionAnswerResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -216,12 +228,14 @@ public LemurActionItemsResponse actionItems(LemurActionItemsParams request, Requ
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), LemurActionItemsResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LemurActionItemsResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -257,13 +271,14 @@ public PurgeLemurRequestDataResponse purgeRequestData(String requestId, RequestO
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(
response.body().string(), PurgeLemurRequestDataResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurgeLemurRequestDataResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class RealtimeClient {
protected final ClientOptions clientOptions;
Expand Down Expand Up @@ -60,13 +61,14 @@ public RealtimeTemporaryTokenResponse createTemporaryToken(
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(
response.body().string(), RealtimeTemporaryTokenResponse.class);
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RealtimeTemporaryTokenResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
ObjectMappers.JSON_MAPPER.readValue(
responseBody != null ? responseBody.string() : "{}", Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Loading

0 comments on commit 196eb9c

Please sign in to comment.