diff --git a/package-lock.json b/package-lock.json index f8e53d3..e4d9716 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "agentkeepalive": "^4.6.0", "dotenv": "^16.5.0", - "openai": "5.20.2", + "openai": "6.3.0", "ws": "^8.18.2" }, "devDependencies": { @@ -5287,16 +5287,16 @@ } }, "node_modules/openai": { - "version": "5.20.2", - "resolved": "https://registry.npmjs.org/openai/-/openai-5.20.2.tgz", - "integrity": "sha512-ZeBIEazj6W/XOulMw92L8iU5FblQeM5IxjPRCZNVArNXsoF+bLPnS7B2X4O0JSmpCM+F5Gdajr6bn4nAUj4LFQ==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-6.3.0.tgz", + "integrity": "sha512-E6vOGtZvdcb4yXQ5jXvDlUG599OhIkb/GjBLZXS+qk0HF+PJReIldEc9hM8Ft81vn+N6dRdFRb7BZNK8bbvXrw==", "license": "Apache-2.0", "bin": { "openai": "bin/cli" }, "peerDependencies": { "ws": "^8.18.0", - "zod": "^3.23.8" + "zod": "^3.25 || ^4.0" }, "peerDependenciesMeta": { "ws": { diff --git a/package.json b/package.json index aeb6386..8139893 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "agentkeepalive": "^4.6.0", "dotenv": "^16.5.0", - "openai": "5.20.2", + "openai": "6.3.0", "ws": "^8.18.2" } } diff --git a/src/apis/chatkit.ts b/src/apis/chatkit.ts new file mode 100644 index 0000000..e36a7ae --- /dev/null +++ b/src/apis/chatkit.ts @@ -0,0 +1,163 @@ +import { ApiResource } from '../apiResource'; +import { createHeaders } from './createHeaders'; +import { finalResponse, initOpenAIClient, overrideConfig } from '../utils'; +import { ApiClientInterface } from '../_types/generalTypes'; +import { APIPromise, RequestOptions } from '../baseClient'; +import { + ChatKitUploadFileParams, + ChatKitUploadFileResponse, +} from 'openai/resources/beta/chatkit/chatkit'; +import { SessionCreateParams } from 'openai/resources/beta/chatkit/sessions'; +import { + ChatKitThread, + ChatSession, + ThreadDeleteResponse, + ThreadListItemsParams, + ThreadListParams, +} from 'openai/resources/beta/chatkit/threads'; + +export class ChatKit extends ApiResource { + sessions: ChatKitSessions; + threads: ChatKitThreads; + constructor(client: any) { + super(client); + this.sessions = new ChatKitSessions(client); + this.threads = new ChatKitThreads(client); + } + + uploadFile( + body: ChatKitUploadFileParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.uploadFile(body, opts); + return result as any; + } +} + +export class ChatKitSessions extends ApiResource { + create( + body: SessionCreateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.sessions + .create(body, opts) + .withResponse(); + return finalResponse(result); + } + + cancel( + sessionID: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.sessions + .cancel(sessionID, opts) + .withResponse(); + return finalResponse(result); + } +} + +export class ChatKitThreads extends ApiResource { + retrieve( + threadID: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.threads + .retrieve(threadID, opts) + .withResponse(); + return finalResponse(result); + } + + list( + query: ThreadListParams | null | undefined = {}, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.threads.list(query, opts); + return result as any; + } + delete( + threadID: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.threads + .delete(threadID, opts) + .withResponse(); + return finalResponse(result); + } + + listItems( + threadID: string, + query: ThreadListItemsParams | null | undefined = {}, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.beta.chatkit.threads.listItems( + threadID, + query, + opts + ); + return result as any; + } +} diff --git a/src/apis/index.ts b/src/apis/index.ts index 3dd4833..9cf88e7 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -35,3 +35,5 @@ export { Providers } from './providers'; export { Webhooks } from './webhooks'; export { MainRealtime } from './mainRealtime'; export { Conversations } from './conversations'; +export { Videos } from './videos'; +export { ChatKit } from './chatkit'; diff --git a/src/apis/mainRealtime.ts b/src/apis/mainRealtime.ts index bd48697..4f68c86 100644 --- a/src/apis/mainRealtime.ts +++ b/src/apis/mainRealtime.ts @@ -2,14 +2,22 @@ import { ClientSecretCreateParams } from 'openai/resources/realtime/client-secre import { ApiResource } from '../apiResource'; import { ApiClientInterface } from '../_types/generalTypes'; import { finalResponse, initOpenAIClient, overrideConfig } from '../utils'; -import { RequestOptions } from '../baseClient'; +import { APIPromise, RequestOptions } from '../baseClient'; import { createHeaders } from './createHeaders'; +import { + CallAcceptParams, + CallReferParams, + CallRejectParams, +} from 'openai/resources/realtime/calls'; export class MainRealtime extends ApiResource { clientSecrets: ClientSecrets; + calls: Calls; + constructor(client: any) { super(client); this.clientSecrets = new ClientSecrets(client); + this.calls = new Calls(client); } } @@ -38,3 +46,80 @@ export class ClientSecrets extends ApiResource { return finalResponse(result); } } + +export class Calls extends ApiResource { + constructor(client: any) { + super(client); + } + + accept( + callID: string, + body: CallAcceptParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.realtime.calls.accept(callID, body, opts); + return result as any; + } + + hangup( + callID: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.realtime.calls.hangup(callID, opts); + return result as any; + } + + refer( + callID: string, + body: CallReferParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.realtime.calls.refer(callID, body, opts); + return result as any; + } + + reject( + callID: string, + body: CallRejectParams | null | undefined = {}, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = OAIclient.realtime.calls.reject(callID, body, opts); + return result as any; + } +} diff --git a/src/apis/videos.ts b/src/apis/videos.ts new file mode 100644 index 0000000..43c6d14 --- /dev/null +++ b/src/apis/videos.ts @@ -0,0 +1,128 @@ +import { ApiResource } from '../apiResource'; +import { createHeaders } from './createHeaders'; +import { initOpenAIClient, overrideConfig } from '../utils'; +import { ApiClientInterface } from '../_types/generalTypes'; +import { APIPromise, RequestOptions } from '../baseClient'; +import { + Video, + VideoCreateParams, + VideoDeleteResponse, + VideoDownloadContentParams, + VideoListParams, + VideoRemixParams, +} from 'openai/resources/videos'; + +export class Videos extends ApiResource { + constructor(client: any) { + super(client); + } + + create( + body: VideoCreateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise