diff --git a/package-lock.json b/package-lock.json index b9f7888..7ff188c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "portkey-ai", - "version": "1.4.0-rc.1", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "portkey-ai", - "version": "1.4.0-rc.1", + "version": "1.4.0", "license": "MIT", "dependencies": { "agentkeepalive": "^4.5.0", diff --git a/package.json b/package.json index 3fc4be9..6c63a19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "portkey-ai", - "version": "1.4.0-rc.1", + "version": "1.4.0", "description": "Node client library for the Portkey API", "types": "dist/src/index.d.ts", "main": "dist/src/index.js", diff --git a/speech.mp3 b/speech.mp3 new file mode 100644 index 0000000..df852d6 Binary files /dev/null and b/speech.mp3 differ diff --git a/src/_types/generalTypes.ts b/src/_types/generalTypes.ts index afad375..e3bc544 100644 --- a/src/_types/generalTypes.ts +++ b/src/_types/generalTypes.ts @@ -29,6 +29,7 @@ export interface ApiClientInterface { cacheNamespace?: string | null | undefined; requestTimeout?: number | null | undefined; strictOpenAiCompliance?: boolean | null | undefined; + anthropicBeta?: string | null | undefined; } export interface APIResponseType { diff --git a/src/apiResource.ts b/src/apiResource.ts index 0a814b3..8aac057 100644 --- a/src/apiResource.ts +++ b/src/apiResource.ts @@ -5,13 +5,13 @@ export class ApiResource { protected post: Portkey["_post"] protected put: Portkey["_put"] protected get: Portkey["_get"] - protected delete: Portkey["_delete"] + protected deleteMethod: Portkey["_delete"] constructor(client: Portkey) { this.client = client this.post = client._post.bind(client) this.put = client._put.bind(client) this.get = client._get.bind(client) - this.delete = client._delete.bind(client) + this.deleteMethod = client._delete.bind(client) // delete is a reserved word } } \ No newline at end of file diff --git a/src/apis/admin.ts b/src/apis/admin.ts index dba0e00..7082f94 100644 --- a/src/apis/admin.ts +++ b/src/apis/admin.ts @@ -3,12 +3,11 @@ import { APIResponseType, ApiClientInterface } from "../_types/generalTypes"; import { APIPromise, RequestOptions } from "../baseClient"; import { createHeaders } from "./createHeaders"; -export interface UsersRetrieveParams { +export interface UsersRetrieveParams{ userId?: string; } -export interface UsersRetrieveAllParams { - userId?: string; +export interface UsersRetrieveAllParams{ pageSize?: number; currentPage?: number; email?: string; @@ -24,6 +23,7 @@ export interface UsersRetrieveResponse extends APIResponseType { email?: string, created_at?: Date, last_updated_at?: Date + workspace_ids?: string[] } export interface UsersRetrieveAllResponse extends APIResponseType { @@ -32,14 +32,15 @@ export interface UsersRetrieveAllResponse extends APIResponseType { data?: UsersRetrieveResponse[] } -export interface UsersUpdateParams extends APIResponseType { +export interface UsersUpdateParams{ userId?: string, - role?: string, + role?: "admin" | "manager" | "member", } -export interface UserInviteParams extends APIResponseType { +export interface UserInviteParams{ email?: string, - role?: string + role?: string, + workspaces?: Record[] } export interface UserInviteResponse extends APIResponseType { @@ -47,7 +48,7 @@ export interface UserInviteResponse extends APIResponseType { invite_link?: string, } -export interface UserInviteRetrieveParams extends APIResponseType { +export interface UserInviteRetrieveParams{ inviteId?: string, } @@ -63,7 +64,7 @@ export interface UserInviteRetrieveResponse extends APIResponseType { invited_by?: string } -export interface UserInviteRetrieveAllParams extends APIResponseType { +export interface UserInviteRetrieveAllParams{ email?: string, role?: string, status?: string @@ -77,11 +78,11 @@ export interface UserInviteRetrieveAllResponse extends APIResponseType { data?: UserInviteRetrieveResponse[] } -export interface UserInviteRemoveParams extends APIResponseType { +export interface UserInviteRemoveParams { inviteId?: string, } -export interface WorkspacesCreateParams extends APIResponseType { +export interface WorkspacesCreateParams{ name?: string, description?: string, defaults?: Record, @@ -91,8 +92,8 @@ export interface WorkspacesRetrieveParams { workspaceId?: string; } export interface WorkspacesRetrieveAllParams { - pageSize?: number; - currentPage?: number; + page_size?: number; + current_page?: number; } export interface WorkspacesCreateResponse extends APIResponseType { @@ -102,7 +103,8 @@ export interface WorkspacesCreateResponse extends APIResponseType { description?: string, created_at?: Date, last_updated_at?: Date, - defaults?: Record + defaults?: Record, + users?: Record[], } export interface WorkspacesRetrieveResponse extends APIResponseType { id?: string, @@ -119,32 +121,43 @@ export interface WorkspacesRetrieveAllResponse extends APIResponseType { object?: string, data?: WorkspacesRetrieveResponse[] } -export interface WorkspacesUpdateParams extends APIResponseType { +export interface WorkspacesUpdateParams{ workspaceId?: string, name?: string, description?: string, defaults?: Record, } -export interface WorkspacesRemoveParams extends APIResponseType { +export interface WorkspacesUpdateResponse extends APIResponseType { + id?: string, + slug?: string, + name?: string, + description?: string, + created_at?: Date, + last_updated_at?: Date, + defaults?: Record, + object?: string, +} + +export interface WorkspacesRemoveParams{ workspaceId?: string; name?: string; } -export interface WorkspaceMemberAddParams extends APIResponseType { +export interface WorkspaceMemberAddParams{ workspaceId?: string, - users?: Record[], + users?: { id: string, role: "member" | "admin" }[], } -export interface WorkspaceMemberRetrieveParams extends APIResponseType { +export interface WorkspaceMemberRetrieveParams{ workspaceId?: string, userId?: string, } -export interface WorkspaceMemberRetrieveAllParams extends APIResponseType { +export interface WorkspaceMemberRetrieveAllParams { workspaceId?: string, - pageSize?: number, - currentPage?: number, + page_size?: number, + current_page?: number, email?: string, - role?: string, + role?: "admin" | "manager" | "member", } export interface WorkspaceMemberRetrieveResponse extends APIResponseType { object?: string, @@ -162,11 +175,11 @@ export interface WorkspaceMemberRetrieveAllResponse extends APIResponseType { object?: string, data?: WorkspaceMemberRetrieveResponse[] } -export interface WorkspaceMemberRemoveParams extends APIResponseType { +export interface WorkspaceMemberRemoveParams{ workspaceId?: string, userId?: string, } -export interface WorkspaceMemberUpdateParams extends APIResponseType { +export interface WorkspaceMemberUpdateParams{ workspaceId?: string, userId?: string, role?: "admin" | "member", @@ -258,7 +271,7 @@ export class Users extends ApiResource { if (params){ this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.delete(`/admin/users/${userId}`, { body, ...opts }); + const response = this.deleteMethod(`/admin/users/${userId}`, { body, ...opts }); return response; } @@ -267,6 +280,7 @@ export class Users extends ApiResource { export class Invites extends ApiResource { + create( _body: UserInviteParams, params?: ApiClientInterface, @@ -308,7 +322,7 @@ export class Invites extends ApiResource { return response; } - remove( + delete( _body: UserInviteRemoveParams, params?: ApiClientInterface, opts?: RequestOptions @@ -318,7 +332,7 @@ export class Invites extends ApiResource { if (params){ this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.delete(`/admin/users/invites/${inviteId}`, { body, ...opts }); + const response = this.deleteMethod(`/admin/users/invites/${inviteId}`, { body, ...opts }); return response; } @@ -375,18 +389,18 @@ export class Workspaces extends ApiResource { _body: WorkspacesUpdateParams, params?: ApiClientInterface, opts?: RequestOptions - ): APIPromise { + ): APIPromise { const body = _body; const workspaceId = _body.workspaceId; delete body.workspaceId; if (params) { this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.put(`/admin/workspaces/${workspaceId}`, { body, ...opts }); + const response = this.put(`/admin/workspaces/${workspaceId}`, { body, ...opts }); return response; } - remove( + delete( _body: WorkspacesRemoveParams, params?: ApiClientInterface, opts?: RequestOptions @@ -396,14 +410,14 @@ export class Workspaces extends ApiResource { if (params){ this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.delete(`/admin/workspaces/${workspaceId}`, { body, ...opts }); + const response = this.deleteMethod(`/admin/workspaces/${workspaceId}`, { body, ...opts }); return response; } } export class Member extends ApiResource { - create( + add( _body: WorkspaceMemberAddParams, params?: ApiClientInterface, opts?: RequestOptions @@ -453,12 +467,12 @@ export class Member extends ApiResource { opts?: RequestOptions ): APIPromise { const body = _body; - const workspaceId = _body.workspaceId; - const userId = _body.userId; + const workspaceId = body.workspaceId; + const userId = body.userId; if (params){ this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.delete(`/admin/workspaces/${workspaceId}/users/${userId}`, { body, ...opts }); + const response = this.deleteMethod(`/admin/workspaces/${workspaceId}/users/${userId}`, { body, ...opts }); return response; } update( @@ -467,7 +481,7 @@ export class Member extends ApiResource { opts?: RequestOptions ): APIPromise { const body = _body; - const workspaceId = _body.workspaceId; + const workspaceId = body.workspaceId; const userId = _body.userId; delete body.workspaceId; if (params) { diff --git a/src/apis/betaChat.ts b/src/apis/betaChat.ts index 998474f..57ee776 100644 --- a/src/apis/betaChat.ts +++ b/src/apis/betaChat.ts @@ -13,7 +13,7 @@ import { ChatCompletionStreamingToolRunnerParams, } from "openai/lib/ChatCompletionStreamingRunner"; import { ChatCompletionParseParams } from "openai/resources/beta/chat/completions"; -import { ExtractParsedContentFromParams } from "openai/lib/parser"; + export class BetaChat extends ApiResource { completions: Completions; @@ -26,7 +26,7 @@ export class BetaChat extends ApiResource { export class Completions extends ApiResource { - async parse> + async parse ( _body: Params, params?: ApiClientInterface, diff --git a/src/apis/chatCompletions.ts b/src/apis/chatCompletions.ts index 1f6cf95..32a0ebb 100644 --- a/src/apis/chatCompletions.ts +++ b/src/apis/chatCompletions.ts @@ -71,12 +71,6 @@ interface Usage { [key: string]: any; } -interface FunctionType { - arguments?: string; - name?: string; - [key: string]: any; - } - interface Message { role: string; content: string; diff --git a/src/apis/moderations.ts b/src/apis/moderations.ts index df1fc43..ee1d2e4 100644 --- a/src/apis/moderations.ts +++ b/src/apis/moderations.ts @@ -1,10 +1,13 @@ -import { ModerationCreateParams } from "openai/resources"; import { ApiClientInterface } from "../_types/generalTypes"; import { ApiResource } from "../apiResource"; import { RequestOptions } from "../baseClient"; import { finalResponse, initOpenAIClient, overrideConfig } from "../utils"; import { createHeaders } from "./createHeaders"; +export interface ModerationCreateParams { + input: string | Array; + model?: any ; +} export class Moderations extends ApiResource{ async create(_body: ModerationCreateParams, diff --git a/src/apis/uploads.ts b/src/apis/uploads.ts index 46d369a..6141902 100644 --- a/src/apis/uploads.ts +++ b/src/apis/uploads.ts @@ -3,9 +3,12 @@ import { ApiResource } from "../apiResource"; import { RequestOptions } from "../baseClient"; import { finalResponse, initOpenAIClient, overrideConfig } from "../utils"; import { createHeaders } from "./createHeaders"; -import { UploadCompleteParams } from "openai/resources"; import { Uploadable } from "openai/uploads"; +export interface UploadCompleteParams { + part_ids: Array; + md5?: string; +} export class Uploads extends ApiResource { parts: Parts diff --git a/src/baseClient.ts b/src/baseClient.ts index 3807aea..a915ee5 100644 --- a/src/baseClient.ts +++ b/src/baseClient.ts @@ -120,10 +120,10 @@ export abstract class ApiClient { portkeyHeaders: Record private fetch: Fetch; - constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, cacheNamespace, requestTimeout, strictOpenAiCompliance }: ApiClientInterface) { + constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, cacheNamespace, requestTimeout, strictOpenAiCompliance, anthropicBeta }: ApiClientInterface) { this.apiKey = apiKey ?? ""; this.baseURL = baseURL ?? ""; - this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, requestTimeout, strictOpenAiCompliance }) + this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, huggingfaceBaseUrl, forwardHeaders, requestTimeout, strictOpenAiCompliance, anthropicBeta }) this.portkeyHeaders = this.defaultHeaders() this.fetch = fetch; this.responseHeaders = {} diff --git a/src/client.ts b/src/client.ts index c66d6b5..e3cae3c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -35,6 +35,7 @@ export class Portkey extends ApiClient { requestTimeout?: number | null | undefined; cacheNamespace?: string | null | undefined; strictOpenAiCompliance?: boolean | null | undefined; + anthropicBeta?: string | null | undefined; constructor({ apiKey = readEnv("PORTKEY_API_KEY") ?? null, baseURL = readEnv("PORTKEY_BASE_URL") ?? null, @@ -64,6 +65,7 @@ export class Portkey extends ApiClient { cacheNamespace, requestTimeout, strictOpenAiCompliance, + anthropicBeta, }: ApiClientInterface) { super({ @@ -95,6 +97,7 @@ export class Portkey extends ApiClient { forwardHeaders, requestTimeout, strictOpenAiCompliance, + anthropicBeta, }); this.apiKey = apiKey; @@ -127,6 +130,7 @@ export class Portkey extends ApiClient { this.forwardHeaders = forwardHeaders; this.requestTimeout = requestTimeout; this.strictOpenAiCompliance = strictOpenAiCompliance; + this.anthropicBeta = anthropicBeta; } completions: API.Completions = new API.Completions(this); diff --git a/src/version.ts b/src/version.ts index f4c159d..fabcbfb 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = "1.4.0-rc.1"; \ No newline at end of file +export const VERSION = "1.4.0"; \ No newline at end of file