Skip to content

Commit b7ac1f9

Browse files
authored
[js] Fix: Making ResponseCreateParams optional params optional. (#108)
1 parent 5e9fff2 commit b7ac1f9

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

javascript/standalone/package-lock.json

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

javascript/standalone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rt-client",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"scripts": {
55
"test": "vitest",
66
"build": "rollup -c",

javascript/standalone/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import nodeResolve from "@rollup/plugin-node-resolve";
88
import alias from "@rollup/plugin-alias";
99
import replace from "@rollup/plugin-replace";
1010

11-
import pkg from "./package.json" assert { type: "json" };
11+
import pkg from "./package.json" with { type: "json" };
1212

1313
export default [
1414
{

javascript/standalone/src/models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ export interface ItemDeleteMessage extends ClientMessageBase {
170170
}
171171

172172
export interface ResponseCreateParams {
173-
commit: boolean;
174-
cancel_previous: boolean;
173+
commit?: boolean;
174+
cancel_previous?: boolean;
175175
append_input_items?: Item[];
176176
input_items?: Item[];
177177
instructions?: string;

javascript/standalone/test/client.spec.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ describe.each([
232232
});
233233
const response = await client.generateResponse();
234234
expect(response).toBeDefined();
235-
expect(response.id).toBeDefined();
236-
expect(response.id!.length).toBeGreaterThan(0);
237-
for await (const item of response) {
235+
expect(response!.id).toBeDefined();
236+
expect(response!.id!.length).toBeGreaterThan(0);
237+
for await (const item of response!) {
238238
expect(item).toBeDefined();
239-
expect(item.responseId).toBe(response.id);
239+
expect(item.responseId).toBe(response!.id);
240240
expect(item.previousItemId).toBe(sentItem.id);
241241
}
242242
});
@@ -254,14 +254,15 @@ describe.each([
254254
],
255255
});
256256
const response = await client.generateResponse();
257-
await response.cancel();
257+
expect(response).toBeDefined();
258+
await response!.cancel();
258259

259260
let itemCount = 0;
260-
for await (const _item of response) {
261+
for await (const _item of response!) {
261262
itemCount++;
262263
}
263264
expect(itemCount).toBe(0);
264-
expect(["cancelled", "completed"].includes(response.status));
265+
expect(["cancelled", "completed"].includes(response!.status));
265266
});
266267

267268
it("items should properly be emitted for text in text out", async () => {
@@ -277,8 +278,9 @@ describe.each([
277278
],
278279
});
279280
const response = await client.generateResponse();
281+
expect(response).toBeDefined();
280282

281-
for await (const item of response) {
283+
for await (const item of response!) {
282284
expect(item.type).toBe("message");
283285
assert(item.type === "message");
284286
for await (const part of item) {
@@ -309,8 +311,9 @@ describe.each([
309311
],
310312
});
311313
const response = await client.generateResponse();
314+
expect(response).toBeDefined();
312315

313-
for await (const item of response) {
316+
for await (const item of response!) {
314317
expect(item.type).toBe("message");
315318
assert(item.type === "message");
316319
for await (const part of item) {
@@ -366,8 +369,9 @@ describe.each([
366369
],
367370
});
368371
const response = await client.generateResponse();
372+
expect(response).toBeDefined();
369373

370-
for await (const item of response) {
374+
for await (const item of response!) {
371375
expect(item.type).toBe("function_call");
372376
assert(item.type === "function_call");
373377
expect(item.functionName).toBe("get_weather_by_location");
@@ -398,8 +402,9 @@ describe.each([
398402
],
399403
});
400404
const response = await client.generateResponse();
405+
expect(response).toBeDefined();
401406

402-
for await (const item of response) {
407+
for await (const item of response!) {
403408
expect(item.type).toBe("function_call");
404409
assert(item.type === "function_call");
405410
expect(item.functionName).toBe("get_weather_by_location");
@@ -430,8 +435,9 @@ describe.each([
430435
],
431436
});
432437
const response = await client.generateResponse();
438+
expect(response).toBeDefined();
433439

434-
for await (const item of response) {
440+
for await (const item of response!) {
435441
expect(item.type).toBe("function_call");
436442
assert(item.type === "function_call");
437443
expect(item.functionName).toBe("get_weather_by_location");
@@ -462,8 +468,9 @@ describe.each([
462468
],
463469
});
464470
const response = await client.generateResponse();
471+
expect(response).toBeDefined();
465472

466-
for await (const item of response) {
473+
for await (const item of response!) {
467474
expect(item.type).toBe("function_call");
468475
assert(item.type === "function_call");
469476
expect(item.functionName).toBe("get_weather_by_location");

0 commit comments

Comments
 (0)