Skip to content

Commit

Permalink
feat: post-EA changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeocodes committed Aug 29, 2024
1 parent ff05cf6 commit 2a205d7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/lib/types/GetModelsResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ type Model = {
canonical_name: string;
architecture: string;
languages?: string[];
language?: string;
version: string;
uuid: string;
batch?: boolean;
Expand All @@ -12,7 +11,6 @@ type Model = {
metadata?: {
accent: string;
color: string;
gender: string;
image: string;
sample: string;
};
Expand Down
3 changes: 3 additions & 0 deletions src/lib/types/GetModelsSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface GetModelsSchema extends Record<string, unknown> {
include_outdated?: boolean;
}
1 change: 1 addition & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./DeepgramResponse";
export * from "./DeepgramSource";
export * from "./Fetch";
export * from "./GetModelsResponse";
export * from "./GetModelsSchema";
export * from "./GetProjectBalancesResponse";
export * from "./GetProjectInvitesResponse";
export * from "./GetProjectKeysResponse";
Expand Down
4 changes: 3 additions & 1 deletion src/packages/ManageRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
GetTokenDetailsResponse,
GetModelsResponse,
GetModelResponse,
GetModelsSchema,
} from "../lib/types";
import { AbstractRestClient } from "./AbstractRestClient";

Expand Down Expand Up @@ -780,10 +781,11 @@ export class ManageRestClient extends AbstractRestClient {
*/
async getAllModels(
projectId: string,
options: GetModelsSchema = {},
endpoint = ":version/projects/:projectId/models"
): Promise<DeepgramResponse<GetModelsResponse>> {
try {
const requestUrl = this.getRequestUrl(endpoint, { projectId });
const requestUrl = this.getRequestUrl(endpoint, { projectId }, options);
const result: GetModelsResponse = await this.get(requestUrl).then((result) => result.json());

return { result, error: null };
Expand Down
14 changes: 11 additions & 3 deletions src/packages/ModelsRestClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { isDeepgramError } from "../lib/errors";
import { DeepgramResponse, GetModelResponse, GetModelsResponse } from "../lib/types";
import {
DeepgramResponse,
GetModelResponse,
GetModelsResponse,
GetModelsSchema,
} from "../lib/types";
import { AbstractRestClient } from "./AbstractRestClient";

/**
Expand Down Expand Up @@ -30,9 +35,12 @@ export class ModelsRestClient extends AbstractRestClient {
* }
* ```
*/
async getAll(endpoint = ":version/models"): Promise<DeepgramResponse<GetModelsResponse>> {
async getAll(
endpoint = ":version/models",
options: GetModelsSchema = {}
): Promise<DeepgramResponse<GetModelsResponse>> {
try {
const requestUrl = this.getRequestUrl(endpoint);
const requestUrl = this.getRequestUrl(endpoint, {}, options);
const result: GetModelsResponse = await this.get(requestUrl).then((result) => result.json());

return { result, error: null };
Expand Down

0 comments on commit 2a205d7

Please sign in to comment.