// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { ChatCompletionRunner, ChatCompletionFunctionRunnerParams } from '../../../lib/ChatCompletionRunner'; export { ChatCompletionRunner, ChatCompletionFunctionRunnerParams } from '../../../lib/ChatCompletionRunner'; import { ChatCompletionStreamingRunner, ChatCompletionStreamingFunctionRunnerParams, } from '../../../lib/ChatCompletionStreamingRunner'; export { ChatCompletionStreamingRunner, ChatCompletionStreamingFunctionRunnerParams, } from '../../../lib/ChatCompletionStreamingRunner'; import { BaseFunctionsArgs } from '../../../lib/RunnableFunction'; export { RunnableFunction, RunnableFunctions, RunnableFunctionWithParse, RunnableFunctionWithoutParse, ParsingFunction, ParsingToolFunction, } from '../../../lib/RunnableFunction'; import { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner'; export { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner'; import { ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner'; export { ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner'; import { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream'; export { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream'; export class Completions extends APIResource { /** * @deprecated - use `runTools` instead. */ runFunctions( body: ChatCompletionFunctionRunnerParams, options?: Core.RequestOptions, ): ChatCompletionRunner; runFunctions( body: ChatCompletionStreamingFunctionRunnerParams, options?: Core.RequestOptions, ): ChatCompletionStreamingRunner; runFunctions( body: | ChatCompletionFunctionRunnerParams | ChatCompletionStreamingFunctionRunnerParams, options?: Core.RequestOptions, ): ChatCompletionRunner | ChatCompletionStreamingRunner { if (body.stream) { return ChatCompletionStreamingRunner.runFunctions( this._client.chat.completions, body as ChatCompletionStreamingFunctionRunnerParams, options, ); } return ChatCompletionRunner.runFunctions( this._client.chat.completions, body as ChatCompletionFunctionRunnerParams, options, ); } /** * A convenience helper for using tool calls with the /chat/completions endpoint * which automatically calls the JavaScript functions you provide and sends their * results back to the /chat/completions endpoint, looping as long as the model * requests function calls. * * For more details and examples, see * [the docs](https://github.com/openai/openai-node#automated-function-calls) */ runTools( body: ChatCompletionToolRunnerParams, options?: Core.RequestOptions, ): ChatCompletionRunner; runTools( body: ChatCompletionStreamingToolRunnerParams, options?: Core.RequestOptions, ): ChatCompletionStreamingRunner; runTools( body: | ChatCompletionToolRunnerParams | ChatCompletionStreamingToolRunnerParams, options?: Core.RequestOptions, ): ChatCompletionRunner | ChatCompletionStreamingRunner { if (body.stream) { return ChatCompletionStreamingRunner.runTools( this._client.chat.completions, body as ChatCompletionStreamingToolRunnerParams, options, ); } return ChatCompletionRunner.runTools( this._client.chat.completions, body as ChatCompletionToolRunnerParams, options, ); } /** * Creates a chat completion stream */ stream(body: ChatCompletionStreamParams, options?: Core.RequestOptions): ChatCompletionStream { return ChatCompletionStream.createChatCompletion(this._client.chat.completions, body, options); } }