Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
90 changes: 90 additions & 0 deletions packages/client/src/BatchApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import type { BatchJob, CreateBatchJobOptions, ListBatchJobsOptions, ListBatchJobsResult } from "@llumiverse/common";
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";

export default class BatchApi extends ApiTopic {
constructor(parent: ClientBase) {
super(parent, "/api/v1/batch");
}

/**
* List batch jobs for a given environment
* @param envId The environment ID
* @param options Optional list options (pageSize, pageToken, filter)
*/
list(envId: string, options?: ListBatchJobsOptions): Promise<ListBatchJobsResult<any, any>> {
return super.get('/', {
query: {
envId,
...options
}
});
}

/**
* Create a new batch job
* @param envId The environment ID
* @param options Batch job creation options
*/
create(envId: string, options: CreateBatchJobOptions<any, any>): Promise<BatchJob<any, any>> {
return this.post('/', {
payload: {
envId,
...options
}
});
}

/**
* Get details of a specific batch job
* @param batchId The batch job ID
* @param envId The environment ID
*/
retrieve(batchId: string, envId: string): Promise<BatchJob<any, any>> {
return super.get('/' + batchId, {
query: { envId }
});
}

/**
* Cancel a running batch job
* @param batchId The batch job ID
* @param envId The environment ID
*/
cancel(batchId: string, envId: string): Promise<BatchJob<any, any>> {
return this.post('/' + batchId + '/cancel', {
query: { envId }
});
}

/**
* Delete a batch job
* @param batchId The batch job ID
* @param envId The environment ID
*/
remove(batchId: string, envId: string): Promise<void> {
return super.delete('/' + batchId, {
query: { envId }
});
}

/**
* Test batch embeddings with a given environment
* @param envId The environment ID to test with
* @param model Optional model to use (defaults to gemini-embedding-001)
* @returns Batch job details
*/
testBatchEmbeddings(envId: string, model?: string): Promise<{
success: boolean;
job_id: string;
job_status: string;
job_type: string;
model: string;
}> {
return this.post('/test-batch-embeddings', {
payload: {
envId,
model
}
});
}
}
2 changes: 1 addition & 1 deletion packages/client/src/EnvironmentsApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExecutionEnvironment, ExecutionEnvironmentCreatePayload, ExecutionEnvironmentRef, ExecutionEnvironmentUpdatePayload, LoadBalancingEnvConfig, MediatorEnvConfig } from "@vertesia/common";
import type { AIModel, EmbeddingsOptions, EmbeddingsResult, ModelSearchPayload } from "@llumiverse/common";
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
import { ExecutionEnvironment, ExecutionEnvironmentCreatePayload, ExecutionEnvironmentRef, ExecutionEnvironmentUpdatePayload, LoadBalancingEnvConfig, MediatorEnvConfig } from "@vertesia/common";

export default class EnvironmentsApi extends ApiTopic {
constructor(parent: ClientBase) {
Expand Down
34 changes: 18 additions & 16 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import AccountsApi from "./AccountsApi.js";
import AnalyticsApi from "./AnalyticsApi.js";
import { ApiKeysApi } from "./ApiKeysApi.js";
import AppsApi from "./AppsApi.js";
import BatchApi from "./BatchApi.js";
import CommandsApi from "./CommandsApi.js";
import EnvironmentsApi from "./EnvironmentsApi.js";
import { IamApi } from "./IamApi.js";
import InteractionsApi from "./InteractionsApi.js";
import ProjectsApi from "./ProjectsApi.js";
import SkillsApi from "./SkillsApi.js";
import PromptsApi from "./PromptsApi.js";
import { RefsApi } from "./RefsApi.js";
import { RunsApi } from "./RunsApi.js";
import SkillsApi from "./SkillsApi.js";
import { ZenoClient } from "./store/client.js";
import { VERSION, VERSION_HEADER } from "./store/version.js";
import TrainingApi from "./TrainingApi.js";
import UsersApi from "./UsersApi.js";
import { VERSION, VERSION_HEADER } from "./store/version.js";


/**
Expand All @@ -39,9 +40,9 @@ export type VertesiaClientProps = {
* @since 0.52.0
*/
site?:
| "api.vertesia.io"
| "api-preview.vertesia.io"
| "api-staging.vertesia.io";
| "api.vertesia.io"
| "api-preview.vertesia.io"
| "api-staging.vertesia.io";
serverUrl?: string;
storeUrl?: string;
tokenServerUrl?: string;
Expand Down Expand Up @@ -93,7 +94,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
}).withApiKey(token);
}

static decodeEndpoints() {}
static decodeEndpoints() { }

constructor(
opts: VertesiaClientProps = {
Expand Down Expand Up @@ -209,16 +210,16 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
return this.withAuthCallback(
apiKey
? async () => {
if (!isApiKey(apiKey)) {
return `Bearer ${apiKey}`;
}

if (isTokenExpired(this._jwt)) {
const jwt = await this.getAuthToken(apiKey);
this._jwt = jwt.token;
}
return `Bearer ${this._jwt}`;
}
if (!isApiKey(apiKey)) {
return `Bearer ${apiKey}`;
}

if (isTokenExpired(this._jwt)) {
const jwt = await this.getAuthToken(apiKey);
this._jwt = jwt.token;
}
return `Bearer ${this._jwt}`;
}
: undefined,
);
}
Expand Down Expand Up @@ -312,6 +313,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {

projects = new ProjectsApi(this);
environments = new EnvironmentsApi(this);
batch = new BatchApi(this);
interactions = new InteractionsApi(this);
skills = new SkillsApi(this);
prompts = new PromptsApi(this);
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/store/Batch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";

export class BatchApi extends ApiTopic {

constructor(parent: ClientBase) {
super(parent, "/api/v1/batch");
}
}
1 change: 1 addition & 0 deletions packages/client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from "./FilesApi.js";
export * from "./ObjectsApi.js";
export * from "./TypesApi.js";
export * from "./WorkflowsApi.js";
export * from "./Batch.js";