@llumiverse/common 0.22.0-dev.1 → 0.22.1
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/lib/cjs/capability/bedrock.js +2 -0
- package/lib/cjs/capability/bedrock.js.map +1 -1
- package/lib/cjs/options/bedrock.js +36 -0
- package/lib/cjs/options/bedrock.js.map +1 -1
- package/lib/cjs/options/vertexai.js +49 -0
- package/lib/cjs/options/vertexai.js.map +1 -1
- package/lib/cjs/types.js +0 -51
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/capability/bedrock.js +2 -0
- package/lib/esm/capability/bedrock.js.map +1 -1
- package/lib/esm/options/bedrock.js +36 -0
- package/lib/esm/options/bedrock.js.map +1 -1
- package/lib/esm/options/vertexai.js +49 -0
- package/lib/esm/options/vertexai.js.map +1 -1
- package/lib/esm/types.js +0 -48
- package/lib/esm/types.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/capability/bedrock.d.ts.map +1 -1
- package/lib/types/options/bedrock.d.ts +6 -1
- package/lib/types/options/bedrock.d.ts.map +1 -1
- package/lib/types/options/vertexai.d.ts +1 -0
- package/lib/types/options/vertexai.d.ts.map +1 -1
- package/lib/types/types.d.ts +17 -20
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +77 -77
- package/src/capability/bedrock.ts +2 -0
- package/src/options/bedrock.ts +43 -1
- package/src/options/vertexai.ts +49 -37
- package/src/types.ts +0 -50
package/src/options/bedrock.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ModelOptionsInfo, ModelOptions, OptionType, ModelOptionInfoItem } from
|
|
|
2
2
|
import { textOptionsFallback } from "./fallback.js";
|
|
3
3
|
|
|
4
4
|
// Union type of all Bedrock options
|
|
5
|
-
export type BedrockOptions = NovaCanvasOptions | BaseConverseOptions | BedrockClaudeOptions | BedrockPalmyraOptions | BedrockGptOssOptions;
|
|
5
|
+
export type BedrockOptions = NovaCanvasOptions | BaseConverseOptions | BedrockClaudeOptions | BedrockPalmyraOptions | BedrockGptOssOptions | TwelvelabsPegasusOptions;
|
|
6
6
|
|
|
7
7
|
export interface NovaCanvasOptions {
|
|
8
8
|
_option_id: "bedrock-nova-canvas"
|
|
@@ -51,6 +51,12 @@ export interface BedrockGptOssOptions extends BaseConverseOptions {
|
|
|
51
51
|
presence_penalty?: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export interface TwelvelabsPegasusOptions {
|
|
55
|
+
_option_id: "bedrock-twelvelabs-pegasus";
|
|
56
|
+
temperature?: number;
|
|
57
|
+
max_tokens?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
export function getMaxTokensLimitBedrock(model: string): number | undefined {
|
|
55
61
|
// Claude models
|
|
56
62
|
if (model.includes("claude")) {
|
|
@@ -135,6 +141,14 @@ export function getMaxTokensLimitBedrock(model: string): number | undefined {
|
|
|
135
141
|
if (model.includes("gpt-oss")) {
|
|
136
142
|
return 128000;
|
|
137
143
|
}
|
|
144
|
+
// TwelveLabs models
|
|
145
|
+
else if (model.includes("twelvelabs")) {
|
|
146
|
+
if (model.includes("pegasus")) {
|
|
147
|
+
return 4096; // Max output tokens for Pegasus
|
|
148
|
+
}
|
|
149
|
+
// Marengo is an embedding model, doesn't generate text
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
138
152
|
|
|
139
153
|
// Default fallback
|
|
140
154
|
return undefined;
|
|
@@ -476,6 +490,34 @@ export function getBedrockOptions(model: string, option?: ModelOptions): ModelOp
|
|
|
476
490
|
options: [...baseConverseOptionsNoStop, ...gptOssOptions]
|
|
477
491
|
};
|
|
478
492
|
}
|
|
493
|
+
else if (model.includes("twelvelabs")) {
|
|
494
|
+
if (model.includes("pegasus")) {
|
|
495
|
+
const pegasusOptions: ModelOptionInfoItem[] = [
|
|
496
|
+
{
|
|
497
|
+
name: "temperature",
|
|
498
|
+
type: OptionType.numeric,
|
|
499
|
+
min: 0.0,
|
|
500
|
+
max: 1.0,
|
|
501
|
+
default: 0.2,
|
|
502
|
+
step: 0.1,
|
|
503
|
+
description: "Controls randomness in the output"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: "max_tokens",
|
|
507
|
+
type: OptionType.numeric,
|
|
508
|
+
min: 1,
|
|
509
|
+
max: 4096,
|
|
510
|
+
integer: true,
|
|
511
|
+
step: 100,
|
|
512
|
+
description: "The maximum number of tokens to generate"
|
|
513
|
+
}
|
|
514
|
+
];
|
|
515
|
+
return {
|
|
516
|
+
_option_id: "bedrock-twelvelabs-pegasus",
|
|
517
|
+
options: pegasusOptions
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
}
|
|
479
521
|
|
|
480
522
|
//Fallback to converse standard.
|
|
481
523
|
return {
|
package/src/options/vertexai.ts
CHANGED
|
@@ -75,6 +75,7 @@ export interface VertexAIGeminiOptions {
|
|
|
75
75
|
seed?: number;
|
|
76
76
|
include_thoughts?: boolean;
|
|
77
77
|
thinking_budget_tokens?: number;
|
|
78
|
+
image_aspect_ratio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "9:16" | "16:9" | "21:9";
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
export function getVertexAiOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
|
|
@@ -247,46 +248,57 @@ function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
247
248
|
function getGeminiOptions(model: string, _option?: ModelOptions): ModelOptionsInfo {
|
|
248
249
|
// Special handling for gemini-2.5-flash-image
|
|
249
250
|
if (model.includes("gemini-2.5-flash-image")) {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
max: 1.0,
|
|
265
|
-
step: 0.01,
|
|
266
|
-
description: "Nucleus sampling probability"
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
name: "candidate_count",
|
|
270
|
-
type: OptionType.numeric,
|
|
271
|
-
min: 1,
|
|
272
|
-
max: 8,
|
|
273
|
-
default: 1,
|
|
274
|
-
integer: true,
|
|
275
|
-
description: "Number of candidates to generate"
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
name: SharedOptions.max_tokens,
|
|
279
|
-
type: OptionType.numeric,
|
|
280
|
-
min: 1,
|
|
281
|
-
max: 32768,
|
|
282
|
-
integer: true,
|
|
283
|
-
step: 200,
|
|
284
|
-
description: "Maximum output tokens"
|
|
251
|
+
const max_tokens_limit = 32768;
|
|
252
|
+
const excludeOptions = ["max_tokens", "presence_penalty", "frequency_penalty", "seed", "top_k"];
|
|
253
|
+
let commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
254
|
+
|
|
255
|
+
// Set max temperature to 2.0 for gemini-2.5-flash-image
|
|
256
|
+
commonOptions = commonOptions.map((option) => {
|
|
257
|
+
if (
|
|
258
|
+
option.name === SharedOptions.temperature &&
|
|
259
|
+
option.type === OptionType.numeric
|
|
260
|
+
) {
|
|
261
|
+
return {
|
|
262
|
+
...option,
|
|
263
|
+
max: 2.0,
|
|
264
|
+
};
|
|
285
265
|
}
|
|
286
|
-
|
|
266
|
+
return option;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const max_tokens: ModelOptionInfoItem[] = [{
|
|
270
|
+
name: SharedOptions.max_tokens,
|
|
271
|
+
type: OptionType.numeric,
|
|
272
|
+
min: 1,
|
|
273
|
+
max: max_tokens_limit,
|
|
274
|
+
integer: true,
|
|
275
|
+
step: 200,
|
|
276
|
+
description: "Maximum output tokens"
|
|
277
|
+
}];
|
|
278
|
+
|
|
279
|
+
const imageAspectRatio: ModelOptionInfoItem[] = [{
|
|
280
|
+
name: "image_aspect_ratio",
|
|
281
|
+
type: OptionType.enum,
|
|
282
|
+
enum: {
|
|
283
|
+
"1:1": "1:1",
|
|
284
|
+
"2:3": "2:3",
|
|
285
|
+
"3:2": "3:2",
|
|
286
|
+
"3:4": "3:4",
|
|
287
|
+
"4:3": "4:3",
|
|
288
|
+
"9:16": "9:16",
|
|
289
|
+
"16:9": "16:9",
|
|
290
|
+
"21:9": "21:9"
|
|
291
|
+
},
|
|
292
|
+
description: "Aspect ratio of the generated images"
|
|
293
|
+
}];
|
|
294
|
+
|
|
287
295
|
return {
|
|
288
296
|
_option_id: "vertexai-gemini",
|
|
289
|
-
options
|
|
297
|
+
options: [
|
|
298
|
+
...max_tokens,
|
|
299
|
+
...commonOptions,
|
|
300
|
+
...imageAspectRatio,
|
|
301
|
+
]
|
|
290
302
|
};
|
|
291
303
|
}
|
|
292
304
|
const max_tokens_limit = getGeminiMaxTokensLimit(model);
|
package/src/types.ts
CHANGED
|
@@ -178,56 +178,6 @@ export interface ImageResult extends BaseResult {
|
|
|
178
178
|
|
|
179
179
|
export type CompletionResult = TextResult | JsonResult | ImageResult;
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* Output as string
|
|
183
|
-
*/
|
|
184
|
-
export function completionResultToString(result: CompletionResult): string {
|
|
185
|
-
switch (result.type) {
|
|
186
|
-
case "text":
|
|
187
|
-
return result.value;
|
|
188
|
-
case "json":
|
|
189
|
-
return JSON.stringify(result.value, null, 2);
|
|
190
|
-
case "image":
|
|
191
|
-
return result.value;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Output as JSON, only handles the first JSON result or tries to parse text as JSON
|
|
197
|
-
* Expects the text to be pure JSON if no JSON result is found
|
|
198
|
-
* Throws if no JSON result is found or if parsing fails
|
|
199
|
-
*/
|
|
200
|
-
export function parseCompletionResultsToJson(results: CompletionResult[]): any {
|
|
201
|
-
const jsonResults = results.filter(r => r.type === "json");
|
|
202
|
-
if (jsonResults.length >= 1) {
|
|
203
|
-
return jsonResults[0].value;
|
|
204
|
-
//TODO: Handle multiple json type results
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const textResults = results.filter(r => r.type === "text").join();
|
|
208
|
-
if (textResults.length === 0) {
|
|
209
|
-
throw new Error("No JSON result found or failed to parse text");
|
|
210
|
-
}
|
|
211
|
-
try {
|
|
212
|
-
return JSON.parse(textResults);
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
throw new Error("No JSON result found or failed to parse text");
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Output as JSON if possible, otherwise as concatenated text
|
|
221
|
-
* Joins text results with the specified separator, default is empty string
|
|
222
|
-
* If multiple JSON results are found only the first one is returned
|
|
223
|
-
*/
|
|
224
|
-
export function parseCompletionResults(result: CompletionResult[], separator: string = ""): any {
|
|
225
|
-
try {
|
|
226
|
-
return parseCompletionResultsToJson(result);
|
|
227
|
-
} catch {
|
|
228
|
-
return result.map(completionResultToString).join(separator);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
181
|
|
|
232
182
|
//Internal structure used in driver implementation.
|
|
233
183
|
export interface CompletionChunkObject {
|