Skip to content

Commit 4a79315

Browse files
authored
Merge branch 'main' into fix-stream-error-handling
2 parents 882da8e + a7fcc26 commit 4a79315

28 files changed

Lines changed: 698 additions & 704 deletions

package-lock.json

Lines changed: 12 additions & 349 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "portkey-ai",
3-
"version": "1.10.3",
3+
"version": "2.0.0",
44
"description": "Node client library for the Portkey API",
55
"types": "dist/src/index.d.ts",
66
"main": "dist/src/index.js",
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"agentkeepalive": "^4.6.0",
4747
"dotenv": "^16.5.0",
48-
"openai": "4.104.0",
48+
"openai": "5.20.2",
4949
"ws": "^8.18.2"
5050
}
5151
}

src/apis/admin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export interface WorkspacesListParams {
124124
name?: string;
125125
page_size?: number;
126126
current_page?: number;
127+
exact_name?: string;
128+
[key: string]: any;
127129
}
128130

129131
export interface WorkspacesListResponse extends APIResponseType {

src/apis/assistants.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class Assistants extends ApiResource {
9898
}
9999

100100
async retrieve(
101-
assistantId: string,
101+
assistantID: string,
102102
params?: ApiClientInterface,
103103
opts?: RequestOptions
104104
): Promise<any> {
@@ -113,14 +113,14 @@ export class Assistants extends ApiResource {
113113
const OAIclient = initOpenAIClient(this.client);
114114

115115
const result = await OAIclient.beta.assistants
116-
.retrieve(assistantId, opts)
116+
.retrieve(assistantID, opts)
117117
.withResponse();
118118

119119
return finalResponse(result);
120120
}
121121

122122
async update(
123-
assistantId: string,
123+
assistantID: string,
124124
_body: AssistantUpdateParams,
125125
params?: ApiClientInterface,
126126
opts?: RequestOptions
@@ -137,14 +137,14 @@ export class Assistants extends ApiResource {
137137
const OAIclient = initOpenAIClient(this.client);
138138

139139
const result = await OAIclient.beta.assistants
140-
.update(assistantId, body, opts)
140+
.update(assistantID, body, opts)
141141
.withResponse();
142142

143143
return finalResponse(result);
144144
}
145145

146-
async del(
147-
assistantId: string,
146+
async delete(
147+
assistantID: string,
148148
params?: ApiClientInterface,
149149
opts?: RequestOptions
150150
): Promise<any> {
@@ -159,7 +159,7 @@ export class Assistants extends ApiResource {
159159
const OAIclient = initOpenAIClient(this.client);
160160

161161
const result = await OAIclient.beta.assistants
162-
.del(assistantId, opts)
162+
.delete(assistantID, opts)
163163
.withResponse();
164164

165165
return finalResponse(result);

src/apis/batches.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Batches extends ApiResource {
2727
}
2828

2929
async retrieve(
30-
batchId: string,
30+
batchID: string,
3131
params?: ApiClientInterface,
3232
opts?: RequestOptions
3333
): Promise<any> {
@@ -42,7 +42,7 @@ export class Batches extends ApiResource {
4242
const OAIclient = initOpenAIClient(this.client);
4343

4444
const result = await OAIclient.batches
45-
.retrieve(batchId, opts)
45+
.retrieve(batchID, opts)
4646
.withResponse();
4747
return finalResponse(result);
4848
}
@@ -68,7 +68,7 @@ export class Batches extends ApiResource {
6868
}
6969

7070
async cancel(
71-
batchId: string,
71+
batchID: string,
7272
params?: ApiClientInterface,
7373
opts?: RequestOptions
7474
): Promise<any> {
@@ -85,7 +85,7 @@ export class Batches extends ApiResource {
8585
const options = { body, ...opts };
8686

8787
const result = await OAIclient.batches
88-
.cancel(batchId, options)
88+
.cancel(batchID, options)
8989
.withResponse();
9090
return finalResponse(result);
9191
}

src/apis/betaChat.ts

Lines changed: 0 additions & 136 deletions
This file was deleted.

src/apis/chatCompletions.ts

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ApiResource } from '../apiResource';
99
import { APIPromise, RequestOptions } from '../baseClient';
1010
import { CHAT_COMPLETE_API } from '../constants';
1111
import { Stream } from '../streaming';
12-
import { overrideConfig } from '../utils';
12+
import { initOpenAIClient, overrideConfig } from '../utils';
1313
import { createHeaders } from './createHeaders';
1414
import { Metadata, CursorPageParams } from '../_types/sharedTypes';
1515

@@ -59,7 +59,7 @@ class ChatCompletions extends ApiResource {
5959
}
6060

6161
retrieve(
62-
completionId: string,
62+
completionID: string,
6363
params?: ApiClientInterface,
6464
opts?: RequestOptions
6565
): APIPromise<ChatCompletion> {
@@ -71,15 +71,15 @@ class ChatCompletions extends ApiResource {
7171
};
7272
}
7373
return this.getMethod<ChatCompletion>(
74-
`${CHAT_COMPLETE_API}/${completionId}`,
74+
`${CHAT_COMPLETE_API}/${completionID}`,
7575
{
7676
...opts,
7777
}
7878
);
7979
}
8080

8181
update(
82-
completionId: string,
82+
completionID: string,
8383
_body: ChatCompletionUpdateParams,
8484
params?: ApiClientInterface,
8585
opts?: RequestOptions
@@ -92,7 +92,7 @@ class ChatCompletions extends ApiResource {
9292
...createHeaders({ ...params, config }),
9393
};
9494
}
95-
return this.post<ChatCompletion>(`${CHAT_COMPLETE_API}/${completionId}`, {
95+
return this.post<ChatCompletion>(`${CHAT_COMPLETE_API}/${completionID}`, {
9696
body,
9797
...opts,
9898
});
@@ -116,8 +116,8 @@ class ChatCompletions extends ApiResource {
116116
});
117117
}
118118

119-
del(
120-
completionId: string,
119+
delete(
120+
completionID: string,
121121
params?: ApiClientInterface,
122122
opts?: RequestOptions
123123
): APIPromise<ChatCompletion> {
@@ -129,17 +129,65 @@ class ChatCompletions extends ApiResource {
129129
};
130130
}
131131
return this.deleteMethod<ChatCompletion>(
132-
`${CHAT_COMPLETE_API}/${completionId}`,
132+
`${CHAT_COMPLETE_API}/${completionID}`,
133133
{
134134
...opts,
135135
}
136136
);
137137
}
138+
139+
async parse(
140+
body: any,
141+
params?: ApiClientInterface,
142+
opts?: RequestOptions
143+
): Promise<any> {
144+
if (params) {
145+
const config = overrideConfig(this.client.config, params.config);
146+
this.client.customHeaders = {
147+
...this.client.customHeaders,
148+
...createHeaders({ ...params, config }),
149+
};
150+
}
151+
152+
const OAIclient = initOpenAIClient(this.client);
153+
const result = await OAIclient.responses.parse(body, opts);
154+
return result;
155+
}
156+
157+
async stream(
158+
body: any,
159+
params?: ApiClientInterface,
160+
opts?: RequestOptions
161+
): Promise<any> {
162+
if (params) {
163+
const config = overrideConfig(this.client.config, params.config);
164+
this.client.customHeaders = {
165+
...this.client.customHeaders,
166+
...createHeaders({ ...params, config }),
167+
};
168+
}
169+
const OAIclient = initOpenAIClient(this.client);
170+
const result = await OAIclient.chat.completions.stream(body, opts);
171+
return result;
172+
}
173+
174+
runTools(body: any, params?: ApiClientInterface, opts?: RequestOptions): any {
175+
if (params) {
176+
const config = overrideConfig(this.client.config, params.config);
177+
this.client.customHeaders = {
178+
...this.client.customHeaders,
179+
...createHeaders({ ...params, config }),
180+
};
181+
}
182+
const OAIclient = initOpenAIClient(this.client);
183+
const result = OAIclient.chat.completions.runTools(body, opts);
184+
return result;
185+
}
138186
}
139187

140188
export class ChatCompletionsMessages extends ApiResource {
141189
list(
142-
completionId: string,
190+
completionID: string,
143191
query?: MessageListParams,
144192
params?: ApiClientInterface,
145193
opts?: RequestOptions
@@ -152,7 +200,7 @@ export class ChatCompletionsMessages extends ApiResource {
152200
};
153201
}
154202
return this.getMethod<any>(
155-
`${CHAT_COMPLETE_API}/${completionId}/messages`,
203+
`${CHAT_COMPLETE_API}/${completionID}/messages`,
156204
{
157205
...opts,
158206
...query,

0 commit comments

Comments
 (0)