Skip to content

Commit 49bbff6

Browse files
committed
make tool runner beta only
1 parent 844c5a4 commit 49bbff6

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

examples/tool-helpers-advanced-streaming.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { z } from 'zod';
77
const client = new OpenAI();
88

99
async function main() {
10-
const runner = client.chat.completions.toolRunner({
10+
const runner = client.beta.chat.completions.toolRunner({
1111
messages: [
1212
{
1313
role: 'user',

examples/tool-helpers-advanced.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { z } from 'zod';
77
const client = new OpenAI();
88

99
async function main() {
10-
const message = await client.chat.completions.toolRunner({
10+
const message = await client.beta.chat.completions.toolRunner({
1111
messages: [
1212
{
1313
role: 'user',

examples/tool-helpers-json-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { betaTool } from 'openai/helpers/beta/json-schema';
66
const client = new OpenAI();
77

88
async function main() {
9-
const message = await client.chat.completions.toolRunner({
9+
const message = await client.beta.chat.completions.toolRunner({
1010
messages: [
1111
{
1212
role: 'user',

src/resources/beta/beta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import {
7474
TranscriptionSessionUpdatedEvent,
7575
} from './realtime/realtime';
7676
import * as ChatKitAPI from './chatkit/chatkit';
77-
import * as ChatAPI from '../chat/chat';
77+
import { BetaChat as BetaChatAPI } from './chat';
7878
import { ChatKit, ChatKitWorkflow } from './chatkit/chatkit';
7979
import * as ThreadsAPI from './threads/threads';
8080
import {
@@ -100,7 +100,7 @@ export class Beta extends APIResource {
100100
chatkit: ChatKitAPI.ChatKit = new ChatKitAPI.ChatKit(this._client);
101101
assistants: AssistantsAPI.Assistants = new AssistantsAPI.Assistants(this._client);
102102
threads: ThreadsAPI.Threads = new ThreadsAPI.Threads(this._client);
103-
chat: ChatAPI.Chat = new ChatAPI.Chat(this._client);
103+
chat: BetaChatAPI = new BetaChatAPI(this._client);
104104
}
105105

106106
Beta.Realtime = Realtime;

src/resources/beta/chat.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { APIResource } from '../../resource';
2+
import {
3+
BetaToolRunner,
4+
type BetaToolRunnerParams,
5+
type BetaToolRunnerRequestOptions,
6+
} from '../../lib/beta/BetaToolRunner';
7+
import { Chat as ChatResource } from '../../resources';
8+
9+
export class BetaCompletions extends ChatResource.Completions {
10+
toolRunner(
11+
body: BetaToolRunnerParams & { stream?: false },
12+
options?: BetaToolRunnerRequestOptions,
13+
): BetaToolRunner<false>;
14+
toolRunner(
15+
body: BetaToolRunnerParams & { stream: true },
16+
options?: BetaToolRunnerRequestOptions,
17+
): BetaToolRunner<true>;
18+
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean>;
19+
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean> {
20+
return new BetaToolRunner(this._client, body, options);
21+
}
22+
}
23+
24+
export class BetaChat extends APIResource {
25+
completions: BetaCompletions = new BetaCompletions(this._client);
26+
}

src/resources/chat/completions/completions.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ import { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunne
1919
import { ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner';
2020
import { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream';
2121
import { ExtractParsedContentFromParams, parseChatCompletion, validateInputTools } from '../../../lib/parser';
22-
import {
23-
BetaToolRunner,
24-
type BetaToolRunnerRequestOptions,
25-
type BetaToolRunnerParams,
26-
} from '../../../lib/beta/BetaToolRunner';
27-
import type OpenAI from '../../../index';
22+
import { BetaToolRunner } from '../../../lib/beta/BetaToolRunner';
2823

2924
export class Completions extends APIResource {
3025
messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
@@ -198,19 +193,6 @@ export class Completions extends APIResource {
198193
return ChatCompletionRunner.runTools(this._client, body as ChatCompletionToolRunnerParams<any>, options);
199194
}
200195

201-
toolRunner(
202-
body: BetaToolRunnerParams & { stream?: false },
203-
options?: BetaToolRunnerRequestOptions,
204-
): BetaToolRunner<false>;
205-
toolRunner(
206-
body: BetaToolRunnerParams & { stream: true },
207-
options?: BetaToolRunnerRequestOptions,
208-
): BetaToolRunner<true>;
209-
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean>;
210-
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean> {
211-
return new BetaToolRunner(this._client as OpenAI, body, options);
212-
}
213-
214196
/**
215197
* Creates a chat completion stream
216198
*/

0 commit comments

Comments
 (0)