@celljs/ai-openai 3.8.0 → 4.0.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.
- package/esm/common/api/api-protocol.d.ts +46 -0
- package/esm/common/api/api-protocol.js +3 -0
- package/esm/common/api/api-protocol.js.map +1 -0
- package/esm/common/api/chat-request.d.ts +203 -0
- package/esm/common/api/chat-request.js +236 -0
- package/esm/common/api/chat-request.js.map +1 -0
- package/esm/common/api/chat-response.d.ts +192 -0
- package/esm/common/api/chat-response.js +191 -0
- package/esm/common/api/chat-response.js.map +1 -0
- package/esm/common/api/embeddings-request.d.ts +62 -0
- package/esm/common/api/embeddings-request.js +85 -0
- package/esm/common/api/embeddings-request.js.map +1 -0
- package/esm/common/api/embeddings-response.d.ts +26 -0
- package/esm/common/api/embeddings-response.js +44 -0
- package/esm/common/api/embeddings-response.js.map +1 -0
- package/esm/common/api/index.d.ts +9 -0
- package/esm/common/api/index.js +10 -0
- package/esm/common/api/index.js.map +1 -0
- package/esm/common/api/message.d.ts +215 -0
- package/esm/common/api/message.js +250 -0
- package/esm/common/api/message.js.map +1 -0
- package/esm/common/api/openai-api.d.ts +18 -0
- package/esm/common/api/openai-api.js +118 -0
- package/esm/common/api/openai-api.js.map +1 -0
- package/esm/common/api/openai-model.d.ts +116 -0
- package/esm/common/api/openai-model.js +118 -0
- package/esm/common/api/openai-model.js.map +1 -0
- package/esm/common/api/response-format.d.ts +59 -0
- package/esm/common/api/response-format.js +107 -0
- package/esm/common/api/response-format.js.map +1 -0
- package/esm/common/api/usage.d.ts +78 -0
- package/esm/common/api/usage.js +106 -0
- package/esm/common/api/usage.js.map +1 -0
- package/esm/common/index.d.ts +3 -0
- package/esm/common/index.js +4 -0
- package/esm/common/index.js.map +1 -0
- package/esm/common/model/index.d.ts +4 -0
- package/esm/common/model/index.js +5 -0
- package/esm/common/model/index.js.map +1 -0
- package/esm/common/model/openai-chat-model.d.ts +36 -0
- package/esm/common/model/openai-chat-model.js +363 -0
- package/esm/common/model/openai-chat-model.js.map +1 -0
- package/esm/common/model/openai-chat-options.d.ts +169 -0
- package/esm/common/model/openai-chat-options.js +274 -0
- package/esm/common/model/openai-chat-options.js.map +1 -0
- package/esm/common/model/openai-embedding-model.d.ts +14 -0
- package/esm/common/model/openai-embedding-model.js +69 -0
- package/esm/common/model/openai-embedding-model.js.map +1 -0
- package/esm/common/model/openai-embedding-options.d.ts +34 -0
- package/esm/common/model/openai-embedding-options.js +72 -0
- package/esm/common/model/openai-embedding-options.js.map +1 -0
- package/esm/common/module.d.ts +3 -0
- package/esm/common/module.js +4 -0
- package/esm/common/module.js.map +1 -0
- package/esm/common/support/index.d.ts +2 -0
- package/esm/common/support/index.js +3 -0
- package/esm/common/support/index.js.map +1 -0
- package/esm/common/support/openai-api-response-headers.d.ts +33 -0
- package/esm/common/support/openai-api-response-headers.js +42 -0
- package/esm/common/support/openai-api-response-headers.js.map +1 -0
- package/esm/common/support/openai-response-header-extractor.d.ts +11 -0
- package/esm/common/support/openai-response-header-extractor.js +129 -0
- package/esm/common/support/openai-response-header-extractor.js.map +1 -0
- package/esm/common/test/mock-openai-api.d.ts +12 -0
- package/esm/common/test/mock-openai-api.js +53 -0
- package/esm/common/test/mock-openai-api.js.map +1 -0
- package/esm/common/test/test-container.d.ts +2 -0
- package/esm/common/test/test-container.js +12 -0
- package/esm/common/test/test-container.js.map +1 -0
- package/esm/package.json +3 -0
- package/package.json +49 -6
|
@@ -0,0 +1,191 @@
|
|
|
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 { Expose, Type } from 'class-transformer';
|
|
11
|
+
import { ChatCompletionFinishReason, ChatCompletionMessage } from './message.js';
|
|
12
|
+
import { Usage } from './usage.js';
|
|
13
|
+
/**
|
|
14
|
+
* The most likely tokens and their log probability, at this token position.
|
|
15
|
+
*/
|
|
16
|
+
export class TopLogProbs {
|
|
17
|
+
}
|
|
18
|
+
__decorate([
|
|
19
|
+
Expose(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], TopLogProbs.prototype, "token", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
Expose(),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], TopLogProbs.prototype, "logprob", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
Expose({ name: 'bytes' }),
|
|
28
|
+
__metadata("design:type", Array)
|
|
29
|
+
], TopLogProbs.prototype, "probBytes", void 0);
|
|
30
|
+
/**
|
|
31
|
+
* Message content tokens with log probability information.
|
|
32
|
+
*/
|
|
33
|
+
export class Content {
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
Expose(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], Content.prototype, "token", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Expose(),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], Content.prototype, "logprob", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
Expose({ name: 'bytes' }),
|
|
45
|
+
__metadata("design:type", Array)
|
|
46
|
+
], Content.prototype, "probBytes", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
Expose({ name: 'top_logprobs' }),
|
|
49
|
+
__metadata("design:type", Array)
|
|
50
|
+
], Content.prototype, "topLogprobs", void 0);
|
|
51
|
+
/**
|
|
52
|
+
* Log probability information for the choice.
|
|
53
|
+
*/
|
|
54
|
+
export class LogProbs {
|
|
55
|
+
}
|
|
56
|
+
__decorate([
|
|
57
|
+
Type(() => Content),
|
|
58
|
+
Expose(),
|
|
59
|
+
__metadata("design:type", Array)
|
|
60
|
+
], LogProbs.prototype, "content", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
Type(() => Content),
|
|
63
|
+
Expose(),
|
|
64
|
+
__metadata("design:type", Array)
|
|
65
|
+
], LogProbs.prototype, "refusal", void 0);
|
|
66
|
+
/**
|
|
67
|
+
* Chat completion choice.
|
|
68
|
+
*/
|
|
69
|
+
export class Choice {
|
|
70
|
+
}
|
|
71
|
+
__decorate([
|
|
72
|
+
Expose({ name: 'finish_reason' }),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], Choice.prototype, "finishReason", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
Expose(),
|
|
77
|
+
__metadata("design:type", Number)
|
|
78
|
+
], Choice.prototype, "index", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
Type(() => ChatCompletionMessage),
|
|
81
|
+
__metadata("design:type", ChatCompletionMessage)
|
|
82
|
+
], Choice.prototype, "message", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
Type(() => LogProbs),
|
|
85
|
+
Expose(),
|
|
86
|
+
__metadata("design:type", LogProbs)
|
|
87
|
+
], Choice.prototype, "logprobs", void 0);
|
|
88
|
+
/**
|
|
89
|
+
* Represents a chat completion response returned by model, based on the provided
|
|
90
|
+
* input.
|
|
91
|
+
*/
|
|
92
|
+
export class ChatCompletion {
|
|
93
|
+
}
|
|
94
|
+
__decorate([
|
|
95
|
+
Expose(),
|
|
96
|
+
__metadata("design:type", String)
|
|
97
|
+
], ChatCompletion.prototype, "id", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
Type(() => Choice),
|
|
100
|
+
Expose(),
|
|
101
|
+
__metadata("design:type", Array)
|
|
102
|
+
], ChatCompletion.prototype, "choices", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
Expose(),
|
|
105
|
+
__metadata("design:type", Number)
|
|
106
|
+
], ChatCompletion.prototype, "created", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
Expose(),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], ChatCompletion.prototype, "model", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
Expose({ name: 'service_tier' }),
|
|
113
|
+
__metadata("design:type", String)
|
|
114
|
+
], ChatCompletion.prototype, "serviceTier", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
Expose({ name: 'system_fingerprint' }),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], ChatCompletion.prototype, "systemFingerprint", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
Expose(),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], ChatCompletion.prototype, "object", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
Type(() => Usage),
|
|
125
|
+
Expose(),
|
|
126
|
+
__metadata("design:type", Usage)
|
|
127
|
+
], ChatCompletion.prototype, "usage", void 0);
|
|
128
|
+
/**
|
|
129
|
+
* Chat completion choice.
|
|
130
|
+
*/
|
|
131
|
+
export class ChunkChoice {
|
|
132
|
+
}
|
|
133
|
+
__decorate([
|
|
134
|
+
Expose({ name: 'finish_reason' }),
|
|
135
|
+
__metadata("design:type", String)
|
|
136
|
+
], ChunkChoice.prototype, "finishReason", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
Expose(),
|
|
139
|
+
__metadata("design:type", Number)
|
|
140
|
+
], ChunkChoice.prototype, "index", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
Type(() => ChatCompletionMessage),
|
|
143
|
+
Expose(),
|
|
144
|
+
__metadata("design:type", ChatCompletionMessage)
|
|
145
|
+
], ChunkChoice.prototype, "delta", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
Type(() => LogProbs),
|
|
148
|
+
Expose(),
|
|
149
|
+
__metadata("design:type", LogProbs)
|
|
150
|
+
], ChunkChoice.prototype, "logprobs", void 0);
|
|
151
|
+
/**
|
|
152
|
+
* Represents a streamed chunk of a chat completion response returned by model, based
|
|
153
|
+
* on the provided input.
|
|
154
|
+
*/
|
|
155
|
+
export class ChatCompletionChunk {
|
|
156
|
+
}
|
|
157
|
+
__decorate([
|
|
158
|
+
Expose(),
|
|
159
|
+
__metadata("design:type", String)
|
|
160
|
+
], ChatCompletionChunk.prototype, "id", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
Type(() => ChunkChoice),
|
|
163
|
+
Expose(),
|
|
164
|
+
__metadata("design:type", Array)
|
|
165
|
+
], ChatCompletionChunk.prototype, "choices", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
Expose(),
|
|
168
|
+
__metadata("design:type", Number)
|
|
169
|
+
], ChatCompletionChunk.prototype, "created", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
Expose(),
|
|
172
|
+
__metadata("design:type", String)
|
|
173
|
+
], ChatCompletionChunk.prototype, "model", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
Expose({ name: 'service_tier' }),
|
|
176
|
+
__metadata("design:type", String)
|
|
177
|
+
], ChatCompletionChunk.prototype, "serviceTier", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
Expose({ name: 'system_fingerprint' }),
|
|
180
|
+
__metadata("design:type", String)
|
|
181
|
+
], ChatCompletionChunk.prototype, "systemFingerprint", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
Expose(),
|
|
184
|
+
__metadata("design:type", String)
|
|
185
|
+
], ChatCompletionChunk.prototype, "object", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
Type(() => Usage),
|
|
188
|
+
Expose(),
|
|
189
|
+
__metadata("design:type", Usage)
|
|
190
|
+
], ChatCompletionChunk.prototype, "usage", void 0);
|
|
191
|
+
//# sourceMappingURL=chat-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-response.js","sourceRoot":"","sources":["../../../src/common/api/chat-response.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an embedding vector returned by embedding endpoint.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Embedding {
|
|
5
|
+
/**
|
|
6
|
+
* The index of the embedding in the list of embeddings.
|
|
7
|
+
*/
|
|
8
|
+
index: number;
|
|
9
|
+
/**
|
|
10
|
+
* The embedding vector, which is a list of floats. The length of vector depends on the model.
|
|
11
|
+
*/
|
|
12
|
+
embedding: number[];
|
|
13
|
+
/**
|
|
14
|
+
* The object type, which is always 'embedding'.
|
|
15
|
+
*/
|
|
16
|
+
object: string;
|
|
17
|
+
constructor(index: number, embedding: number[], object?: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an embedding vector representing the input text.
|
|
21
|
+
*/
|
|
22
|
+
export declare class EmbeddingRequest<T> {
|
|
23
|
+
/**
|
|
24
|
+
* Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request,
|
|
25
|
+
* pass an array of strings or array of token arrays.
|
|
26
|
+
* The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002),
|
|
27
|
+
* cannot be an empty string, and any array must be 2048 dimensions or less.
|
|
28
|
+
*/
|
|
29
|
+
input: T;
|
|
30
|
+
/**
|
|
31
|
+
* ID of the model to use.
|
|
32
|
+
*/
|
|
33
|
+
model: string;
|
|
34
|
+
/**
|
|
35
|
+
* The format to return the embeddings in. Can be either float or base64.
|
|
36
|
+
*/
|
|
37
|
+
encodingFormat: string;
|
|
38
|
+
/**
|
|
39
|
+
* The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.
|
|
40
|
+
*/
|
|
41
|
+
dimensions?: number;
|
|
42
|
+
/**
|
|
43
|
+
* A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
|
|
44
|
+
*/
|
|
45
|
+
user?: string;
|
|
46
|
+
/**
|
|
47
|
+
* An optional signal to abort the request.
|
|
48
|
+
*/
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
constructor(input: T, model: string, encodingFormat?: string, dimensions?: number, user?: string, signal?: AbortSignal);
|
|
51
|
+
/**
|
|
52
|
+
* Create an embedding request with the given input, model and encoding format set to float.
|
|
53
|
+
* @param input Input text to embed.
|
|
54
|
+
* @param model ID of the model to use.
|
|
55
|
+
*/
|
|
56
|
+
static fromInputAndModel<T>(input: T, model: string): EmbeddingRequest<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Create an embedding request with the given input. Encoding format is set to float and user is null and the model is set to 'text-embedding-ada-002'.
|
|
59
|
+
* @param input Input text to embed.
|
|
60
|
+
*/
|
|
61
|
+
static fromInput<T>(input: T): EmbeddingRequest<T>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 } from 'class-transformer';
|
|
11
|
+
/**
|
|
12
|
+
* Represents an embedding vector returned by embedding endpoint.
|
|
13
|
+
*/
|
|
14
|
+
export class Embedding {
|
|
15
|
+
constructor(index, embedding, object = 'embedding') {
|
|
16
|
+
this.index = index;
|
|
17
|
+
this.embedding = embedding;
|
|
18
|
+
this.object = object;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__decorate([
|
|
22
|
+
Expose(),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], Embedding.prototype, "index", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
Expose(),
|
|
27
|
+
__metadata("design:type", Array)
|
|
28
|
+
], Embedding.prototype, "embedding", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
Expose(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Embedding.prototype, "object", void 0);
|
|
33
|
+
/**
|
|
34
|
+
* Creates an embedding vector representing the input text.
|
|
35
|
+
*/
|
|
36
|
+
export class EmbeddingRequest {
|
|
37
|
+
constructor(input, model, encodingFormat = 'float', dimensions, user, signal) {
|
|
38
|
+
this.input = input;
|
|
39
|
+
this.model = model;
|
|
40
|
+
this.encodingFormat = encodingFormat;
|
|
41
|
+
this.dimensions = dimensions;
|
|
42
|
+
this.user = user;
|
|
43
|
+
this.signal = signal;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create an embedding request with the given input, model and encoding format set to float.
|
|
47
|
+
* @param input Input text to embed.
|
|
48
|
+
* @param model ID of the model to use.
|
|
49
|
+
*/
|
|
50
|
+
static fromInputAndModel(input, model) {
|
|
51
|
+
return new EmbeddingRequest(input, model);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create an embedding request with the given input. Encoding format is set to float and user is null and the model is set to 'text-embedding-ada-002'.
|
|
55
|
+
* @param input Input text to embed.
|
|
56
|
+
*/
|
|
57
|
+
static fromInput(input) {
|
|
58
|
+
return new EmbeddingRequest(input, 'text-embedding-ada-002');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
__decorate([
|
|
62
|
+
Expose(),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], EmbeddingRequest.prototype, "input", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
Expose(),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], EmbeddingRequest.prototype, "model", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
Expose({ name: 'encoding_format' }),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], EmbeddingRequest.prototype, "encodingFormat", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
Expose(),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], EmbeddingRequest.prototype, "dimensions", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
Expose(),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], EmbeddingRequest.prototype, "user", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
Exclude(),
|
|
83
|
+
__metadata("design:type", AbortSignal)
|
|
84
|
+
], EmbeddingRequest.prototype, "signal", void 0);
|
|
85
|
+
//# sourceMappingURL=embeddings-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings-request.js","sourceRoot":"","sources":["../../../src/common/api/embeddings-request.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,SAAS;IAmBlB,YAAY,KAAa,EAAE,SAAmB,EAAE,MAAM,GAAG,WAAW;QAChE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAnBG;IADC,MAAM,EAAE;;wCACK;AAMd;IADC,MAAM,EAAE;;4CACW;AAMpB;IADC,MAAM,EAAE;;yCACM;AASnB;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAwCzB,YACI,KAAQ,EACR,KAAa,EACb,cAAc,GAAG,OAAO,EACxB,UAAmB,EACnB,IAAa,EACb,MAAoB;QAEpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CAAI,KAAQ,EAAE,KAAa;QAC/C,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAI,KAAQ;QACxB,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;IACjE,CAAC;CACJ;AAhEG;IADC,MAAM,EAAE;;+CACA;AAMT;IADC,MAAM,EAAE;;+CACK;AAMd;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;;wDACb;AAMvB;IADC,MAAM,EAAE;;oDACW;AAMpB;IADC,MAAM,EAAE;;8CACK;AAMd;IADC,OAAO,EAAE;8BACD,WAAW;gDAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Embedding } from './embeddings-request.js';
|
|
2
|
+
import { Usage } from './usage.js';
|
|
3
|
+
/**
|
|
4
|
+
* List of multiple embedding responses.
|
|
5
|
+
*
|
|
6
|
+
* @typeparam T Type of the entities in the data list.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EmbeddingResponse {
|
|
9
|
+
/**
|
|
10
|
+
* Must have value "list".
|
|
11
|
+
*/
|
|
12
|
+
object: string;
|
|
13
|
+
/**
|
|
14
|
+
* List of entities.
|
|
15
|
+
*/
|
|
16
|
+
data: Embedding[];
|
|
17
|
+
/**
|
|
18
|
+
* ID of the model to use.
|
|
19
|
+
*/
|
|
20
|
+
model: string;
|
|
21
|
+
/**
|
|
22
|
+
* Usage statistics for the completion request.
|
|
23
|
+
*/
|
|
24
|
+
usage: Usage;
|
|
25
|
+
constructor(object: string, data: Embedding[], model: string, usage: Usage);
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { Type, Expose } from 'class-transformer';
|
|
11
|
+
import { Embedding } from './embeddings-request.js';
|
|
12
|
+
import { Usage } from './usage.js';
|
|
13
|
+
/**
|
|
14
|
+
* List of multiple embedding responses.
|
|
15
|
+
*
|
|
16
|
+
* @typeparam T Type of the entities in the data list.
|
|
17
|
+
*/
|
|
18
|
+
export class EmbeddingResponse {
|
|
19
|
+
constructor(object, data, model, usage) {
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.data = data;
|
|
22
|
+
this.model = model;
|
|
23
|
+
this.usage = usage;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
__decorate([
|
|
27
|
+
Expose(),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], EmbeddingResponse.prototype, "object", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
Type(() => Embedding),
|
|
32
|
+
Expose(),
|
|
33
|
+
__metadata("design:type", Array)
|
|
34
|
+
], EmbeddingResponse.prototype, "data", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Expose(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], EmbeddingResponse.prototype, "model", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Type(() => Usage),
|
|
41
|
+
Expose(),
|
|
42
|
+
__metadata("design:type", Usage)
|
|
43
|
+
], EmbeddingResponse.prototype, "usage", void 0);
|
|
44
|
+
//# sourceMappingURL=embeddings-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings-response.js","sourceRoot":"","sources":["../../../src/common/api/embeddings-response.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IA2B1B,YACI,MAAc,EACd,IAAiB,EACjB,KAAa,EACb,KAAY;QAEZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAjCG;IADC,MAAM,EAAE;;iDACM;AAOf;IAFC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;IACrB,MAAM,EAAE;;+CACS;AAMlB;IADC,MAAM,EAAE;;gDACK;AAOd;IAFC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;IACjB,MAAM,EAAE;8BACF,KAAK;gDAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './api-protocol.js';
|
|
2
|
+
export * from './chat-request.js';
|
|
3
|
+
export * from './chat-response.js';
|
|
4
|
+
export * from './embeddings-request.js';
|
|
5
|
+
export * from './embeddings-response.js';
|
|
6
|
+
export * from './openai-api.js';
|
|
7
|
+
export * from './message.js';
|
|
8
|
+
export * from './openai-model.js';
|
|
9
|
+
export * from './response-format.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './api-protocol.js';
|
|
2
|
+
export * from './chat-request.js';
|
|
3
|
+
export * from './chat-response.js';
|
|
4
|
+
export * from './embeddings-request.js';
|
|
5
|
+
export * from './embeddings-response.js';
|
|
6
|
+
export * from './openai-api.js';
|
|
7
|
+
export * from './message.js';
|
|
8
|
+
export * from './openai-model.js';
|
|
9
|
+
export * from './response-format.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
export declare enum ChatCompletionFinishReason {
|
|
2
|
+
/**
|
|
3
|
+
* The model hit a natural stop point or a provided stop sequence.
|
|
4
|
+
*/
|
|
5
|
+
STOP = "stop",
|
|
6
|
+
/**
|
|
7
|
+
* The maximum number of tokens specified in the request was reached.
|
|
8
|
+
*/
|
|
9
|
+
LENGTH = "length",
|
|
10
|
+
/**
|
|
11
|
+
* The content was omitted due to a flag from our content filters.
|
|
12
|
+
*/
|
|
13
|
+
CONTENT_FILTER = "content_filter",
|
|
14
|
+
/**
|
|
15
|
+
* The model called a tool.
|
|
16
|
+
*/
|
|
17
|
+
TOOL_CALLS = "tool_calls",
|
|
18
|
+
/**
|
|
19
|
+
* Only for compatibility with Mistral AI API
|
|
20
|
+
*/
|
|
21
|
+
TOOL_CALL = "tool_call"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The role of the author of this message.
|
|
25
|
+
*/
|
|
26
|
+
export declare enum Role {
|
|
27
|
+
/**
|
|
28
|
+
* System message.
|
|
29
|
+
*/
|
|
30
|
+
SYSTEM = "system",
|
|
31
|
+
/**
|
|
32
|
+
* User message.
|
|
33
|
+
*/
|
|
34
|
+
USER = "user",
|
|
35
|
+
/**
|
|
36
|
+
* Assistant message.
|
|
37
|
+
*/
|
|
38
|
+
ASSISTANT = "assistant",
|
|
39
|
+
/**
|
|
40
|
+
* Tool message.
|
|
41
|
+
*/
|
|
42
|
+
TOOL = "tool"
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The function definition.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ChatCompletionFunction {
|
|
48
|
+
/**
|
|
49
|
+
* The name of the function.
|
|
50
|
+
*/
|
|
51
|
+
name: string;
|
|
52
|
+
/**
|
|
53
|
+
* The arguments that the model expects you to pass to the function.
|
|
54
|
+
*/
|
|
55
|
+
arguments: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The relevant tool call.
|
|
59
|
+
*/
|
|
60
|
+
export declare class ToolCall {
|
|
61
|
+
/**
|
|
62
|
+
* The index of the tool call in the list of tool calls. Required in
|
|
63
|
+
* case of streaming.
|
|
64
|
+
*/
|
|
65
|
+
index?: number;
|
|
66
|
+
/**
|
|
67
|
+
* The ID of the tool call. This ID must be referenced when you submit
|
|
68
|
+
* the tool outputs in using the Submit tool outputs to run endpoint.
|
|
69
|
+
*/
|
|
70
|
+
id: string;
|
|
71
|
+
/**
|
|
72
|
+
* The type of tool call the output is required for. For now, this is
|
|
73
|
+
* always function.
|
|
74
|
+
*/
|
|
75
|
+
type: string;
|
|
76
|
+
/**
|
|
77
|
+
* The function definition.
|
|
78
|
+
*/
|
|
79
|
+
function: ChatCompletionFunction;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Audio response from the model.
|
|
83
|
+
*/
|
|
84
|
+
export declare class AudioOutput {
|
|
85
|
+
/**
|
|
86
|
+
* Unique identifier for the audio response from the model.
|
|
87
|
+
*/
|
|
88
|
+
id?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Audio output from the model.
|
|
91
|
+
*/
|
|
92
|
+
data?: string;
|
|
93
|
+
/**
|
|
94
|
+
* When the audio content will no longer be available on the server.
|
|
95
|
+
*/
|
|
96
|
+
expiresAt?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Transcript of the audio output from the model.
|
|
99
|
+
*/
|
|
100
|
+
transcript?: string;
|
|
101
|
+
static create(id?: string, data?: string, expiresAt?: number, transcript?: string): AudioOutput;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The format of the encoded audio data. Currently supports "wav" and "mp3".
|
|
105
|
+
*/
|
|
106
|
+
export declare enum Format {
|
|
107
|
+
/**
|
|
108
|
+
* MP3 audio format.
|
|
109
|
+
*/
|
|
110
|
+
MP3 = "mp3",
|
|
111
|
+
/**
|
|
112
|
+
* WAV audio format.
|
|
113
|
+
*/
|
|
114
|
+
WAV = "wav"
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Audio input data.
|
|
118
|
+
*/
|
|
119
|
+
export declare class InputAudio {
|
|
120
|
+
/**
|
|
121
|
+
* Base64 encoded audio data.
|
|
122
|
+
*/
|
|
123
|
+
data: string;
|
|
124
|
+
/**
|
|
125
|
+
* The format of the encoded audio data. Currently supports "wav" and "mp3".
|
|
126
|
+
*/
|
|
127
|
+
format: Format;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Image content.
|
|
131
|
+
*/
|
|
132
|
+
export declare class ImageUrl {
|
|
133
|
+
/**
|
|
134
|
+
* Either a URL of the image or the base64 encoded image data. The
|
|
135
|
+
* base64 encoded image data must have a special prefix in the following
|
|
136
|
+
* format: "data:{mimetype};base64,{base64-encoded-image-data}".
|
|
137
|
+
*/
|
|
138
|
+
url: string;
|
|
139
|
+
/**
|
|
140
|
+
* Specifies the detail level of the image.
|
|
141
|
+
*/
|
|
142
|
+
detail?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* An array of content parts with a defined type. Each MediaContent can be of
|
|
146
|
+
* either "text", "image_url", or "input_audio" type. Only one option allowed.
|
|
147
|
+
*/
|
|
148
|
+
export declare class MediaContent {
|
|
149
|
+
/**
|
|
150
|
+
* Content type, each can be of type text or image_url.
|
|
151
|
+
*/
|
|
152
|
+
type: string;
|
|
153
|
+
/**
|
|
154
|
+
* The text content of the message.
|
|
155
|
+
*/
|
|
156
|
+
text: string;
|
|
157
|
+
/**
|
|
158
|
+
* The image content of the message. You can pass multiple images
|
|
159
|
+
* by adding multiple image_url content parts. Image input is only supported when
|
|
160
|
+
* using the gpt-4-visual-preview model.
|
|
161
|
+
*/
|
|
162
|
+
imageUrl: ImageUrl;
|
|
163
|
+
/**
|
|
164
|
+
* Audio content part.
|
|
165
|
+
*/
|
|
166
|
+
inputAudio: InputAudio;
|
|
167
|
+
static createText(text: string): MediaContent;
|
|
168
|
+
static createImageUrl(url: string, detail?: string): MediaContent;
|
|
169
|
+
static createInputAudio(data: string, format: Format): MediaContent;
|
|
170
|
+
}
|
|
171
|
+
export declare class ChatCompletionMessage {
|
|
172
|
+
/**
|
|
173
|
+
* The contents of the message. Can be either a {@link MediaContent}
|
|
174
|
+
* or a {@link String}. The response message content is always a {@link String}.
|
|
175
|
+
*/
|
|
176
|
+
content: any;
|
|
177
|
+
/**
|
|
178
|
+
* The role of the messages author. Could be one of the {@link Role}
|
|
179
|
+
* types.
|
|
180
|
+
*/
|
|
181
|
+
role: Role;
|
|
182
|
+
/**
|
|
183
|
+
* An optional name for the participant. Provides the model information to
|
|
184
|
+
* differentiate between participants of the same role. In case of Function calling,
|
|
185
|
+
* the name is the function name that the message is responding to.
|
|
186
|
+
*/
|
|
187
|
+
name?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Tool call that this message is responding to. Only applicable for
|
|
190
|
+
* the {@link Role#TOOL} role and null otherwise.
|
|
191
|
+
*/
|
|
192
|
+
toolCallId?: string;
|
|
193
|
+
/**
|
|
194
|
+
* The tool calls generated by the model, such as function calls.
|
|
195
|
+
* Applicable only for {@link Role#ASSISTANT} role and null otherwise.
|
|
196
|
+
*/
|
|
197
|
+
toolCalls?: ToolCall[];
|
|
198
|
+
/**
|
|
199
|
+
* The refusal message by the assistant. Applicable only for
|
|
200
|
+
* {@link Role#ASSISTANT} role and null otherwise.
|
|
201
|
+
*/
|
|
202
|
+
refusal?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Audio response from the model.
|
|
205
|
+
*/
|
|
206
|
+
audioOutput?: AudioOutput;
|
|
207
|
+
/**
|
|
208
|
+
* 创建一个新的聊天消息实例。
|
|
209
|
+
*
|
|
210
|
+
* @param text - 消息内容。
|
|
211
|
+
* @param role - 消息角色,表示发送者的身份。
|
|
212
|
+
* @returns 返回一个包含指定内容和角色的 ChatCompletionMessage 实例。
|
|
213
|
+
*/
|
|
214
|
+
static create(text: any, role: Role): ChatCompletionMessage;
|
|
215
|
+
}
|