Skip to content

Commit 949d8a0

Browse files
committed
fix more naming
1 parent 8eb6c3d commit 949d8a0

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/lib/beta/BetaToolRunner.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function promiseWithResolvers<T>(): {
3131
}
3232

3333
/**
34-
* A BetaToolRunner handles the automatic conversation loop between the assistant and tools.
34+
* A `BetaToolRunner` handles the automatic conversation loop between the assistant and tools.
3535
*
36-
* A BetaToolRunner is an async iterable that yields either ChatCompletion or
37-
* ChatCompletionStream objects depending on the streaming configuration.
36+
* A `BetaToolRunner` is an async iterable that yields either `ChatCompletion` or
37+
* `ChatCompletionStream` objects depending on the streaming configuration.
3838
*/
3939
export class BetaToolRunner<Stream extends boolean>
4040
implements AsyncIterable<Stream extends true ? ChatCompletionStream : ChatCompletion>
@@ -230,15 +230,15 @@ export class BetaToolRunner<Stream extends boolean>
230230
* Get the tool response for the last message from the assistant.
231231
* Avoids redundant tool executions by caching results.
232232
*
233-
* @returns A promise that resolves to a BetaMessageParam containing tool results, or null if no tools need to be executed
233+
* @returns A promise that resolves to a `ChatCompletionToolMessageParam` containing tool results, or null if no tools need to be executed
234234
*
235235
* @example
236236
* const toolResponse = await runner.generateToolResponse();
237237
* if (toolResponse) {
238238
* console.log('Tool results:', toolResponse.content);
239239
* }
240240
*/
241-
async generateToolResponse() {
241+
async generateToolResponse(): Promise<ChatCompletionToolMessageParam[] | null> {
242242
// The most recent message from the assistant.
243243
const message = await this.#message;
244244
if (!message) {
@@ -266,7 +266,7 @@ export class BetaToolRunner<Stream extends boolean>
266266
* Wait for the async iterator to complete. This works even if the async iterator hasn't yet started, and
267267
* will wait for an instance to start and go to completion.
268268
*
269-
* @returns A promise that resolves to the final BetaMessage when the iterator completes
269+
* @returns A promise that resolves to the final `ChatComletionMessage` when the iterator completes
270270
*
271271
* @example
272272
* // Start consuming the iterator
@@ -283,12 +283,14 @@ export class BetaToolRunner<Stream extends boolean>
283283
}
284284

285285
/**
286-
* Returns a promise indicating that the stream is done. Unlike .done(), this will eagerly read the stream:
287-
* * If the iterator has not been consumed, consume the entire iterator and return the final message from the
288-
* assistant.
289-
* * If the iterator has been consumed, waits for it to complete and returns the final message.
286+
* Returns a promise indicating that the stream is done. Unlike .done(), this
287+
* will eagerly read the stream:
290288
*
291-
* @returns A promise that resolves to the final BetaMessage from the conversation
289+
* - If the iterator has not been consumed, consume the entire iterator and
290+
* return the final message from the assistant.
291+
* - If the iterator has been consumed, waits for it to complete and returns the final message.
292+
*
293+
* @returns A promise that resolves to the final `ChatCompletionMessage` from the conversation
292294
* @throws {OpenAIError} If no messages were processed during the conversation
293295
*
294296
* @example
@@ -308,9 +310,9 @@ export class BetaToolRunner<Stream extends boolean>
308310
}
309311

310312
/**
311-
* Get the current parameters being used by the ToolRunner.
313+
* Get the current parameters being used by the `BetaToolRunner`.
312314
*
313-
* @returns A readonly view of the current ToolRunnerParams
315+
* @returns A readonly view of the current `BetaToolRunnerParams`
314316
*
315317
* @example
316318
* const currentParams = runner.params;
@@ -324,7 +326,7 @@ export class BetaToolRunner<Stream extends boolean>
324326
/**
325327
* Add one or more messages to the conversation history.
326328
*
327-
* @param messages - One or more BetaMessageParam objects to add to the conversation
329+
* @param messages - One or more `ChatCompletionMessageParam` objects to add to the conversation
328330
*
329331
* @example
330332
* runner.pushMessages(

tests/lib/tools/BetaToolRunner.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function getTextContent(text?: string): ChatCompletionMessage {
112112
};
113113
}
114114

115-
function betaMessageToStreamEvents(message: ChatCompletion): ChatCompletionChunk[] {
115+
function chunkChatCompletion(message: ChatCompletion): ChatCompletionChunk[] {
116116
const events: ChatCompletionChunk[] = [];
117117

118118
const messageContent = message.choices[0]!.message;
@@ -374,7 +374,7 @@ function setupTest(params: Partial<BetaToolRunnerParams> = {}): SetupTestResult<
374374
},
375375
};
376376

377-
handleStreamEvents(betaMessageToStreamEvents(message));
377+
handleStreamEvents(chunkChatCompletion(message));
378378
return message;
379379
};
380380

@@ -459,7 +459,7 @@ describe('ToolRunner', () => {
459459
await expectDone(iterator);
460460
});
461461

462-
it('yields BetaMessageStream when stream=true', async () => {
462+
it('yields ChatCompletionStream when stream=true', async () => {
463463
const { runner, handleAssistantMessageStream } = setupTest({ stream: true });
464464

465465
const iterator = runner[Symbol.asyncIterator]();

0 commit comments

Comments
 (0)