Skip to content

Commit 71a3000

Browse files
committed
chore: fix typo in docs and add request header for function calls (#494)
1 parent 12de980 commit 71a3000

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ If you pass a `parse` function, it will automatically parse the `arguments` for
153153
and returns any parsing errors to the model to attempt auto-recovery.
154154
Otherwise, the args will be passed to the function you provide as a string.
155155

156-
If you pass `function_call: {name: …}` or `tool_call: {function: {name: …}}` instead of `auto`,
156+
If you pass `function_call: {name: …}` or `tool_choice: {function: {name: …}}` instead of `auto`,
157157
it returns immediately after calling that function (and only loops to auto-recover parsing errors).
158158

159159
```ts

examples/tool-call-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async function main() {
8585
console.log(runner.messages);
8686

8787
console.log();
88-
console.log('final chat competion');
88+
console.log('final chat completion');
8989
console.dir(result, { depth: null });
9090
}
9191

src/lib/ChatCompletionStream.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ export class ChatCompletionStream
5252
options?: Core.RequestOptions,
5353
): ChatCompletionStream {
5454
const runner = new ChatCompletionStream();
55-
runner._run(() => runner._runChatCompletion(completions, { ...params, stream: true }, options));
55+
runner._run(() =>
56+
runner._runChatCompletion(
57+
completions,
58+
{ ...params, stream: true },
59+
{ ...options, headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'stream' } },
60+
),
61+
);
5662
return runner;
5763
}
5864

src/lib/ChatCompletionStreamingRunner.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ export class ChatCompletionStreamingRunner
4343
options?: RunnerOptions,
4444
): ChatCompletionStreamingRunner {
4545
const runner = new ChatCompletionStreamingRunner();
46-
runner._run(() => runner._runFunctions(completions, params, options));
46+
runner._run(() =>
47+
runner._runFunctions(completions, params, {
48+
...options,
49+
headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runFunctions' },
50+
}),
51+
);
4752
return runner;
4853
}
4954

@@ -53,7 +58,12 @@ export class ChatCompletionStreamingRunner
5358
options?: RunnerOptions,
5459
): ChatCompletionStreamingRunner {
5560
const runner = new ChatCompletionStreamingRunner();
56-
runner._run(() => runner._runTools(completions, params, options));
61+
runner._run(() =>
62+
runner._runTools(completions, params, {
63+
...options,
64+
headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },
65+
}),
66+
);
5767
return runner;
5868
}
5969
}

0 commit comments

Comments
 (0)