diff --git a/README.md b/README.md index 14e84034d..80419523c 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ If you pass a `parse` function, it will automatically parse the `arguments` for and returns any parsing errors to the model to attempt auto-recovery. Otherwise, the args will be passed to the function you provide as a string. -If you pass `function_call: {name: …}` or `tool_call: {function: {name: …}}` instead of `auto`, +If you pass `function_call: {name: …}` or `tool_choice: {function: {name: …}}` instead of `auto`, it returns immediately after calling that function (and only loops to auto-recover parsing errors). ```ts diff --git a/examples/tool-call-helpers.ts b/examples/tool-call-helpers.ts index e750b2ab9..d87e3c3e6 100755 --- a/examples/tool-call-helpers.ts +++ b/examples/tool-call-helpers.ts @@ -85,7 +85,7 @@ async function main() { console.log(runner.messages); console.log(); - console.log('final chat competion'); + console.log('final chat completion'); console.dir(result, { depth: null }); } diff --git a/src/lib/ChatCompletionStream.ts b/src/lib/ChatCompletionStream.ts index 1f14c8e33..b4534639f 100644 --- a/src/lib/ChatCompletionStream.ts +++ b/src/lib/ChatCompletionStream.ts @@ -52,7 +52,13 @@ export class ChatCompletionStream options?: Core.RequestOptions, ): ChatCompletionStream { const runner = new ChatCompletionStream(); - runner._run(() => runner._runChatCompletion(completions, { ...params, stream: true }, options)); + runner._run(() => + runner._runChatCompletion( + completions, + { ...params, stream: true }, + { ...options, headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'stream' } }, + ), + ); return runner; } diff --git a/src/lib/ChatCompletionStreamingRunner.ts b/src/lib/ChatCompletionStreamingRunner.ts index 8ea911ea0..a2da456e6 100644 --- a/src/lib/ChatCompletionStreamingRunner.ts +++ b/src/lib/ChatCompletionStreamingRunner.ts @@ -43,7 +43,12 @@ export class ChatCompletionStreamingRunner options?: RunnerOptions, ): ChatCompletionStreamingRunner { const runner = new ChatCompletionStreamingRunner(); - runner._run(() => runner._runFunctions(completions, params, options)); + runner._run(() => + runner._runFunctions(completions, params, { + ...options, + headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runFunctions' }, + }), + ); return runner; } @@ -53,7 +58,12 @@ export class ChatCompletionStreamingRunner options?: RunnerOptions, ): ChatCompletionStreamingRunner { const runner = new ChatCompletionStreamingRunner(); - runner._run(() => runner._runTools(completions, params, options)); + runner._run(() => + runner._runTools(completions, params, { + ...options, + headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' }, + }), + ); return runner; } }