@celljs/ai-openai 3.4.4
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/LICENSE +21 -0
- package/README.md +96 -0
- package/lib/common/api/api-protocol.d.ts +47 -0
- package/lib/common/api/api-protocol.d.ts.map +1 -0
- package/lib/common/api/api-protocol.js +6 -0
- package/lib/common/api/api-protocol.js.map +1 -0
- package/lib/common/api/chat-request.d.ts +198 -0
- package/lib/common/api/chat-request.d.ts.map +1 -0
- package/lib/common/api/chat-request.js +145 -0
- package/lib/common/api/chat-request.js.map +1 -0
- package/lib/common/api/chat-response.d.ts +193 -0
- package/lib/common/api/chat-response.d.ts.map +1 -0
- package/lib/common/api/chat-response.js +124 -0
- package/lib/common/api/chat-response.js.map +1 -0
- package/lib/common/api/embeddings-request.d.ts +59 -0
- package/lib/common/api/embeddings-request.d.ts.map +1 -0
- package/lib/common/api/embeddings-request.js +49 -0
- package/lib/common/api/embeddings-request.js.map +1 -0
- package/lib/common/api/embeddings-response.d.ts +27 -0
- package/lib/common/api/embeddings-response.d.ts.map +1 -0
- package/lib/common/api/embeddings-response.js +30 -0
- package/lib/common/api/embeddings-response.js.map +1 -0
- package/lib/common/api/index.d.ts +10 -0
- package/lib/common/api/index.d.ts.map +1 -0
- package/lib/common/api/index.js +13 -0
- package/lib/common/api/index.js.map +1 -0
- package/lib/common/api/message.d.ts +216 -0
- package/lib/common/api/message.d.ts.map +1 -0
- package/lib/common/api/message.js +179 -0
- package/lib/common/api/message.js.map +1 -0
- package/lib/common/api/openai-api.d.ts +18 -0
- package/lib/common/api/openai-api.d.ts.map +1 -0
- package/lib/common/api/openai-api.js +99 -0
- package/lib/common/api/openai-api.js.map +1 -0
- package/lib/common/api/openai-api.spec.d.ts +2 -0
- package/lib/common/api/openai-api.spec.d.ts.map +1 -0
- package/lib/common/api/openai-api.spec.js +162 -0
- package/lib/common/api/openai-api.spec.js.map +1 -0
- package/lib/common/api/openai-model.d.ts +117 -0
- package/lib/common/api/openai-model.d.ts.map +1 -0
- package/lib/common/api/openai-model.js +121 -0
- package/lib/common/api/openai-model.js.map +1 -0
- package/lib/common/api/response-format.d.ts +60 -0
- package/lib/common/api/response-format.d.ts.map +1 -0
- package/lib/common/api/response-format.js +79 -0
- package/lib/common/api/response-format.js.map +1 -0
- package/lib/common/api/usage.d.ts +79 -0
- package/lib/common/api/usage.d.ts.map +1 -0
- package/lib/common/api/usage.js +95 -0
- package/lib/common/api/usage.js.map +1 -0
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +7 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/model/index.d.ts +5 -0
- package/lib/common/model/index.d.ts.map +1 -0
- package/lib/common/model/index.js +8 -0
- package/lib/common/model/index.js.map +1 -0
- package/lib/common/model/openai-chat-model.d.ts +37 -0
- package/lib/common/model/openai-chat-model.d.ts.map +1 -0
- package/lib/common/model/openai-chat-model.js +357 -0
- package/lib/common/model/openai-chat-model.js.map +1 -0
- package/lib/common/model/openai-chat-model.spec.d.ts +2 -0
- package/lib/common/model/openai-chat-model.spec.d.ts.map +1 -0
- package/lib/common/model/openai-chat-model.spec.js +82 -0
- package/lib/common/model/openai-chat-model.spec.js.map +1 -0
- package/lib/common/model/openai-chat-options.d.ts +159 -0
- package/lib/common/model/openai-chat-options.d.ts.map +1 -0
- package/lib/common/model/openai-chat-options.js +231 -0
- package/lib/common/model/openai-chat-options.js.map +1 -0
- package/lib/common/model/openai-embedding-model.d.ts +15 -0
- package/lib/common/model/openai-embedding-model.d.ts.map +1 -0
- package/lib/common/model/openai-embedding-model.js +64 -0
- package/lib/common/model/openai-embedding-model.js.map +1 -0
- package/lib/common/model/openai-embedding-model.spec.d.ts +2 -0
- package/lib/common/model/openai-embedding-model.spec.d.ts.map +1 -0
- package/lib/common/model/openai-embedding-model.spec.js +100 -0
- package/lib/common/model/openai-embedding-model.spec.js.map +1 -0
- package/lib/common/model/openai-embedding-options.d.ts +35 -0
- package/lib/common/model/openai-embedding-options.d.ts.map +1 -0
- package/lib/common/model/openai-embedding-options.js +56 -0
- package/lib/common/model/openai-embedding-options.js.map +1 -0
- package/lib/common/module.d.ts +4 -0
- package/lib/common/module.d.ts.map +1 -0
- package/lib/common/module.js +6 -0
- package/lib/common/module.js.map +1 -0
- package/lib/common/support/index.d.ts +3 -0
- package/lib/common/support/index.d.ts.map +1 -0
- package/lib/common/support/index.js +6 -0
- package/lib/common/support/index.js.map +1 -0
- package/lib/common/support/openai-api-response-headers.d.ts +34 -0
- package/lib/common/support/openai-api-response-headers.d.ts.map +1 -0
- package/lib/common/support/openai-api-response-headers.js +45 -0
- package/lib/common/support/openai-api-response-headers.js.map +1 -0
- package/lib/common/support/openai-response-header-extractor.d.ts +12 -0
- package/lib/common/support/openai-response-header-extractor.d.ts.map +1 -0
- package/lib/common/support/openai-response-header-extractor.js +131 -0
- package/lib/common/support/openai-response-header-extractor.js.map +1 -0
- package/lib/common/test/mock-openai-api.d.ts +13 -0
- package/lib/common/test/mock-openai-api.d.ts.map +1 -0
- package/lib/common/test/mock-openai-api.js +57 -0
- package/lib/common/test/mock-openai-api.js.map +1 -0
- package/lib/common/test/test-container.d.ts +3 -0
- package/lib/common/test/test-container.d.ts.map +1 -0
- package/lib/common/test/test-container.js +16 -0
- package/lib/common/test/test-container.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +46 -0
- package/src/common/api/api-protocol.ts +51 -0
- package/src/common/api/chat-request.ts +258 -0
- package/src/common/api/chat-response.ts +218 -0
- package/src/common/api/embeddings-request.ts +92 -0
- package/src/common/api/embeddings-response.ts +44 -0
- package/src/common/api/index.ts +9 -0
- package/src/common/api/message.ts +273 -0
- package/src/common/api/openai-api.spec.ts +175 -0
- package/src/common/api/openai-api.ts +111 -0
- package/src/common/api/openai-model.ts +137 -0
- package/src/common/api/response-format.ts +109 -0
- package/src/common/api/usage.ts +135 -0
- package/src/common/index.ts +3 -0
- package/src/common/model/index.ts +4 -0
- package/src/common/model/openai-chat-model.spec.ts +85 -0
- package/src/common/model/openai-chat-model.ts +399 -0
- package/src/common/model/openai-chat-options.ts +326 -0
- package/src/common/model/openai-embedding-model.spec.ts +112 -0
- package/src/common/model/openai-embedding-model.ts +83 -0
- package/src/common/model/openai-embedding-options.ts +72 -0
- package/src/common/module.ts +4 -0
- package/src/common/support/index.ts +2 -0
- package/src/common/support/openai-api-response-headers.ts +46 -0
- package/src/common/support/openai-response-header-extractor.ts +141 -0
- package/src/common/test/mock-openai-api.ts +70 -0
- package/src/common/test/test-container.ts +13 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const http_1 = require("@celljs/http");
|
|
5
|
+
const test_container_1 = require("../test/test-container");
|
|
6
|
+
const api_protocol_1 = require("./api-protocol");
|
|
7
|
+
const chat_request_1 = require("./chat-request");
|
|
8
|
+
const embeddings_request_1 = require("./embeddings-request");
|
|
9
|
+
const message_1 = require("./message");
|
|
10
|
+
require("../index");
|
|
11
|
+
describe('OpenAIAPI', () => {
|
|
12
|
+
const container = (0, test_container_1.createContainer)();
|
|
13
|
+
let openaiAPI;
|
|
14
|
+
// Mock response data
|
|
15
|
+
const mockResponses = {
|
|
16
|
+
chat: {
|
|
17
|
+
id: 'chatcmpl-123',
|
|
18
|
+
object: 'chat.completion',
|
|
19
|
+
created: 1677652288,
|
|
20
|
+
model: 'gpt-3.5-turbo',
|
|
21
|
+
choices: [{
|
|
22
|
+
index: 0,
|
|
23
|
+
message: {
|
|
24
|
+
role: 'assistant',
|
|
25
|
+
content: 'Hello! How can I help you today?'
|
|
26
|
+
},
|
|
27
|
+
finish_reason: 'stop'
|
|
28
|
+
}],
|
|
29
|
+
usage: {
|
|
30
|
+
prompt_tokens: 9,
|
|
31
|
+
completion_tokens: 12,
|
|
32
|
+
total_tokens: 21
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
stream: {
|
|
36
|
+
id: 'chatcmpl-123',
|
|
37
|
+
object: 'chat.completion.chunk',
|
|
38
|
+
created: 1677652288,
|
|
39
|
+
model: 'gpt-3.5-turbo',
|
|
40
|
+
choices: [{
|
|
41
|
+
index: 0,
|
|
42
|
+
delta: {
|
|
43
|
+
role: 'assistant',
|
|
44
|
+
content: 'Hello'
|
|
45
|
+
}
|
|
46
|
+
}]
|
|
47
|
+
},
|
|
48
|
+
embeddings: {
|
|
49
|
+
object: 'list',
|
|
50
|
+
data: [{ object: 'embedding', embedding: [0.1, 0.2, 0.3], index: 0 }],
|
|
51
|
+
model: 'text-embedding-3-small',
|
|
52
|
+
usage: { prompt_tokens: 8, total_tokens: 8 }
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
// Configure mock REST operations
|
|
57
|
+
container.rebind(http_1.RestOperations).toConstantValue({
|
|
58
|
+
post: async (url, data) => {
|
|
59
|
+
if (url === '/v1/embeddings') {
|
|
60
|
+
return { data: mockResponses.embeddings };
|
|
61
|
+
}
|
|
62
|
+
if (data.stream) {
|
|
63
|
+
const stream = new ReadableStream({
|
|
64
|
+
start(controller) {
|
|
65
|
+
controller.enqueue(`data: ${JSON.stringify(mockResponses.stream)}\n\n`);
|
|
66
|
+
controller.enqueue('data: [DONE]\n\n');
|
|
67
|
+
controller.close();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return { data: stream };
|
|
71
|
+
}
|
|
72
|
+
return { data: mockResponses.chat };
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
openaiAPI = container.get(api_protocol_1.OpenAIAPI);
|
|
76
|
+
});
|
|
77
|
+
describe('chat', () => {
|
|
78
|
+
it('should return correct response for non-streaming request', async () => {
|
|
79
|
+
const request = new chat_request_1.ChatCompletionRequest();
|
|
80
|
+
request.model = 'gpt-3.5-turbo';
|
|
81
|
+
request.messages = [{ role: message_1.Role.USER, content: 'Hello' }];
|
|
82
|
+
const response = await openaiAPI.chat(request);
|
|
83
|
+
(0, chai_1.expect)(response.body.id).to.equal('chatcmpl-123');
|
|
84
|
+
(0, chai_1.expect)(response.body.choices[0].message.content).to.equal('Hello! How can I help you today?');
|
|
85
|
+
(0, chai_1.expect)(response.body.usage.totalTokens).to.equal(21);
|
|
86
|
+
});
|
|
87
|
+
it('should throw error when stream is enabled', async () => {
|
|
88
|
+
const request = new chat_request_1.ChatCompletionRequest();
|
|
89
|
+
request.model = 'gpt-3.5-turbo';
|
|
90
|
+
request.messages = [{ role: message_1.Role.USER, content: 'Hello' }];
|
|
91
|
+
request.stream = true;
|
|
92
|
+
try {
|
|
93
|
+
await openaiAPI.chat(request);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
(0, chai_1.expect)(e).to.be.instanceOf(Error);
|
|
97
|
+
(0, chai_1.expect)(e.message).to.include('Request must set the stream property to false.');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('chat', () => {
|
|
102
|
+
it('should throw error when stream is disabled', async () => {
|
|
103
|
+
const request = new chat_request_1.ChatCompletionRequest();
|
|
104
|
+
request.model = 'gpt-3.5-turbo';
|
|
105
|
+
request.messages = [{ role: message_1.Role.USER, content: 'Hello' }];
|
|
106
|
+
request.stream = false;
|
|
107
|
+
try {
|
|
108
|
+
await openaiAPI.chat(request);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
(0, chai_1.expect)(e).to.be.instanceOf(Error);
|
|
112
|
+
(0, chai_1.expect)(e.message).to.include('Request must set the stream property to true.');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
describe('streamingChat', () => {
|
|
117
|
+
it('should handle streaming response correctly', done => {
|
|
118
|
+
const request = new chat_request_1.ChatCompletionRequest();
|
|
119
|
+
request.model = 'gpt-3.5-turbo';
|
|
120
|
+
request.messages = [{ role: message_1.Role.USER, content: 'Hello' }];
|
|
121
|
+
request.stream = true;
|
|
122
|
+
openaiAPI.streamingChat(request).then(response$ => {
|
|
123
|
+
response$.subscribe({
|
|
124
|
+
next: chunk => {
|
|
125
|
+
(0, chai_1.expect)(chunk.body.id).to.equal('chatcmpl-123');
|
|
126
|
+
(0, chai_1.expect)(chunk.body.choices[0].delta.content).to.equal('Hello');
|
|
127
|
+
done();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
it('should throw error when stream is disabled', async () => {
|
|
133
|
+
const request = new chat_request_1.ChatCompletionRequest();
|
|
134
|
+
request.model = 'gpt-3.5-turbo';
|
|
135
|
+
request.messages = [{ role: message_1.Role.USER, content: 'Hello' }];
|
|
136
|
+
request.stream = false;
|
|
137
|
+
try {
|
|
138
|
+
await openaiAPI.streamingChat(request);
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
(0, chai_1.expect)(e).to.be.instanceOf(Error);
|
|
142
|
+
(0, chai_1.expect)(e.message).to.include('Request must set the stream property to true.');
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('embed', () => {
|
|
147
|
+
it('should return correct embedding vectors', async () => {
|
|
148
|
+
const request = embeddings_request_1.EmbeddingRequest.fromInput('Hello world');
|
|
149
|
+
const response = await openaiAPI.embed(request);
|
|
150
|
+
(0, chai_1.expect)(response.body.object).to.equal('list');
|
|
151
|
+
(0, chai_1.expect)(response.body.data[0].embedding).to.deep.equal([0.1, 0.2, 0.3]);
|
|
152
|
+
(0, chai_1.expect)(response.body.model).to.equal('text-embedding-3-small');
|
|
153
|
+
});
|
|
154
|
+
it('should support batch inputs', async () => {
|
|
155
|
+
const request = embeddings_request_1.EmbeddingRequest.fromInputAndModel(['Hello', 'World'], 'text-embedding-3-small');
|
|
156
|
+
const response = await openaiAPI.embed(request);
|
|
157
|
+
(0, chai_1.expect)(response.body.data[0].embedding).to.deep.equal([0.1, 0.2, 0.3]);
|
|
158
|
+
(0, chai_1.expect)(response.body.usage.totalTokens).to.equal(8);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
//# sourceMappingURL=openai-api.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-api.spec.js","sourceRoot":"","sources":["../../../src/common/api/openai-api.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,uCAA8C;AAC9C,2DAAyD;AACzD,iDAA2C;AAC3C,iDAAuD;AACvD,6DAAwD;AACxD,uCAAiC;AACjC,oBAAkB;AAElB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,MAAM,SAAS,GAAG,IAAA,gCAAe,GAAE,CAAC;IACpC,IAAI,SAAoB,CAAC;IAEzB,qBAAqB;IACrB,MAAM,aAAa,GAAG;QAClB,IAAI,EAAE;YACF,EAAE,EAAE,cAAc;YAClB,MAAM,EAAE,iBAAiB;YACzB,OAAO,EAAE,UAAU;YACnB,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,CAAC;oBACN,KAAK,EAAE,CAAC;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,WAAW;wBACjB,OAAO,EAAE,kCAAkC;qBAC9C;oBACD,aAAa,EAAE,MAAM;iBACxB,CAAC;YACF,KAAK,EAAE;gBACH,aAAa,EAAE,CAAC;gBAChB,iBAAiB,EAAE,EAAE;gBACrB,YAAY,EAAE,EAAE;aACnB;SACJ;QACD,MAAM,EAAE;YACJ,EAAE,EAAE,cAAc;YAClB,MAAM,EAAE,uBAAuB;YAC/B,OAAO,EAAE,UAAU;YACnB,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,CAAC;oBACN,KAAK,EAAE,CAAC;oBACR,KAAK,EAAE;wBACH,IAAI,EAAE,WAAW;wBACjB,OAAO,EAA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enAI Chat Completion Models:
|
|
3
|
+
*
|
|
4
|
+
* - [GPT-4o](https://platform.openai.com/docs/models/gpt-4o)
|
|
5
|
+
* - [GPT-4o mini](https://platform.openai.com/docs/models/gpt-4o-mini)
|
|
6
|
+
* - [GPT-4 and GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo)
|
|
7
|
+
* - [GPT-3.5 Turbo](https://platform.openai.com/docs/models/gpt-3-5-turbo)
|
|
8
|
+
* - [DALL·E](https://platform.openai.com/docs/models/dall-e)
|
|
9
|
+
*/
|
|
10
|
+
export declare enum OpenAIModel {
|
|
11
|
+
/**
|
|
12
|
+
* Points to the most recent snapshot of the o1 model: o1-preview-2024-09-12
|
|
13
|
+
*/
|
|
14
|
+
O1_PREVIEW = "o1-preview",
|
|
15
|
+
/**
|
|
16
|
+
* Latest o1 model snapshot
|
|
17
|
+
*/
|
|
18
|
+
O1_PREVIEW_2024_09_12 = "o1-preview-2024-09-12",
|
|
19
|
+
/**
|
|
20
|
+
* Points to the most recent o1-mini snapshot: o1-mini-2024-09-12
|
|
21
|
+
*/
|
|
22
|
+
O1_MINI = "o1-mini",
|
|
23
|
+
/**
|
|
24
|
+
* Latest o1-mini model snapshot
|
|
25
|
+
*/
|
|
26
|
+
O1_MINI_2024_09_12 = "o1-mini-2024-09-12",
|
|
27
|
+
/**
|
|
28
|
+
* Multimodal flagship model that’s cheaper and faster than GPT-4 Turbo. Currently
|
|
29
|
+
* points to gpt-4o-2024-05-13.
|
|
30
|
+
*/
|
|
31
|
+
GPT_4_O = "gpt-4o",
|
|
32
|
+
/**
|
|
33
|
+
* Preview release for audio inputs in chat completions.
|
|
34
|
+
*/
|
|
35
|
+
GPT_4_O_AUDIO_PREVIEW = "gpt-4o-audio-preview",
|
|
36
|
+
/**
|
|
37
|
+
* Affordable and intelligent small model for fast, lightweight tasks. GPT-4o mini
|
|
38
|
+
* is cheaper and more capable than GPT-3.5 Turbo. Currently points to
|
|
39
|
+
* gpt-4o-mini-2024-07-18.
|
|
40
|
+
*/
|
|
41
|
+
GPT_4_O_MINI = "gpt-4o-mini",
|
|
42
|
+
/**
|
|
43
|
+
* GPT-4 Turbo with Vision The latest GPT-4 Turbo model with vision capabilities.
|
|
44
|
+
* Vision requests can now use JSON mode and function calling. Currently points to
|
|
45
|
+
* gpt-4-turbo-2024-04-09.
|
|
46
|
+
*/
|
|
47
|
+
GPT_4_TURBO = "gpt-4-turbo",
|
|
48
|
+
/**
|
|
49
|
+
* GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and
|
|
50
|
+
* function calling.
|
|
51
|
+
*/
|
|
52
|
+
GPT_4_TURBO_2024_04_09 = "gpt-4-turbo-2024-04-09",
|
|
53
|
+
/**
|
|
54
|
+
* (New) GPT-4 Turbo - latest GPT-4 model intended to reduce cases of “laziness”
|
|
55
|
+
* where the model doesn’t complete a task. Returns a maximum of 4,096 output
|
|
56
|
+
* tokens. Context window: 128k tokens
|
|
57
|
+
* Currently points to gpt-4-0125-preview
|
|
58
|
+
*/
|
|
59
|
+
GPT_4_0125_PREVIEW = "gpt-4-0125-preview",
|
|
60
|
+
/**
|
|
61
|
+
* Currently points to gpt-4-0125-preview - model featuring improved instruction
|
|
62
|
+
* following, JSON mode, reproducible outputs, parallel function calling, and
|
|
63
|
+
* more. Returns a maximum of 4,096 output tokens Context window: 128k tokens
|
|
64
|
+
*/
|
|
65
|
+
GPT_4_TURBO_PREVIEW = "gpt-4-turbo-preview",
|
|
66
|
+
/**
|
|
67
|
+
* Currently points to gpt-4-0613. Snapshot of gpt-4 from June 13th 2023 with
|
|
68
|
+
* improved function calling support. Context window: 8k tokens
|
|
69
|
+
* Returns a maximum of 4,096 output tokens Context window: 8k tokens
|
|
70
|
+
*/
|
|
71
|
+
GPT_4 = "gpt-4",
|
|
72
|
+
/**
|
|
73
|
+
* Currently points to gpt-3.5-turbo-0125. model with higher accuracy at
|
|
74
|
+
* responding in requested formats and a fix for a bug which caused a text
|
|
75
|
+
* encoding issue for non-English language function calls. Returns a maximum of
|
|
76
|
+
* 4,096 Context window: 16k tokens
|
|
77
|
+
*/
|
|
78
|
+
GPT_3_5_TURBO = "gpt-3.5-turbo",
|
|
79
|
+
/**
|
|
80
|
+
* Currently points to gpt-3.5-turbo-0125. model with higher accuracy at
|
|
81
|
+
* responding in requested formats and a fix for a bug which caused a text
|
|
82
|
+
* encoding issue for non-English language function calls. Returns a maximum of
|
|
83
|
+
* 4,096 Context window: 16k tokens
|
|
84
|
+
*/
|
|
85
|
+
GPT_3_5_TURBO_0125 = "gpt-3.5-turbo-0125",
|
|
86
|
+
/**
|
|
87
|
+
* GPT-3.5 Turbo model with improved instruction following, JSON mode,
|
|
88
|
+
* reproducible outputs, parallel function calling, and more. Returns a maximum of
|
|
89
|
+
* 4,096 output tokens. Context window: 16k tokens.
|
|
90
|
+
*/
|
|
91
|
+
GPT_3_5_TURBO_1106 = "gpt-3.5-turbo-1106",
|
|
92
|
+
/**
|
|
93
|
+
* Most capable embedding model for both English and non-English tasks. DIMENSION:
|
|
94
|
+
* 3072
|
|
95
|
+
*/
|
|
96
|
+
TEXT_EMBEDDING_3_LARGE = "text-embedding-3-large",
|
|
97
|
+
/**
|
|
98
|
+
* Increased performance over 2nd generation ada embedding model. DIMENSION: 1536
|
|
99
|
+
*/
|
|
100
|
+
TEXT_EMBEDDING_3_SMALL = "text-embedding-3-small",
|
|
101
|
+
/**
|
|
102
|
+
* Most capable 2nd generation embedding model, replacing 16 first generation
|
|
103
|
+
* models. DIMENSION: 1536
|
|
104
|
+
*/
|
|
105
|
+
TEXT_EMBEDDING_ADA_002 = "text-embedding-ada-002",
|
|
106
|
+
/**
|
|
107
|
+
* The latest DALL·E model released in Nov 2023.
|
|
108
|
+
*/
|
|
109
|
+
DALL_E_3 = "dall-e-3",
|
|
110
|
+
/**
|
|
111
|
+
* The previous DALL·E model released in Nov 2022. The 2nd iteration of DALL·E
|
|
112
|
+
* with more realistic, accurate, and 4x greater resolution images than the
|
|
113
|
+
* original model.
|
|
114
|
+
*/
|
|
115
|
+
DALL_E_2 = "dall-e-2"
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=openai-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-model.d.ts","sourceRoot":"","sources":["../../../src/common/api/openai-model.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AACH,oBAAY,WAAW;IAEnB;;OAEG;IACH,UAAU,eAAe;IAEzB;;OAEG;IACH,qBAAqB,0BAA0B;IAE/C;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,kBAAkB,uBAAuB;IAEzC;;;OAGG;IACH,OAAO,WAAW;IAElB;;OAEG;IACH,qBAAqB,yBAAyB;IAE9C;;;;OAIG;IACH,YAAY,gBAAgB;IAE5B;;;;OAIG;IACH,WAAW,gBAAgB;IAE3B;;;OAGG;IACH,sBAAsB,2BAA2B;IAEjD;;;;;OAKG;IACH,kBAAkB,uBAAuB;IAEzC;;;;OAIG;IACH,mBAAmB,wBAAwB;IAE3C;;;;OAIG;IACH,KAAK,UAAU;IAEf;;;;;OAKG;IACH,aAAa,kBAAkB;IAE/B;;;;;OAKG;IACH,kBAAkB,uBAAuB;IAEzC;;;;OAIG;IACH,kBAAkB,uBAAuB;IAEzC;;;OAGG;IACH,sBAAsB,2BAA2B;IAEjD;;OAEG;IACH,sBAAsB,2BAA2B;IAEjD;;;OAGG;IACH,sBAAsB,2BAA2B;IAEjD;;OAEG;IACH,QAAQ,aAAa;IAErB;;;;OAIG;IACH,QAAQ,aAAa;CACxB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAIModel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* OpenAI Chat Completion Models:
|
|
6
|
+
*
|
|
7
|
+
* - [GPT-4o](https://platform.openai.com/docs/models/gpt-4o)
|
|
8
|
+
* - [GPT-4o mini](https://platform.openai.com/docs/models/gpt-4o-mini)
|
|
9
|
+
* - [GPT-4 and GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo)
|
|
10
|
+
* - [GPT-3.5 Turbo](https://platform.openai.com/docs/models/gpt-3-5-turbo)
|
|
11
|
+
* - [DALL·E](https://platform.openai.com/docs/models/dall-e)
|
|
12
|
+
*/
|
|
13
|
+
var OpenAIModel;
|
|
14
|
+
(function (OpenAIModel) {
|
|
15
|
+
/**
|
|
16
|
+
* Points to the most recent snapshot of the o1 model: o1-preview-2024-09-12
|
|
17
|
+
*/
|
|
18
|
+
OpenAIModel["O1_PREVIEW"] = "o1-preview";
|
|
19
|
+
/**
|
|
20
|
+
* Latest o1 model snapshot
|
|
21
|
+
*/
|
|
22
|
+
OpenAIModel["O1_PREVIEW_2024_09_12"] = "o1-preview-2024-09-12";
|
|
23
|
+
/**
|
|
24
|
+
* Points to the most recent o1-mini snapshot: o1-mini-2024-09-12
|
|
25
|
+
*/
|
|
26
|
+
OpenAIModel["O1_MINI"] = "o1-mini";
|
|
27
|
+
/**
|
|
28
|
+
* Latest o1-mini model snapshot
|
|
29
|
+
*/
|
|
30
|
+
OpenAIModel["O1_MINI_2024_09_12"] = "o1-mini-2024-09-12";
|
|
31
|
+
/**
|
|
32
|
+
* Multimodal flagship model that’s cheaper and faster than GPT-4 Turbo. Currently
|
|
33
|
+
* points to gpt-4o-2024-05-13.
|
|
34
|
+
*/
|
|
35
|
+
OpenAIModel["GPT_4_O"] = "gpt-4o";
|
|
36
|
+
/**
|
|
37
|
+
* Preview release for audio inputs in chat completions.
|
|
38
|
+
*/
|
|
39
|
+
OpenAIModel["GPT_4_O_AUDIO_PREVIEW"] = "gpt-4o-audio-preview";
|
|
40
|
+
/**
|
|
41
|
+
* Affordable and intelligent small model for fast, lightweight tasks. GPT-4o mini
|
|
42
|
+
* is cheaper and more capable than GPT-3.5 Turbo. Currently points to
|
|
43
|
+
* gpt-4o-mini-2024-07-18.
|
|
44
|
+
*/
|
|
45
|
+
OpenAIModel["GPT_4_O_MINI"] = "gpt-4o-mini";
|
|
46
|
+
/**
|
|
47
|
+
* GPT-4 Turbo with Vision The latest GPT-4 Turbo model with vision capabilities.
|
|
48
|
+
* Vision requests can now use JSON mode and function calling. Currently points to
|
|
49
|
+
* gpt-4-turbo-2024-04-09.
|
|
50
|
+
*/
|
|
51
|
+
OpenAIModel["GPT_4_TURBO"] = "gpt-4-turbo";
|
|
52
|
+
/**
|
|
53
|
+
* GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and
|
|
54
|
+
* function calling.
|
|
55
|
+
*/
|
|
56
|
+
OpenAIModel["GPT_4_TURBO_2024_04_09"] = "gpt-4-turbo-2024-04-09";
|
|
57
|
+
/**
|
|
58
|
+
* (New) GPT-4 Turbo - latest GPT-4 model intended to reduce cases of “laziness”
|
|
59
|
+
* where the model doesn’t complete a task. Returns a maximum of 4,096 output
|
|
60
|
+
* tokens. Context window: 128k tokens
|
|
61
|
+
* Currently points to gpt-4-0125-preview
|
|
62
|
+
*/
|
|
63
|
+
OpenAIModel["GPT_4_0125_PREVIEW"] = "gpt-4-0125-preview";
|
|
64
|
+
/**
|
|
65
|
+
* Currently points to gpt-4-0125-preview - model featuring improved instruction
|
|
66
|
+
* following, JSON mode, reproducible outputs, parallel function calling, and
|
|
67
|
+
* more. Returns a maximum of 4,096 output tokens Context window: 128k tokens
|
|
68
|
+
*/
|
|
69
|
+
OpenAIModel["GPT_4_TURBO_PREVIEW"] = "gpt-4-turbo-preview";
|
|
70
|
+
/**
|
|
71
|
+
* Currently points to gpt-4-0613. Snapshot of gpt-4 from June 13th 2023 with
|
|
72
|
+
* improved function calling support. Context window: 8k tokens
|
|
73
|
+
* Returns a maximum of 4,096 output tokens Context window: 8k tokens
|
|
74
|
+
*/
|
|
75
|
+
OpenAIModel["GPT_4"] = "gpt-4";
|
|
76
|
+
/**
|
|
77
|
+
* Currently points to gpt-3.5-turbo-0125. model with higher accuracy at
|
|
78
|
+
* responding in requested formats and a fix for a bug which caused a text
|
|
79
|
+
* encoding issue for non-English language function calls. Returns a maximum of
|
|
80
|
+
* 4,096 Context window: 16k tokens
|
|
81
|
+
*/
|
|
82
|
+
OpenAIModel["GPT_3_5_TURBO"] = "gpt-3.5-turbo";
|
|
83
|
+
/**
|
|
84
|
+
* Currently points to gpt-3.5-turbo-0125. model with higher accuracy at
|
|
85
|
+
* responding in requested formats and a fix for a bug which caused a text
|
|
86
|
+
* encoding issue for non-English language function calls. Returns a maximum of
|
|
87
|
+
* 4,096 Context window: 16k tokens
|
|
88
|
+
*/
|
|
89
|
+
OpenAIModel["GPT_3_5_TURBO_0125"] = "gpt-3.5-turbo-0125";
|
|
90
|
+
/**
|
|
91
|
+
* GPT-3.5 Turbo model with improved instruction following, JSON mode,
|
|
92
|
+
* reproducible outputs, parallel function calling, and more. Returns a maximum of
|
|
93
|
+
* 4,096 output tokens. Context window: 16k tokens.
|
|
94
|
+
*/
|
|
95
|
+
OpenAIModel["GPT_3_5_TURBO_1106"] = "gpt-3.5-turbo-1106";
|
|
96
|
+
/**
|
|
97
|
+
* Most capable embedding model for both English and non-English tasks. DIMENSION:
|
|
98
|
+
* 3072
|
|
99
|
+
*/
|
|
100
|
+
OpenAIModel["TEXT_EMBEDDING_3_LARGE"] = "text-embedding-3-large";
|
|
101
|
+
/**
|
|
102
|
+
* Increased performance over 2nd generation ada embedding model. DIMENSION: 1536
|
|
103
|
+
*/
|
|
104
|
+
OpenAIModel["TEXT_EMBEDDING_3_SMALL"] = "text-embedding-3-small";
|
|
105
|
+
/**
|
|
106
|
+
* Most capable 2nd generation embedding model, replacing 16 first generation
|
|
107
|
+
* models. DIMENSION: 1536
|
|
108
|
+
*/
|
|
109
|
+
OpenAIModel["TEXT_EMBEDDING_ADA_002"] = "text-embedding-ada-002";
|
|
110
|
+
/**
|
|
111
|
+
* The latest DALL·E model released in Nov 2023.
|
|
112
|
+
*/
|
|
113
|
+
OpenAIModel["DALL_E_3"] = "dall-e-3";
|
|
114
|
+
/**
|
|
115
|
+
* The previous DALL·E model released in Nov 2022. The 2nd iteration of DALL·E
|
|
116
|
+
* with more realistic, accurate, and 4x greater resolution images than the
|
|
117
|
+
* original model.
|
|
118
|
+
*/
|
|
119
|
+
OpenAIModel["DALL_E_2"] = "dall-e-2";
|
|
120
|
+
})(OpenAIModel = exports.OpenAIModel || (exports.OpenAIModel = {}));
|
|
121
|
+
//# sourceMappingURL=openai-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-model.js","sourceRoot":"","sources":["../../../src/common/api/openai-model.ts"],"names":[],"mappings":";;;AACA;;;;;;;;GAQG;AACH,IAAY,WA8HX;AA9HD,WAAY,WAAW;IAEnB;;OAEG;IACH,wCAAyB,CAAA;IAEzB;;OAEG;IACH,8DAA+C,CAAA;IAE/C;;OAEG;IACH,kCAAmB,CAAA;IAEnB;;OAEG;IACH,wDAAyC,CAAA;IAEzC;;;OAGG;IACH,iCAAkB,CAAA;IAElB;;OAEG;IACH,6DAA8C,CAAA;IAE9C;;;;OAIG;IACH,2CAA4B,CAAA;IAE5B;;;;OAIG;IACH,0CAA2B,CAAA;IAE3B;;;OAGG;IACH,gEAAiD,CAAA;IAEjD;;;;;OAKG;IACH,wDAAyC,CAAA;IAEzC;;;;OAIG;IACH,0DAA2C,CAAA;IAE3C;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;;OAKG;IACH,8CAA+B,CAAA;IAE/B;;;;;OAKG;IACH,wDAAyC,CAAA;IAEzC;;;;OAIG;IACH,wDAAyC,CAAA;IAEzC;;;OAGG;IACH,gEAAiD,CAAA;IAEjD;;OAEG;IACH,gEAAiD,CAAA;IAEjD;;;OAGG;IACH,gEAAiD,CAAA;IAEjD;;OAEG;IACH,oCAAqB,CAAA;IAErB;;;;OAIG;IACH,oCAAqB,CAAA;AACzB,CAAC,EA9HW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA8HtB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare enum ResponseFormatType {
|
|
2
|
+
TEXT = "text",
|
|
3
|
+
JSON_OBJECT = "json_object",
|
|
4
|
+
JSON_SCHEMA = "json_schema"
|
|
5
|
+
}
|
|
6
|
+
export declare class JsonSchema {
|
|
7
|
+
name: string;
|
|
8
|
+
schema: Map<string, any>;
|
|
9
|
+
strict: boolean;
|
|
10
|
+
constructor(name: string, schema: Map<string, any>, strict: boolean);
|
|
11
|
+
static builder(): JsonSchemaBuilder;
|
|
12
|
+
}
|
|
13
|
+
export declare class JsonSchemaBuilder {
|
|
14
|
+
private name;
|
|
15
|
+
private schema;
|
|
16
|
+
private strict;
|
|
17
|
+
withName(name: string): this;
|
|
18
|
+
withSchema(schema: Map<string, any>): this;
|
|
19
|
+
withStrict(strict: boolean): this;
|
|
20
|
+
build(): JsonSchema;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An object specifying the format that the model must output.
|
|
24
|
+
*
|
|
25
|
+
* Setting the type to JSON_SCHEMA, enables Structured Outputs which ensures the model
|
|
26
|
+
* will match your supplied JSON schema. Learn more in the
|
|
27
|
+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
|
28
|
+
*
|
|
29
|
+
* References: [OpenAi API - ResponseFormat](https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format),
|
|
30
|
+
* [JSON Mode](https://platform.openai.com/docs/guides/structured-outputs#json-mode),
|
|
31
|
+
* [Structured Outputs vs JSON mode](https://platform.openai.com/docs/guides/structured-outputs#structured-outputs-vs-json-mode)
|
|
32
|
+
*/
|
|
33
|
+
export declare class ResponseFormat {
|
|
34
|
+
/**
|
|
35
|
+
* Type Must be one of 'text', 'json_object' or 'json_schema'.
|
|
36
|
+
*/
|
|
37
|
+
type: ResponseFormatType;
|
|
38
|
+
/**
|
|
39
|
+
* JSON schema object that describes the format of the JSON object. Only applicable
|
|
40
|
+
* when type is 'json_schema'.
|
|
41
|
+
*/
|
|
42
|
+
schema?: JsonSchema;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the model must strictly adhere to the schema. Only applicable when type is
|
|
45
|
+
* 'json_schema'.
|
|
46
|
+
*/
|
|
47
|
+
strict?: boolean;
|
|
48
|
+
constructor(type: ResponseFormatType, schema?: JsonSchema, strict?: boolean);
|
|
49
|
+
static builder(): ResponseFormatBuilder;
|
|
50
|
+
}
|
|
51
|
+
export declare class ResponseFormatBuilder {
|
|
52
|
+
private type;
|
|
53
|
+
private schema?;
|
|
54
|
+
private strict?;
|
|
55
|
+
withType(type: ResponseFormatType): this;
|
|
56
|
+
withSchema(schema: JsonSchema): this;
|
|
57
|
+
withStrict(strict: boolean): this;
|
|
58
|
+
build(): ResponseFormat;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=response-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-format.d.ts","sourceRoot":"","sources":["../../../src/common/api/response-format.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC1B,IAAI,SAAS;IACb,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;CAC9B;AAED,qBAAa,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;gBACJ,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO;IAMnE,MAAM,CAAC,OAAO;CAGjB;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAU;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAKrB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAKnC,UAAU,CAAC,MAAM,EAAE,OAAO;IAK1B,KAAK;CAGR;AAED;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACvB;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;gBAEL,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,OAAO;IAM3E,MAAM,CAAC,OAAO;CAGjB;AAED,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B,OAAO,CAAC,MAAM,CAAC,CAAU;IAEzB,QAAQ,CAAC,IAAI,EAAE,kBAAkB;IAKjC,UAAU,CAAC,MAAM,EAAE,UAAU;IAK7B,UAAU,CAAC,MAAM,EAAE,OAAO;IAI1B,KAAK;CAGR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseFormatBuilder = exports.ResponseFormat = exports.JsonSchemaBuilder = exports.JsonSchema = exports.ResponseFormatType = void 0;
|
|
4
|
+
var ResponseFormatType;
|
|
5
|
+
(function (ResponseFormatType) {
|
|
6
|
+
ResponseFormatType["TEXT"] = "text";
|
|
7
|
+
ResponseFormatType["JSON_OBJECT"] = "json_object";
|
|
8
|
+
ResponseFormatType["JSON_SCHEMA"] = "json_schema";
|
|
9
|
+
})(ResponseFormatType = exports.ResponseFormatType || (exports.ResponseFormatType = {}));
|
|
10
|
+
class JsonSchema {
|
|
11
|
+
constructor(name, schema, strict) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.schema = schema;
|
|
14
|
+
this.strict = strict;
|
|
15
|
+
}
|
|
16
|
+
static builder() {
|
|
17
|
+
return new JsonSchemaBuilder();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.JsonSchema = JsonSchema;
|
|
21
|
+
class JsonSchemaBuilder {
|
|
22
|
+
withName(name) {
|
|
23
|
+
this.name = name;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
withSchema(schema) {
|
|
27
|
+
this.schema = schema;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
withStrict(strict) {
|
|
31
|
+
this.strict = strict;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
build() {
|
|
35
|
+
return new JsonSchema(this.name, this.schema, this.strict);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.JsonSchemaBuilder = JsonSchemaBuilder;
|
|
39
|
+
/**
|
|
40
|
+
* An object specifying the format that the model must output.
|
|
41
|
+
*
|
|
42
|
+
* Setting the type to JSON_SCHEMA, enables Structured Outputs which ensures the model
|
|
43
|
+
* will match your supplied JSON schema. Learn more in the
|
|
44
|
+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
|
45
|
+
*
|
|
46
|
+
* References: [OpenAi API - ResponseFormat](https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format),
|
|
47
|
+
* [JSON Mode](https://platform.openai.com/docs/guides/structured-outputs#json-mode),
|
|
48
|
+
* [Structured Outputs vs JSON mode](https://platform.openai.com/docs/guides/structured-outputs#structured-outputs-vs-json-mode)
|
|
49
|
+
*/
|
|
50
|
+
class ResponseFormat {
|
|
51
|
+
constructor(type, schema, strict) {
|
|
52
|
+
this.type = type;
|
|
53
|
+
this.schema = schema;
|
|
54
|
+
this.strict = strict;
|
|
55
|
+
}
|
|
56
|
+
static builder() {
|
|
57
|
+
return new ResponseFormatBuilder();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ResponseFormat = ResponseFormat;
|
|
61
|
+
class ResponseFormatBuilder {
|
|
62
|
+
withType(type) {
|
|
63
|
+
this.type = type;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
withSchema(schema) {
|
|
67
|
+
this.schema = schema;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
withStrict(strict) {
|
|
71
|
+
this.strict = strict;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
build() {
|
|
75
|
+
return new ResponseFormat(this.type, this.schema, this.strict);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ResponseFormatBuilder = ResponseFormatBuilder;
|
|
79
|
+
//# sourceMappingURL=response-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-format.js","sourceRoot":"","sources":["../../../src/common/api/response-format.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;AAC/B,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B;AAED,MAAa,UAAU;IAInB,YAAY,IAAY,EAAE,MAAwB,EAAE,MAAe;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,OAAO;QACV,OAAO,IAAI,iBAAiB,EAAE,CAAC;IACnC,CAAC;CACJ;AAbD,gCAaC;AAED,MAAa,iBAAiB;IAK1B,QAAQ,CAAC,IAAY;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAwB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AAvBD,8CAuBC;AAED;;;;;;;;;;GAUG;AACH,MAAa,cAAc;IAkBvB,YAAY,IAAwB,EAAE,MAAmB,EAAE,MAAgB;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,OAAO;QACV,OAAO,IAAI,qBAAqB,EAAE,CAAC;IACvC,CAAC;CACJ;AA3BD,wCA2BC;AAED,MAAa,qBAAqB;IAK9B,QAAQ,CAAC,IAAwB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAkB;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,KAAK;QACD,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;CACJ;AAtBD,sDAsBC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Usage as IUsage } from '@celljs/ai-core';
|
|
2
|
+
/**
|
|
3
|
+
* Breakdown of tokens used in the prompt.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PromptTokensDetails {
|
|
6
|
+
/**
|
|
7
|
+
* Audio input tokens present in the prompt.
|
|
8
|
+
*/
|
|
9
|
+
audioTokens?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Cached tokens present in the prompt.
|
|
12
|
+
*/
|
|
13
|
+
cachedTokens?: number;
|
|
14
|
+
constructor(audioTokens?: number, cachedTokens?: number);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Breakdown of tokens used in a completion.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CompletionTokenDetails {
|
|
20
|
+
/**
|
|
21
|
+
* Number of tokens generated by the model for reasoning.
|
|
22
|
+
*/
|
|
23
|
+
reasoningTokens?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Number of tokens generated by the model for accepted predictions.
|
|
26
|
+
*/
|
|
27
|
+
acceptedPredictionTokens?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Number of tokens generated by the model for audio.
|
|
30
|
+
*/
|
|
31
|
+
audioTokens?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Number of tokens generated by the model for rejected predictions.
|
|
34
|
+
*/
|
|
35
|
+
rejectedPredictionTokens?: number;
|
|
36
|
+
constructor(reasoningTokens?: number, acceptedPredictionTokens?: number, audioTokens?: number, rejectedPredictionTokens?: number);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The response object returned from the /embedding endpoint.
|
|
40
|
+
*/
|
|
41
|
+
export declare class EmbeddingsResponse {
|
|
42
|
+
/**
|
|
43
|
+
* The model used for generating the embeddings.
|
|
44
|
+
*/
|
|
45
|
+
model: string;
|
|
46
|
+
/**
|
|
47
|
+
* The list of embeddings generated from the model.
|
|
48
|
+
* Each embedding (list of doubles) corresponds to a single input text.
|
|
49
|
+
*/
|
|
50
|
+
embeddings: number[][];
|
|
51
|
+
constructor(model: string, embeddings: number[][]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Usage statistics for the completion request.
|
|
55
|
+
*/
|
|
56
|
+
export declare class Usage implements IUsage {
|
|
57
|
+
/**
|
|
58
|
+
* Number of tokens in the generated completion. Only applicable for completion requests.
|
|
59
|
+
*/
|
|
60
|
+
completionTokens?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Number of tokens in the prompt.
|
|
63
|
+
*/
|
|
64
|
+
promptTokens?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Total number of tokens used in the request (prompt + completion).
|
|
67
|
+
*/
|
|
68
|
+
totalTokens?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Breakdown of tokens used in the prompt.
|
|
71
|
+
*/
|
|
72
|
+
promptTokensDetails?: PromptTokensDetails;
|
|
73
|
+
/**
|
|
74
|
+
* Breakdown of tokens used in a completion.
|
|
75
|
+
*/
|
|
76
|
+
completionTokenDetails?: CompletionTokenDetails;
|
|
77
|
+
constructor(completionTokens?: number, promptTokens?: number, totalTokens?: number, promptTokensDetails?: PromptTokensDetails, completionTokenDetails?: CompletionTokenDetails);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/common/api/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;GAEG;AACH,qBAAa,mBAAmB;IAC5B;;OAEG;IAEH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IAEH,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEV,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CAI1D;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAC/B;;OAEG;IAEH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IAEH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IAEH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IAEH,wBAAwB,CAAC,EAAE,MAAM,CAAC;gBAG9B,eAAe,CAAC,EAAE,MAAM,EACxB,wBAAwB,CAAC,EAAE,MAAM,EACjC,WAAW,CAAC,EAAE,MAAM,EACpB,wBAAwB,CAAC,EAAE,MAAM;CAOxC;AAED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