@celljs/ai-openai 3.7.8 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/esm/common/api/api-protocol.d.ts +46 -0
  2. package/esm/common/api/api-protocol.js +3 -0
  3. package/esm/common/api/api-protocol.js.map +1 -0
  4. package/esm/common/api/chat-request.d.ts +203 -0
  5. package/esm/common/api/chat-request.js +236 -0
  6. package/esm/common/api/chat-request.js.map +1 -0
  7. package/esm/common/api/chat-response.d.ts +192 -0
  8. package/esm/common/api/chat-response.js +191 -0
  9. package/esm/common/api/chat-response.js.map +1 -0
  10. package/esm/common/api/embeddings-request.d.ts +62 -0
  11. package/esm/common/api/embeddings-request.js +85 -0
  12. package/esm/common/api/embeddings-request.js.map +1 -0
  13. package/esm/common/api/embeddings-response.d.ts +26 -0
  14. package/esm/common/api/embeddings-response.js +44 -0
  15. package/esm/common/api/embeddings-response.js.map +1 -0
  16. package/esm/common/api/index.d.ts +9 -0
  17. package/esm/common/api/index.js +10 -0
  18. package/esm/common/api/index.js.map +1 -0
  19. package/esm/common/api/message.d.ts +215 -0
  20. package/esm/common/api/message.js +250 -0
  21. package/esm/common/api/message.js.map +1 -0
  22. package/esm/common/api/openai-api.d.ts +18 -0
  23. package/esm/common/api/openai-api.js +118 -0
  24. package/esm/common/api/openai-api.js.map +1 -0
  25. package/esm/common/api/openai-model.d.ts +116 -0
  26. package/esm/common/api/openai-model.js +118 -0
  27. package/esm/common/api/openai-model.js.map +1 -0
  28. package/esm/common/api/response-format.d.ts +59 -0
  29. package/esm/common/api/response-format.js +107 -0
  30. package/esm/common/api/response-format.js.map +1 -0
  31. package/esm/common/api/usage.d.ts +78 -0
  32. package/esm/common/api/usage.js +106 -0
  33. package/esm/common/api/usage.js.map +1 -0
  34. package/esm/common/index.d.ts +3 -0
  35. package/esm/common/index.js +4 -0
  36. package/esm/common/index.js.map +1 -0
  37. package/esm/common/model/index.d.ts +4 -0
  38. package/esm/common/model/index.js +5 -0
  39. package/esm/common/model/index.js.map +1 -0
  40. package/esm/common/model/openai-chat-model.d.ts +36 -0
  41. package/esm/common/model/openai-chat-model.js +363 -0
  42. package/esm/common/model/openai-chat-model.js.map +1 -0
  43. package/esm/common/model/openai-chat-options.d.ts +169 -0
  44. package/esm/common/model/openai-chat-options.js +274 -0
  45. package/esm/common/model/openai-chat-options.js.map +1 -0
  46. package/esm/common/model/openai-embedding-model.d.ts +14 -0
  47. package/esm/common/model/openai-embedding-model.js +69 -0
  48. package/esm/common/model/openai-embedding-model.js.map +1 -0
  49. package/esm/common/model/openai-embedding-options.d.ts +34 -0
  50. package/esm/common/model/openai-embedding-options.js +72 -0
  51. package/esm/common/model/openai-embedding-options.js.map +1 -0
  52. package/esm/common/module.d.ts +3 -0
  53. package/esm/common/module.js +4 -0
  54. package/esm/common/module.js.map +1 -0
  55. package/esm/common/support/index.d.ts +2 -0
  56. package/esm/common/support/index.js +3 -0
  57. package/esm/common/support/index.js.map +1 -0
  58. package/esm/common/support/openai-api-response-headers.d.ts +33 -0
  59. package/esm/common/support/openai-api-response-headers.js +42 -0
  60. package/esm/common/support/openai-api-response-headers.js.map +1 -0
  61. package/esm/common/support/openai-response-header-extractor.d.ts +11 -0
  62. package/esm/common/support/openai-response-header-extractor.js +129 -0
  63. package/esm/common/support/openai-response-header-extractor.js.map +1 -0
  64. package/esm/common/test/mock-openai-api.d.ts +12 -0
  65. package/esm/common/test/mock-openai-api.js +53 -0
  66. package/esm/common/test/mock-openai-api.js.map +1 -0
  67. package/esm/common/test/test-container.d.ts +2 -0
  68. package/esm/common/test/test-container.js +12 -0
  69. package/esm/common/test/test-container.js.map +1 -0
  70. package/esm/package.json +3 -0
  71. package/lib/common/api/chat-request.d.ts.map +1 -1
  72. package/lib/common/api/chat-request.js.map +1 -1
  73. package/lib/common/api/chat-response.js.map +1 -1
  74. package/lib/common/api/embeddings-request.d.ts.map +1 -1
  75. package/lib/common/api/embeddings-request.js.map +1 -1
  76. package/lib/common/api/embeddings-response.d.ts.map +1 -1
  77. package/lib/common/api/embeddings-response.js.map +1 -1
  78. package/lib/common/api/message.d.ts.map +1 -1
  79. package/lib/common/api/message.js.map +1 -1
  80. package/lib/common/api/openai-api.d.ts.map +1 -1
  81. package/lib/common/api/openai-api.js.map +1 -1
  82. package/lib/common/api/openai-api.spec.d.ts.map +1 -1
  83. package/lib/common/api/openai-api.spec.js +14 -13
  84. package/lib/common/api/openai-api.spec.js.map +1 -1
  85. package/lib/common/api/openai-model.js.map +1 -1
  86. package/lib/common/api/response-format.d.ts.map +1 -1
  87. package/lib/common/api/response-format.js.map +1 -1
  88. package/lib/common/api/usage.d.ts.map +1 -1
  89. package/lib/common/api/usage.js.map +1 -1
  90. package/lib/common/model/openai-chat-model.d.ts.map +1 -1
  91. package/lib/common/model/openai-chat-model.js +12 -13
  92. package/lib/common/model/openai-chat-model.js.map +1 -1
  93. package/lib/common/model/openai-chat-model.spec.d.ts.map +1 -1
  94. package/lib/common/model/openai-chat-model.spec.js +9 -8
  95. package/lib/common/model/openai-chat-model.spec.js.map +1 -1
  96. package/lib/common/model/openai-chat-options.d.ts.map +1 -1
  97. package/lib/common/model/openai-chat-options.js.map +1 -1
  98. package/lib/common/model/openai-embedding-model.d.ts.map +1 -1
  99. package/lib/common/model/openai-embedding-model.js.map +1 -1
  100. package/lib/common/model/openai-embedding-model.spec.d.ts.map +1 -1
  101. package/lib/common/model/openai-embedding-model.spec.js +9 -8
  102. package/lib/common/model/openai-embedding-model.spec.js.map +1 -1
  103. package/lib/common/model/openai-embedding-options.d.ts.map +1 -1
  104. package/lib/common/model/openai-embedding-options.js.map +1 -1
  105. package/lib/common/module.d.ts.map +1 -1
  106. package/lib/common/module.js.map +1 -1
  107. package/lib/common/support/openai-api-response-headers.js.map +1 -1
  108. package/lib/common/support/openai-response-header-extractor.d.ts.map +1 -1
  109. package/lib/common/support/openai-response-header-extractor.js +4 -2
  110. package/lib/common/support/openai-response-header-extractor.js.map +1 -1
  111. package/lib/common/test/mock-openai-api.d.ts.map +1 -1
  112. package/lib/common/test/mock-openai-api.js.map +1 -1
  113. package/lib/common/test/test-container.js +5 -2
  114. package/lib/common/test/test-container.js.map +1 -1
  115. package/lib/package.spec.d.ts +1 -0
  116. package/lib/package.spec.js +5 -2
  117. package/lib/package.spec.js.map +1 -1
  118. package/package.json +48 -13
  119. package/src/common/api/openai-api.spec.ts +1 -0
  120. package/src/common/model/openai-chat-model.spec.ts +2 -1
  121. package/src/common/model/openai-embedding-model.spec.ts +2 -1
  122. package/src/package.spec.ts +1 -0
  123. package/LICENSE +0 -21
@@ -0,0 +1,46 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatCompletionRequest } from './chat-request.js';
3
+ import { ChatCompletion, ChatCompletionChunk } from './chat-response.js';
4
+ import { EmbeddingResponse } from './embeddings-response.js';
5
+ import { EmbeddingRequest } from './embeddings-request.js';
6
+ import { ResponseEntity } from '@celljs/http';
7
+ export declare const OpenAIAPIOptions: unique symbol;
8
+ export declare const OpenAIAPI: unique symbol;
9
+ export interface OpenAIAPIOptions {
10
+ baseUrl?: string;
11
+ apiKey?: string;
12
+ completionsPath?: string;
13
+ embeddingsPath?: string;
14
+ }
15
+ /**
16
+ * Interface representing the OpenAI API.
17
+ */
18
+ export interface OpenAIAPI {
19
+ /**
20
+ * Creates a model response for the given chat conversation.
21
+ * @param chatRequest - The chat completion request.
22
+ * @param additionalHttpHeader - Optional, additional HTTP headers to be added to the request.
23
+ * @returns A promise that resolves to the chat completion response.
24
+ */
25
+ chat(chatRequest: ChatCompletionRequest, additionalHttpHeader?: Record<string, string>): Promise<ResponseEntity<ChatCompletion>>;
26
+ /**
27
+ * Creates a streaming chat response for the given chat conversation.
28
+ * @param chatRequest - The chat completion request. Must have the stream property set to true.
29
+ * @param additionalHttpHeader - Optional, additional HTTP headers to be added to the request.
30
+ * @returns A promise that resolves to an observable of chat completion chunks.
31
+ */
32
+ streamingChat(chatRequest: ChatCompletionRequest, additionalHttpHeader?: Record<string, string>): Promise<Observable<ResponseEntity<ChatCompletionChunk>>>;
33
+ /**
34
+ * Creates an embedding vector representing the input text or token array.
35
+ * @param embeddingsRequest - The embedding request.
36
+ * @typeParam T - Type of the entity in the data list. Can be a string or list of tokens (e.g., integers).
37
+ * For embedding multiple inputs in a single request, you can pass a list of strings or a list of lists of tokens.
38
+ * @example
39
+ * ```typescript
40
+ * embed(List.of("text1", "text2", "text3"));
41
+ * embed(List.of(List.of(1, 2, 3), List.of(3, 4, 5)));
42
+ * ```
43
+ * @returns A promise that resolves to an embedding response containing a list of embeddings.
44
+ */
45
+ embed<T>(embeddingsRequest: EmbeddingRequest<T>): Promise<ResponseEntity<EmbeddingResponse>>;
46
+ }
@@ -0,0 +1,3 @@
1
+ export const OpenAIAPIOptions = Symbol('OpenAIAPIOptions');
2
+ export const OpenAIAPI = Symbol('OpenAIAPI');
3
+ //# sourceMappingURL=api-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-protocol.js","sourceRoot":"","sources":["../../../src/common/api/api-protocol.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,203 @@
1
+ import { ChatCompletionMessage } from './message.js';
2
+ import { ResponseFormat } from './response-format.js';
3
+ import { Prediction } from '@celljs/ai-core';
4
+ export declare class StreamOptions {
5
+ static INCLUDE_USAGE: StreamOptions;
6
+ /**
7
+ * includeUsage If set, an additional chunk will be streamed
8
+ * before the data: [DONE] message. The usage field on this chunk
9
+ * shows the token usage statistics for the entire request, and
10
+ * the choices field will always be an empty array. All other chunks
11
+ * will also include a usage field, but with a null value.
12
+ */
13
+ includeUsage: boolean;
14
+ constructor(includeUsage: boolean);
15
+ }
16
+ /**
17
+ * Function definition.
18
+ */
19
+ export declare class Function {
20
+ description: string;
21
+ name: string;
22
+ parameters: Record<string, any>;
23
+ strict?: boolean;
24
+ static create(description: string, name: string, parameters: Record<string, any>, strict?: boolean): Function;
25
+ }
26
+ export declare enum ToolType {
27
+ /**
28
+ * Function tool type.
29
+ */
30
+ FUNCTION = "function"
31
+ }
32
+ export declare class FunctionTool {
33
+ /**
34
+ * The type of the tool. Currently, only 'function' is supported.
35
+ */
36
+ type: ToolType;
37
+ /**
38
+ * The function definition.
39
+ */
40
+ function: Function;
41
+ static create(func: Function): FunctionTool;
42
+ }
43
+ /**
44
+ * The type of modality for the model completion.
45
+ */
46
+ export declare enum OutputModality {
47
+ AUDIO = "audio",
48
+ TEXT = "text"
49
+ }
50
+ export declare enum Voice {
51
+ ALLOY = "alloy",
52
+ ECHO = "echo",
53
+ FABLE = "fable",
54
+ ONYX = "onyx",
55
+ NOVA = "nova",
56
+ SHIMMER = "shimmer"
57
+ }
58
+ export declare enum AudioResponseFormat {
59
+ MP3 = "mp3",
60
+ FLAC = "flac",
61
+ OPUS = "opus",
62
+ PCM16 = "pcm16",
63
+ WAV = "wav"
64
+ }
65
+ export declare class AudioParameters {
66
+ /**
67
+ * Specifies the voice type.
68
+ */
69
+ voice?: Voice;
70
+ /**
71
+ * Specifies the output audio format.
72
+ */
73
+ format?: AudioResponseFormat;
74
+ }
75
+ /**
76
+ * Creates a model response for the given chat conversation.
77
+ */
78
+ export declare class ChatCompletionRequest {
79
+ /**
80
+ * A list of messages comprising the conversation so far.
81
+ */
82
+ messages: ChatCompletionMessage[];
83
+ /**
84
+ * ID of the model to use.
85
+ */
86
+ model: string;
87
+ /**
88
+ * Whether to store the output of this chat completion request for use in OpenAI's model distillation or evals products.
89
+ */
90
+ store?: boolean;
91
+ /**
92
+ * Developer-defined tags and values used for filtering completions in the OpenAI's dashboard.
93
+ */
94
+ metadata?: Record<string, any>;
95
+ /**
96
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far,
97
+ * decreasing the model's likelihood to repeat the same line verbatim.
98
+ */
99
+ frequencyPenalty?: number;
100
+ /**
101
+ * Modify the likelihood of specified tokens appearing in the completion.
102
+ * Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100.
103
+ */
104
+ logitBias?: Record<string, number>;
105
+ /**
106
+ * Whether to return log probabilities of the output tokens or not.
107
+ */
108
+ logprobs?: boolean;
109
+ /**
110
+ * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
111
+ */
112
+ topLogprobs?: number;
113
+ /**
114
+ * @deprecated The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
115
+ */
116
+ maxTokens?: number;
117
+ /**
118
+ * An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
119
+ */
120
+ maxCompletionTokens?: number;
121
+ /**
122
+ * How many chat completion choices to generate for each input message.
123
+ */
124
+ n?: number;
125
+ /**
126
+ * Output types that you would like the model to generate for this request.
127
+ */
128
+ outputModalities?: OutputModality[];
129
+ /**
130
+ * Parameters for audio output. Required when audio output is requested with outputModalities: ["audio"].
131
+ */
132
+ audioParameters?: AudioParameters;
133
+ /**
134
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far,
135
+ * increasing the model's likelihood to talk about new topics.
136
+ */
137
+ presencePenalty?: number;
138
+ /**
139
+ * An object specifying the format that the model must output.
140
+ */
141
+ responseFormat?: ResponseFormat;
142
+ /**
143
+ * If specified, our system will make a best effort to sample deterministically,
144
+ * such that repeated requests with the same seed and parameters should return the same result.
145
+ */
146
+ seed?: number;
147
+ /**
148
+ * Specifies the latency tier to use for processing the request.
149
+ */
150
+ serviceTier?: string;
151
+ /**
152
+ * Up to 4 sequences where the API will stop generating further tokens.
153
+ */
154
+ stop?: string[];
155
+ /**
156
+ * Options for streaming response.
157
+ */
158
+ stream?: boolean;
159
+ /**
160
+ * The format to return the response in. Currently, the only accepted value is "json".
161
+ */
162
+ streamOptions?: StreamOptions;
163
+ /**
164
+ * What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random,
165
+ * while lower values like 0.2 will make it more focused and deterministic.
166
+ */
167
+ temperature?: number;
168
+ /**
169
+ * An alternative to sampling with temperature, called nucleus sampling,
170
+ * where the model considers the results of the tokens with top_p probability mass.
171
+ */
172
+ topP?: number;
173
+ /**
174
+ * A list of tools the model may call. Currently, only functions are supported as a tool.
175
+ */
176
+ tools?: FunctionTool[];
177
+ /**
178
+ * Controls which (if any) function is called by the model.
179
+ */
180
+ toolChoice?: Record<string, any>;
181
+ /**
182
+ * If set to true, the model will call all functions in the tools list in parallel. Otherwise,
183
+ * the model will call the functions in the tools list in the order they are provided.
184
+ */
185
+ parallelToolCalls?: boolean;
186
+ /**
187
+ * A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
188
+ */
189
+ user?: string;
190
+ /**
191
+ * Static predicted output content, such as the content of a text file that is
192
+ * being regenerated.
193
+ */
194
+ prediction?: Prediction | null;
195
+ /**
196
+ * Extra parameters to be added to the request.
197
+ */
198
+ extra?: Record<string, unknown>;
199
+ /**
200
+ * An optional signal to abort the request.
201
+ */
202
+ signal?: AbortSignal;
203
+ }
@@ -0,0 +1,236 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Exclude, Expose, Type } from 'class-transformer';
11
+ import { ChatCompletionMessage } from './message.js';
12
+ import { ResponseFormat } from './response-format.js';
13
+ export class StreamOptions {
14
+ constructor(includeUsage) {
15
+ this.includeUsage = includeUsage;
16
+ }
17
+ }
18
+ StreamOptions.INCLUDE_USAGE = new StreamOptions(true);
19
+ __decorate([
20
+ Expose({ name: 'include_usage' }),
21
+ __metadata("design:type", Boolean)
22
+ ], StreamOptions.prototype, "includeUsage", void 0);
23
+ /**
24
+ * Function definition.
25
+ */
26
+ export class Function {
27
+ static create(description, name, parameters, strict) {
28
+ const func = new Function();
29
+ func.description = description;
30
+ func.name = name;
31
+ func.parameters = parameters;
32
+ func.strict = strict;
33
+ return func;
34
+ }
35
+ }
36
+ __decorate([
37
+ Expose(),
38
+ __metadata("design:type", String)
39
+ ], Function.prototype, "description", void 0);
40
+ __decorate([
41
+ Expose(),
42
+ __metadata("design:type", String)
43
+ ], Function.prototype, "name", void 0);
44
+ __decorate([
45
+ Expose(),
46
+ __metadata("design:type", Object)
47
+ ], Function.prototype, "parameters", void 0);
48
+ __decorate([
49
+ Expose(),
50
+ __metadata("design:type", Boolean)
51
+ ], Function.prototype, "strict", void 0);
52
+ export var ToolType;
53
+ (function (ToolType) {
54
+ /**
55
+ * Function tool type.
56
+ */
57
+ ToolType["FUNCTION"] = "function";
58
+ })(ToolType || (ToolType = {}));
59
+ export class FunctionTool {
60
+ static create(func) {
61
+ const tool = new FunctionTool();
62
+ tool.type = ToolType.FUNCTION;
63
+ tool.function = func;
64
+ return tool;
65
+ }
66
+ }
67
+ __decorate([
68
+ Expose(),
69
+ __metadata("design:type", String)
70
+ ], FunctionTool.prototype, "type", void 0);
71
+ __decorate([
72
+ Type(() => Function),
73
+ Expose(),
74
+ __metadata("design:type", Function)
75
+ ], FunctionTool.prototype, "function", void 0);
76
+ /**
77
+ * The type of modality for the model completion.
78
+ */
79
+ export var OutputModality;
80
+ (function (OutputModality) {
81
+ OutputModality["AUDIO"] = "audio";
82
+ OutputModality["TEXT"] = "text";
83
+ })(OutputModality || (OutputModality = {}));
84
+ export var Voice;
85
+ (function (Voice) {
86
+ Voice["ALLOY"] = "alloy";
87
+ Voice["ECHO"] = "echo";
88
+ Voice["FABLE"] = "fable";
89
+ Voice["ONYX"] = "onyx";
90
+ Voice["NOVA"] = "nova";
91
+ Voice["SHIMMER"] = "shimmer";
92
+ })(Voice || (Voice = {}));
93
+ export var AudioResponseFormat;
94
+ (function (AudioResponseFormat) {
95
+ AudioResponseFormat["MP3"] = "mp3";
96
+ AudioResponseFormat["FLAC"] = "flac";
97
+ AudioResponseFormat["OPUS"] = "opus";
98
+ AudioResponseFormat["PCM16"] = "pcm16";
99
+ AudioResponseFormat["WAV"] = "wav";
100
+ })(AudioResponseFormat || (AudioResponseFormat = {}));
101
+ export class AudioParameters {
102
+ }
103
+ __decorate([
104
+ Expose(),
105
+ __metadata("design:type", String)
106
+ ], AudioParameters.prototype, "voice", void 0);
107
+ __decorate([
108
+ Expose({ name: 'response_format' }),
109
+ __metadata("design:type", String)
110
+ ], AudioParameters.prototype, "format", void 0);
111
+ /**
112
+ * Creates a model response for the given chat conversation.
113
+ */
114
+ export class ChatCompletionRequest {
115
+ }
116
+ __decorate([
117
+ Type(() => ChatCompletionMessage),
118
+ Expose(),
119
+ __metadata("design:type", Array)
120
+ ], ChatCompletionRequest.prototype, "messages", void 0);
121
+ __decorate([
122
+ Expose(),
123
+ __metadata("design:type", String)
124
+ ], ChatCompletionRequest.prototype, "model", void 0);
125
+ __decorate([
126
+ Expose(),
127
+ __metadata("design:type", Boolean)
128
+ ], ChatCompletionRequest.prototype, "store", void 0);
129
+ __decorate([
130
+ Expose(),
131
+ __metadata("design:type", Object)
132
+ ], ChatCompletionRequest.prototype, "metadata", void 0);
133
+ __decorate([
134
+ Expose({ name: 'frequency_penalty' }),
135
+ __metadata("design:type", Number)
136
+ ], ChatCompletionRequest.prototype, "frequencyPenalty", void 0);
137
+ __decorate([
138
+ Expose({ name: 'logit_bias' }),
139
+ __metadata("design:type", Object)
140
+ ], ChatCompletionRequest.prototype, "logitBias", void 0);
141
+ __decorate([
142
+ Expose(),
143
+ __metadata("design:type", Boolean)
144
+ ], ChatCompletionRequest.prototype, "logprobs", void 0);
145
+ __decorate([
146
+ Expose({ name: 'top_logprobs' }),
147
+ __metadata("design:type", Number)
148
+ ], ChatCompletionRequest.prototype, "topLogprobs", void 0);
149
+ __decorate([
150
+ Expose({ name: 'max_tokens' }),
151
+ __metadata("design:type", Number)
152
+ ], ChatCompletionRequest.prototype, "maxTokens", void 0);
153
+ __decorate([
154
+ Expose({ name: 'max_completion_tokens' }),
155
+ __metadata("design:type", Number)
156
+ ], ChatCompletionRequest.prototype, "maxCompletionTokens", void 0);
157
+ __decorate([
158
+ Expose(),
159
+ __metadata("design:type", Number)
160
+ ], ChatCompletionRequest.prototype, "n", void 0);
161
+ __decorate([
162
+ Expose({ name: 'output_modalities' }),
163
+ __metadata("design:type", Array)
164
+ ], ChatCompletionRequest.prototype, "outputModalities", void 0);
165
+ __decorate([
166
+ Expose({ name: 'audio_parameters' }),
167
+ Type(() => AudioParameters),
168
+ __metadata("design:type", AudioParameters)
169
+ ], ChatCompletionRequest.prototype, "audioParameters", void 0);
170
+ __decorate([
171
+ Expose({ name: 'presence_penalty' }),
172
+ __metadata("design:type", Number)
173
+ ], ChatCompletionRequest.prototype, "presencePenalty", void 0);
174
+ __decorate([
175
+ Expose({ name: 'response_format' }),
176
+ Type(() => ResponseFormat),
177
+ __metadata("design:type", ResponseFormat)
178
+ ], ChatCompletionRequest.prototype, "responseFormat", void 0);
179
+ __decorate([
180
+ Expose(),
181
+ __metadata("design:type", Number)
182
+ ], ChatCompletionRequest.prototype, "seed", void 0);
183
+ __decorate([
184
+ Expose({ name: 'service_tier' }),
185
+ __metadata("design:type", String)
186
+ ], ChatCompletionRequest.prototype, "serviceTier", void 0);
187
+ __decorate([
188
+ Expose(),
189
+ __metadata("design:type", Array)
190
+ ], ChatCompletionRequest.prototype, "stop", void 0);
191
+ __decorate([
192
+ Expose(),
193
+ __metadata("design:type", Boolean)
194
+ ], ChatCompletionRequest.prototype, "stream", void 0);
195
+ __decorate([
196
+ Expose({ name: 'stream_options' }),
197
+ Type(() => StreamOptions),
198
+ __metadata("design:type", StreamOptions)
199
+ ], ChatCompletionRequest.prototype, "streamOptions", void 0);
200
+ __decorate([
201
+ Expose(),
202
+ __metadata("design:type", Number)
203
+ ], ChatCompletionRequest.prototype, "temperature", void 0);
204
+ __decorate([
205
+ Expose({ name: 'top_p' }),
206
+ __metadata("design:type", Number)
207
+ ], ChatCompletionRequest.prototype, "topP", void 0);
208
+ __decorate([
209
+ Type(() => FunctionTool),
210
+ __metadata("design:type", Array)
211
+ ], ChatCompletionRequest.prototype, "tools", void 0);
212
+ __decorate([
213
+ Expose({ name: 'tool_choice' }),
214
+ __metadata("design:type", Object)
215
+ ], ChatCompletionRequest.prototype, "toolChoice", void 0);
216
+ __decorate([
217
+ Expose({ name: 'parallel_tool_calls' }),
218
+ __metadata("design:type", Boolean)
219
+ ], ChatCompletionRequest.prototype, "parallelToolCalls", void 0);
220
+ __decorate([
221
+ Expose(),
222
+ __metadata("design:type", String)
223
+ ], ChatCompletionRequest.prototype, "user", void 0);
224
+ __decorate([
225
+ Expose(),
226
+ __metadata("design:type", Object)
227
+ ], ChatCompletionRequest.prototype, "prediction", void 0);
228
+ __decorate([
229
+ Expose(),
230
+ __metadata("design:type", Object)
231
+ ], ChatCompletionRequest.prototype, "extra", void 0);
232
+ __decorate([
233
+ Exclude(),
234
+ __metadata("design:type", AbortSignal)
235
+ ], ChatCompletionRequest.prototype, "signal", void 0);
236
+ //# sourceMappingURL=chat-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-request.js","sourceRoot":"","sources":["../../../src/common/api/chat-request.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,c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@@ -0,0 +1,192 @@
1
+ import { ChatCompletionFinishReason, ChatCompletionMessage } from './message.js';
2
+ import { Usage } from './usage.js';
3
+ /**
4
+ * The most likely tokens and their log probability, at this token position.
5
+ */
6
+ export declare class TopLogProbs {
7
+ /**
8
+ * The token.
9
+ */
10
+ token: string;
11
+ /**
12
+ * The log probability of the token.
13
+ */
14
+ logprob: number;
15
+ /**
16
+ * A list of integers representing the UTF-8 bytes
17
+ * representation of the token. Useful in instances where characters are represented by multiple
18
+ * tokens and their byte representations must be combined to generate the correct
19
+ * text representation. Can be null if there is no bytes representation for the
20
+ * token.
21
+ */
22
+ probBytes: number[];
23
+ }
24
+ /**
25
+ * Message content tokens with log probability information.
26
+ */
27
+ export declare class Content {
28
+ /**
29
+ * The token.
30
+ */
31
+ token: string;
32
+ /**
33
+ * The log probability of the token.
34
+ */
35
+ logprob: number;
36
+ /**
37
+ * A list of integers representing the UTF-8 bytes representation
38
+ * of the token. Useful in instances where characters are represented by multiple
39
+ * tokens and their byte representations must be combined to generate the correct
40
+ * text representation. Can be null if there is no bytes representation for the
41
+ * token.
42
+ */
43
+ probBytes: number[];
44
+ /**
45
+ * List of the most likely tokens and their log probability, at
46
+ * this token position. In rare cases, there may be fewer than the number of
47
+ * requested top_logprobs returned.
48
+ */
49
+ topLogprobs: TopLogProbs[];
50
+ }
51
+ /**
52
+ * Log probability information for the choice.
53
+ */
54
+ export declare class LogProbs {
55
+ /**
56
+ * Message content tokens with log probability information.
57
+ */
58
+ content: Content[];
59
+ /**
60
+ * Message refusal tokens with log probability information.
61
+ */
62
+ refusal: Content[];
63
+ }
64
+ /**
65
+ * Chat completion choice.
66
+ */
67
+ export declare class Choice {
68
+ /**
69
+ * The reason the model stopped generating tokens.
70
+ */
71
+ finishReason: ChatCompletionFinishReason;
72
+ /**
73
+ * The index of the choice in the list of choices.
74
+ */
75
+ index: number;
76
+ /**
77
+ * A chat completion message generated by the model.
78
+ */
79
+ message: ChatCompletionMessage;
80
+ /**
81
+ * Log probability information for the choice.
82
+ */
83
+ logprobs: LogProbs;
84
+ }
85
+ /**
86
+ * Represents a chat completion response returned by model, based on the provided
87
+ * input.
88
+ */
89
+ export declare class ChatCompletion {
90
+ /**
91
+ * A unique identifier for the chat completion.
92
+ */
93
+ id: string;
94
+ /**
95
+ * A list of chat completion choices. Can be more than one if n is
96
+ * greater than 1.
97
+ */
98
+ choices: Choice[];
99
+ /**
100
+ * The Unix timestamp (in seconds) of when the chat completion was
101
+ * created.
102
+ */
103
+ created: number;
104
+ /**
105
+ * The model used for the chat completion.
106
+ */
107
+ model: string;
108
+ /**
109
+ * The service tier used for processing the request. This field is
110
+ * only included if the service_tier parameter is specified in the request.
111
+ */
112
+ serviceTier: string;
113
+ /**
114
+ * This fingerprint represents the backend configuration that
115
+ * the model runs with. Can be used in conjunction with the seed request parameter to
116
+ * understand when backend changes have been made that might impact determinism.
117
+ */
118
+ systemFingerprint: string;
119
+ /**
120
+ * The object type, which is always chat.completion.
121
+ */
122
+ object: string;
123
+ /**
124
+ * Usage statistics for the completion request.
125
+ */
126
+ usage: Usage;
127
+ }
128
+ /**
129
+ * Chat completion choice.
130
+ */
131
+ export declare class ChunkChoice {
132
+ /**
133
+ * The reason the model stopped generating tokens.
134
+ */
135
+ finishReason: ChatCompletionFinishReason;
136
+ /**
137
+ * The index of the choice in the list of choices.
138
+ */
139
+ index: number;
140
+ /**
141
+ * A chat completion delta generated by streamed model responses.
142
+ */
143
+ delta: ChatCompletionMessage;
144
+ /**
145
+ * Log probability information for the choice.
146
+ */
147
+ logprobs: LogProbs;
148
+ }
149
+ /**
150
+ * Represents a streamed chunk of a chat completion response returned by model, based
151
+ * on the provided input.
152
+ */
153
+ export declare class ChatCompletionChunk {
154
+ /**
155
+ * A unique identifier for the chat completion. Each chunk has the same ID.
156
+ */
157
+ id: string;
158
+ /**
159
+ * A list of chat completion choices. Can be more than one if n is
160
+ * greater than 1.
161
+ */
162
+ choices: ChunkChoice[];
163
+ /**
164
+ * The Unix timestamp (in seconds) of when the chat completion was
165
+ * created. Each chunk has the same timestamp.
166
+ */
167
+ created: number;
168
+ /**
169
+ * The model used for the chat completion.
170
+ */
171
+ model: string;
172
+ /**
173
+ * The service tier used for processing the request. This field is
174
+ * only included if the service_tier parameter is specified in the request.
175
+ */
176
+ serviceTier: string;
177
+ /**
178
+ * This fingerprint represents the backend configuration that
179
+ * the model runs with. Can be used in conjunction with the seed request parameter to
180
+ * understand when backend changes have been made that might impact determinism.
181
+ */
182
+ systemFingerprint: string;
183
+ /**
184
+ * The object type, which is always 'chat.completion.chunk'.
185
+ */
186
+ object: string;
187
+ /**
188
+ * Usage statistics for the completion request. Present in the last chunk
189
+ * only if the StreamOptions.includeUsage is set to true.
190
+ */
191
+ usage: Usage;
192
+ }