diff --git a/llumiverse b/llumiverse index bf5c53dbe..4059bad32 160000 --- a/llumiverse +++ b/llumiverse @@ -1 +1 @@ -Subproject commit bf5c53dbe973b73cbd09bbbfb1f53b7f58eda532 +Subproject commit 4059bad32c778ce0a571c8410b129a00bc910ec6 diff --git a/packages/client/src/BatchApi.ts b/packages/client/src/BatchApi.ts new file mode 100644 index 000000000..79a156249 --- /dev/null +++ b/packages/client/src/BatchApi.ts @@ -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> { + 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): Promise> { + 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> { + 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> { + 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 { + 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 + } + }); + } +} diff --git a/packages/client/src/EnvironmentsApi.ts b/packages/client/src/EnvironmentsApi.ts index 6be5e5c16..abd38af06 100644 --- a/packages/client/src/EnvironmentsApi.ts +++ b/packages/client/src/EnvironmentsApi.ts @@ -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) { diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 1ecd401a7..4cba81c88 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -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"; /** @@ -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; @@ -93,7 +94,7 @@ export class VertesiaClient extends AbstractFetchClient { }).withApiKey(token); } - static decodeEndpoints() {} + static decodeEndpoints() { } constructor( opts: VertesiaClientProps = { @@ -209,16 +210,16 @@ export class VertesiaClient extends AbstractFetchClient { 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, ); } @@ -312,6 +313,7 @@ export class VertesiaClient extends AbstractFetchClient { projects = new ProjectsApi(this); environments = new EnvironmentsApi(this); + batch = new BatchApi(this); interactions = new InteractionsApi(this); skills = new SkillsApi(this); prompts = new PromptsApi(this); diff --git a/packages/client/src/store/Batch.ts b/packages/client/src/store/Batch.ts new file mode 100644 index 000000000..904aa372c --- /dev/null +++ b/packages/client/src/store/Batch.ts @@ -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"); + } +} diff --git a/packages/client/src/store/index.ts b/packages/client/src/store/index.ts index 786ccd29e..45a8a5bc0 100644 --- a/packages/client/src/store/index.ts +++ b/packages/client/src/store/index.ts @@ -4,4 +4,5 @@ export * from "./FilesApi.js"; export * from "./ObjectsApi.js"; export * from "./TypesApi.js"; export * from "./WorkflowsApi.js"; +export * from "./Batch.js";