forked from openai/openai-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
completions.ts
106 lines (102 loc) · 4.26 KB
/
completions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { ChatCompletionRunner, ChatCompletionFunctionRunnerParams } from 'openai/lib/ChatCompletionRunner';
export { ChatCompletionRunner, ChatCompletionFunctionRunnerParams } from 'openai/lib/ChatCompletionRunner';
import {
ChatCompletionStreamingRunner,
ChatCompletionStreamingFunctionRunnerParams,
} from 'openai/lib/ChatCompletionStreamingRunner';
export {
ChatCompletionStreamingRunner,
ChatCompletionStreamingFunctionRunnerParams,
} from 'openai/lib/ChatCompletionStreamingRunner';
import { BaseFunctionsArgs } from 'openai/lib/RunnableFunction';
export {
RunnableFunction,
RunnableFunctions,
RunnableFunctionWithParse,
RunnableFunctionWithoutParse,
ParsingFunction,
ParsingToolFunction,
} from 'openai/lib/RunnableFunction';
import { ChatCompletionToolRunnerParams } from 'openai/lib/ChatCompletionRunner';
export { ChatCompletionToolRunnerParams } from 'openai/lib/ChatCompletionRunner';
import { ChatCompletionStreamingToolRunnerParams } from 'openai/lib/ChatCompletionStreamingRunner';
export { ChatCompletionStreamingToolRunnerParams } from 'openai/lib/ChatCompletionStreamingRunner';
import { ChatCompletionStream, type ChatCompletionStreamParams } from 'openai/lib/ChatCompletionStream';
export { ChatCompletionStream, type ChatCompletionStreamParams } from 'openai/lib/ChatCompletionStream';
export class Completions extends APIResource {
/**
* @deprecated - use `runTools` instead.
*/
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
body: ChatCompletionFunctionRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionRunner;
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
body: ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionStreamingRunner;
runFunctions<FunctionsArgs extends BaseFunctionsArgs>(
body:
| ChatCompletionFunctionRunnerParams<FunctionsArgs>
| ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionRunner | ChatCompletionStreamingRunner {
if (body.stream) {
return ChatCompletionStreamingRunner.runFunctions(
this._client.chat.completions,
body as ChatCompletionStreamingFunctionRunnerParams<FunctionsArgs>,
options,
);
}
return ChatCompletionRunner.runFunctions(
this._client.chat.completions,
body as ChatCompletionFunctionRunnerParams<FunctionsArgs>,
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<FunctionsArgs extends BaseFunctionsArgs>(
body: ChatCompletionToolRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionRunner;
runTools<FunctionsArgs extends BaseFunctionsArgs>(
body: ChatCompletionStreamingToolRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionStreamingRunner;
runTools<FunctionsArgs extends BaseFunctionsArgs>(
body:
| ChatCompletionToolRunnerParams<FunctionsArgs>
| ChatCompletionStreamingToolRunnerParams<FunctionsArgs>,
options?: Core.RequestOptions,
): ChatCompletionRunner | ChatCompletionStreamingRunner {
if (body.stream) {
return ChatCompletionStreamingRunner.runTools(
this._client.chat.completions,
body as ChatCompletionStreamingToolRunnerParams<FunctionsArgs>,
options,
);
}
return ChatCompletionRunner.runTools(
this._client.chat.completions,
body as ChatCompletionToolRunnerParams<FunctionsArgs>,
options,
);
}
/**
* Creates a chat completion stream
*/
stream(body: ChatCompletionStreamParams, options?: Core.RequestOptions): ChatCompletionStream {
return ChatCompletionStream.createChatCompletion(this._client.chat.completions, body, options);
}
}