Skip to content

Commit

Permalink
merge: userInvite
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-pareek committed Sep 26, 2024
2 parents ee663fb + 1c4731a commit 3b77d72
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 55 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Binary file added speech.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/apiResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
88 changes: 51 additions & 37 deletions src/apis/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -32,22 +32,23 @@ 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<string,unknown>[]
}

export interface UserInviteResponse extends APIResponseType {
id?: string,
invite_link?: string,
}

export interface UserInviteRetrieveParams extends APIResponseType {
export interface UserInviteRetrieveParams{
inviteId?: string,
}

Expand All @@ -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
Expand All @@ -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<string, any>,
Expand All @@ -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 {
Expand All @@ -102,7 +103,8 @@ export interface WorkspacesCreateResponse extends APIResponseType {
description?: string,
created_at?: Date,
last_updated_at?: Date,
defaults?: Record<string, any>
defaults?: Record<string, any>,
users?: Record<string, string>[],
}
export interface WorkspacesRetrieveResponse extends APIResponseType {
id?: string,
Expand All @@ -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<string, any>,
}

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<string, any>,
object?: string,
}

export interface WorkspacesRemoveParams{
workspaceId?: string;
name?: string;

}
export interface WorkspaceMemberAddParams extends APIResponseType {
export interface WorkspaceMemberAddParams{
workspaceId?: string,
users?: Record<string, string>[],
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,
Expand All @@ -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",
Expand Down Expand Up @@ -258,7 +271,7 @@ export class Users extends ApiResource {
if (params){
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.delete<any>(`/admin/users/${userId}`, { body, ...opts });
const response = this.deleteMethod<any>(`/admin/users/${userId}`, { body, ...opts });
return response;
}

Expand All @@ -267,6 +280,7 @@ export class Users extends ApiResource {

export class Invites extends ApiResource {


create(
_body: UserInviteParams,
params?: ApiClientInterface,
Expand Down Expand Up @@ -308,7 +322,7 @@ export class Invites extends ApiResource {
return response;
}

remove(
delete(
_body: UserInviteRemoveParams,
params?: ApiClientInterface,
opts?: RequestOptions
Expand All @@ -318,7 +332,7 @@ export class Invites extends ApiResource {
if (params){
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.delete<any>(`/admin/users/invites/${inviteId}`, { body, ...opts });
const response = this.deleteMethod<any>(`/admin/users/invites/${inviteId}`, { body, ...opts });
return response;
}

Expand Down Expand Up @@ -375,18 +389,18 @@ export class Workspaces extends ApiResource {
_body: WorkspacesUpdateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<any> {
): APIPromise<WorkspacesUpdateResponse> {
const body = _body;
const workspaceId = _body.workspaceId;
delete body.workspaceId;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.put<any>(`/admin/workspaces/${workspaceId}`, { body, ...opts });
const response = this.put<WorkspacesUpdateResponse>(`/admin/workspaces/${workspaceId}`, { body, ...opts });
return response;
}

remove(
delete(
_body: WorkspacesRemoveParams,
params?: ApiClientInterface,
opts?: RequestOptions
Expand All @@ -396,14 +410,14 @@ export class Workspaces extends ApiResource {
if (params){
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.delete<any>(`/admin/workspaces/${workspaceId}`, { body, ...opts });
const response = this.deleteMethod<any>(`/admin/workspaces/${workspaceId}`, { body, ...opts });
return response;
}

}
export class Member extends ApiResource {

create(
add(
_body: WorkspaceMemberAddParams,
params?: ApiClientInterface,
opts?: RequestOptions
Expand Down Expand Up @@ -453,12 +467,12 @@ export class Member extends ApiResource {
opts?: RequestOptions
): APIPromise<any> {
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<any>(`/admin/workspaces/${workspaceId}/users/${userId}`, { body, ...opts });
const response = this.deleteMethod<any>(`/admin/workspaces/${workspaceId}/users/${userId}`, { body, ...opts });
return response;
}
update(
Expand All @@ -467,7 +481,7 @@ export class Member extends ApiResource {
opts?: RequestOptions
): APIPromise<any> {
const body = _body;
const workspaceId = _body.workspaceId;
const workspaceId = body.workspaceId;
const userId = _body.userId;
delete body.workspaceId;
if (params) {
Expand Down
4 changes: 2 additions & 2 deletions src/apis/betaChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +26,7 @@ export class BetaChat extends ApiResource {

export class Completions extends ApiResource {

async parse<Params extends ChatCompletionParseParams, ParsedT = ExtractParsedContentFromParams<Params>>
async parse<Params extends ChatCompletionParseParams>
(
_body: Params,
params?: ApiClientInterface,
Expand Down
6 changes: 0 additions & 6 deletions src/apis/chatCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ interface Usage {
[key: string]: any;
}

interface FunctionType {
arguments?: string;
name?: string;
[key: string]: any;
}

interface Message {
role: string;
content: string;
Expand Down
5 changes: 4 additions & 1 deletion src/apis/moderations.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
model?: any ;
}

export class Moderations extends ApiResource{
async create(_body: ModerationCreateParams,
Expand Down
5 changes: 4 additions & 1 deletion src/apis/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
md5?: string;
}
export class Uploads extends ApiResource {
parts: Parts

Expand Down
4 changes: 2 additions & 2 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export abstract class ApiClient {
portkeyHeaders: Record<string, string>

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 = {}
Expand Down
Loading

0 comments on commit 3b77d72

Please sign in to comment.