Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configs API Added #120

Merged
merged 24 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
19b71d5
chore: added configs api
shivam-pareek Sep 24, 2024
88755fe
chore: apiKeys and Configs have been integrated
shivam-pareek Sep 25, 2024
aceface
updating acc to userInvites
shivam-pareek Sep 26, 2024
48b57db
chore: added configs api after testing
shivam-pareek Sep 26, 2024
cd18c16
fix: add missing listConfigsParam type
shivam-pareek Sep 30, 2024
2b649e0
fix: get methods for configs have been fixed
shivam-pareek Oct 3, 2024
6cfbb0d
merge: userInvite
shivam-pareek Oct 4, 2024
26dbb54
merge: userInvite
shivam-pareek Oct 5, 2024
bfffd34
fix: the interfaces have been rearranged and method names have been c…
shivam-pareek Oct 5, 2024
3821305
fix: Delete method added for configs API
shivam-pareek Oct 6, 2024
c8d78a4
fix: "create" has been replaced with "add"
shivam-pareek Oct 7, 2024
ff13e76
merge: userInvite
shivam-pareek Oct 7, 2024
cdfc58f
merge: userInvite
shivam-pareek Oct 7, 2024
bcaf195
fix: "unknown" replaced with "any" and comments resolved
shivam-pareek Oct 7, 2024
91b3ab3
merge: userInvite
shivam-pareek Oct 7, 2024
6d3d218
fix: utils.js updated with toQueryParams
shivam-pareek Oct 7, 2024
edf8af4
merge: userInvite
shivam-pareek Oct 7, 2024
5a4f1da
fix: import statement fixed
shivam-pareek Oct 7, 2024
2867537
merge: userInvite
shivam-pareek Oct 7, 2024
95b8359
merge: userInvite
shivam-pareek Oct 7, 2024
72a6c62
Merge branch 'feat/userInvite' into feat/configs
csgulati09 Oct 8, 2024
f1a20a8
Merge branch 'feat/userInvite' into feat/configs
csgulati09 Oct 8, 2024
301e86d
feat: rename signature
csgulati09 Oct 8, 2024
6637fdb
Merge branch 'main' into feat/configs
csgulati09 Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions src/apis/configs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { ApiResource } from "../apiResource";
import { APIResponseType, ApiClientInterface } from "../_types/generalTypes";
import { APIPromise, RequestOptions } from "../baseClient";
import { createHeaders } from "./createHeaders";
import { toQueryParams } from "../utils";

export interface ConfigsAddParams {
name?: string;
config?: Record<string, any>;
isDefault?: number;
workspace_id?:string;
}
export interface ConfigsAddResponse extends APIResponseType {
id?: string;
version_id?: string;
slug?: string;
object?: string;
}
export interface ConfigsGetParams {
slug?: string;
}
export interface ConfigsGetResponse extends APIResponseType {
id?: string;
name?: string;
workspace_id?: string;
slug?: string;
organization_id?: string;
is_default?: number;
status?: string;
owner_id?: string;
created_at?: string;
updated_by?: string;
last_updated_at?: string;
config?: Record<string, any>;
format?: string;
type?: string;
version_id?: string;
object?: string;
}
export interface CongfigsListParams {
workspace_id?: string;
}
export interface ConfigsListResponse extends APIResponseType {
object?: boolean;
total?: number;
data?: Record<string, any>[];
}
export interface ConfigsUpdateParams {
slug?: string;
name?: string;
config?: Record<string, any>;
status?: string;
}
export interface ConfigsUpdateResponse extends APIResponseType {
version_id?: string;
object?: string;
}
export interface ConfigsDeleteParams {
id?: string;
}
export class Configs extends ApiResource {
constructor(client: any) {
super(client);
}
create(
_body: ConfigsAddParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigsAddResponse> {
const body = _body;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.post<ConfigsAddResponse>('/configs', { body, ...opts });
return response;
}

retrieve(
_body: ConfigsGetParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigsGetResponse> {
const body = _body;
const slug = body.slug;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.getMethod<ConfigsGetResponse>(`/configs/${slug}`, { ...opts });
return response;
}

update(
_body: ConfigsUpdateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigsUpdateResponse> {
const body = _body;
const slug = body.slug;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.put<ConfigsUpdateResponse>(`/configs/${slug}`, { body, ...opts });
return response;
}
list(
_body?:CongfigsListParams,
params?: ApiClientInterface,
opts?: RequestOptions
):APIPromise<ConfigsListResponse>{
const body = _body;
const query = toQueryParams(body);
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.getMethod<ConfigsListResponse>(`/configs${query}`, {...opts});
return response;
}
delete(
_body:ConfigsDeleteParams,
params?: ApiClientInterface,
opts?: RequestOptions
):APIPromise<any>{
const body = _body;
const configId = body.id;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.deleteMethod<any>(`/configs/${configId}`, {...opts});
return response;
}
}

3 changes: 2 additions & 1 deletion src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export { Threads } from "./threads";
export { MainFiles } from "./files";
export { Models } from "./models";
export { Admin } from "./admin";
export { Configs } from "./configs";
export { Batches } from "./batches";
export { FineTuning } from "./fineTuning"
export { Moderations } from "./moderations"
export { Audio } from "./audio"
export { VectorStores } from "./vectorStores"
export { BetaChat } from "./betaChat"
export { Uploads } from "./uploads"
export { Uploads } from "./uploads"
1 change: 1 addition & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class Portkey extends ApiClient {
audio = new API.Audio(this);
uploads = new API.Uploads(this);
admin = new API.Admin(this);
configs = new API.Configs(this);
beta = {
assistants: new API.Assistants(this),
threads: new API.Threads(this),
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createResponseHeaders } from "./streaming";
import OpenAI from "openai";
import type { Portkey } from "./index";
import { UserInviteListParams, UsersListParams, WorkspaceMemberListParams, WorkspacesListParams } from "./apis/admin";
import { CongfigsListParams } from "./apis/configs";

type PlatformProperties = {
"x-portkey-runtime"?: string,
Expand Down Expand Up @@ -131,7 +132,7 @@ export function initOpenAIClient(client: Portkey){
maxRetries: 0
})
}
export function toQueryParams(params?: (UsersListParams | UserInviteListParams | WorkspacesListParams | WorkspaceMemberListParams)): string {
export function toQueryParams(params?: (UsersListParams | UserInviteListParams | WorkspacesListParams | WorkspaceMemberListParams | CongfigsListParams)): string {
if (!params) {
return '';
}
Expand Down
Loading