Skip to content

Commit

Permalink
feat: Add executions routes
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Aug 29, 2024
1 parent cf114f4 commit 9fc08a8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 27 deletions.
31 changes: 15 additions & 16 deletions sdks/ts/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAI } from "openai";
// import { Chat, Completions } from "openai/resources/index";
import { Chat, Completions } from "openai/resources/index";
import typia, { tags } from "typia";

// import { AgentsManager } from "./managers/agent";
Expand All @@ -11,11 +11,12 @@ import typia, { tags } from "typia";
import { AgentsRoutes } from "./agents";
import { JulepApiClient } from "./api";
import { JULEP_API_KEY, JULEP_API_URL } from "./env";
// import { patchCreate } from "./utils/openaiPatch";
import { patchCreate } from "./utils/openaiPatch";
import { UsersRoutes } from "./users";
import { SessionsRoutes } from "./sessions";
import { TasksRoutes } from "./tasks";
import { DocsRoutes } from "./docs";
import { ExecutionsRoutes } from "./executions";

interface ClientOptions {
apiKey?: string;
Expand Down Expand Up @@ -69,18 +70,16 @@ export class Client {
// this.memories = new MemoriesManager(this._apiClient);
// this.tools = new ToolsManager(this._apiClient);
this.agents = new AgentsRoutes(this._apiClient)
this.users = new UsersRoutes(this._apiClient)
this.sessions = new SessionsRoutes(this._apiClient)
this.tasks = new TasksRoutes(this._apiClient)
this.executions = new ExecutionsRoutes(this._apiClient)
this.docs = new DocsRoutes(this._apiClient)
// this.chat = this._openaiClient.chat;
// patchCreate(this.chat.completions, this.chat);
// this.completions = this._openaiClient.completions;
// patchCreate(this.completions);
}

get apiClient() {
return this._apiClient
this.sessions = new SessionsRoutes(this._apiClient)
this.users = new UsersRoutes(this._apiClient)

this.chat = this._openaiClient.chat;
patchCreate(this.chat.completions, this.chat);
this.completions = this._openaiClient.completions;
patchCreate(this.completions);
}

/**
Expand All @@ -105,7 +104,7 @@ export class Client {
* Manager for interacting with documents.
* Enables document management including creation, update, and deletion.
*/
// docs: DocsManager;
docs: DocsRoutes;

/**
* Manager for interacting with memories.
Expand All @@ -123,13 +122,13 @@ export class Client {
* OpenAI Chat API.
* This is patched to enhance functionality and ensure compatibility with Julep API.
*/
// chat: Chat;
chat: Chat;

/**
* OpenAI Completions API.
* Enhanced with custom patches for improved integration and usage within Julep.
*/
// completions: Completions;
completions: Completions;
tasks: TasksRoutes;
docs: DocsRoutes;
executions: ExecutionsRoutes;
}
50 changes: 50 additions & 0 deletions sdks/ts/src/executions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Common_limit, Common_offset, Common_uuid, Executions_TaskTokenResumeExecutionRequest, Executions_UpdateExecutionRequest } from "./api";
import { BaseRoutes } from "./baseRoutes";

export class ExecutionsRoutes extends BaseRoutes {
async resume({
taskToken,
requestBody,
}: {
taskToken: string;
requestBody: Executions_TaskTokenResumeExecutionRequest;
}) {
return await this.apiClient.default.executionsRouteResumeWithTaskToken({ taskToken, requestBody })
}

async get({
id,
}: {
id: Common_uuid;
}) {
return await this.apiClient.default.executionsRouteGet({ id })
}

async update({
id,
requestBody,
}: {
id: Common_uuid;
requestBody: Executions_UpdateExecutionRequest;
}) {
return await this.apiClient.default.executionsRouteUpdate({ id, requestBody })
}

async listTransitions({
id,
limit = 100,
offset,
sortBy = "created_at",
direction = "asc",
metadataFilter = "{}",
}: {
id: Common_uuid;
limit?: Common_limit;
offset: Common_offset;
sortBy?: "created_at" | "updated_at";
direction?: "asc" | "desc";
metadataFilter?: string;
}) {
return await this.apiClient.default.executionTransitionsRouteList({ id, limit, offset, sortBy, direction, metadataFilter })
}
}
12 changes: 1 addition & 11 deletions sdks/ts/src/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Common_limit, Common_offset, Common_uuid, Executions_CreateExecutionRequest, Executions_TaskTokenResumeExecutionRequest, Tasks_CreateTaskRequest, Tasks_PatchTaskRequest, Tasks_UpdateTaskRequest } from "./api";
import { Common_limit, Common_offset, Common_uuid, Executions_CreateExecutionRequest, Tasks_CreateTaskRequest, Tasks_PatchTaskRequest, Tasks_UpdateTaskRequest } from "./api";
import { BaseRoutes } from "./baseRoutes";

export class TasksRoutes extends BaseRoutes {
Expand Down Expand Up @@ -105,14 +105,4 @@ export class TasksRoutes extends BaseRoutes {
}) {
return await this.apiClient.default.taskExecutionsRouteList({ id, limit, offset, sortBy, direction, metadataFilter })
}

async resumeExecution({
taskToken,
requestBody,
}: {
taskToken: string;
requestBody: Executions_TaskTokenResumeExecutionRequest;
}) {
return await this.apiClient.default.executionsRouteResumeWithTaskToken({ taskToken, requestBody })
}
}

0 comments on commit 9fc08a8

Please sign in to comment.