@llumiverse/core 0.24.0 → 0.25.0-dev.20260204.110528Z
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/package.json +2 -2
- package/lib/cjs/CompletionStream.js +0 -244
- package/lib/cjs/CompletionStream.js.map +0 -1
- package/lib/cjs/Driver.js +0 -194
- package/lib/cjs/Driver.js.map +0 -1
- package/lib/cjs/async.js +0 -131
- package/lib/cjs/async.js.map +0 -1
- package/lib/cjs/conversation-utils.js +0 -457
- package/lib/cjs/conversation-utils.js.map +0 -1
- package/lib/cjs/formatters/commons.js +0 -7
- package/lib/cjs/formatters/commons.js.map +0 -1
- package/lib/cjs/formatters/generic.js +0 -59
- package/lib/cjs/formatters/generic.js.map +0 -1
- package/lib/cjs/formatters/index.js +0 -20
- package/lib/cjs/formatters/index.js.map +0 -1
- package/lib/cjs/formatters/nova.js +0 -99
- package/lib/cjs/formatters/nova.js.map +0 -1
- package/lib/cjs/index.js +0 -22
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/json.js +0 -29
- package/lib/cjs/json.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/resolver.js +0 -45
- package/lib/cjs/resolver.js.map +0 -1
- package/lib/cjs/stream.js +0 -30
- package/lib/cjs/stream.js.map +0 -1
- package/lib/cjs/validation.js +0 -96
- package/lib/cjs/validation.js.map +0 -1
- package/lib/esm/CompletionStream.js +0 -239
- package/lib/esm/CompletionStream.js.map +0 -1
- package/lib/esm/Driver.js +0 -189
- package/lib/esm/Driver.js.map +0 -1
- package/lib/esm/async.js +0 -123
- package/lib/esm/async.js.map +0 -1
- package/lib/esm/conversation-utils.js +0 -447
- package/lib/esm/conversation-utils.js.map +0 -1
- package/lib/esm/formatters/commons.js +0 -4
- package/lib/esm/formatters/commons.js.map +0 -1
- package/lib/esm/formatters/generic.js +0 -55
- package/lib/esm/formatters/generic.js.map +0 -1
- package/lib/esm/formatters/index.js +0 -4
- package/lib/esm/formatters/index.js.map +0 -1
- package/lib/esm/formatters/nova.js +0 -96
- package/lib/esm/formatters/nova.js.map +0 -1
- package/lib/esm/index.js +0 -6
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/json.js +0 -25
- package/lib/esm/json.js.map +0 -1
- package/lib/esm/resolver.js +0 -42
- package/lib/esm/resolver.js.map +0 -1
- package/lib/esm/stream.js +0 -25
- package/lib/esm/stream.js.map +0 -1
- package/lib/esm/validation.js +0 -88
- package/lib/esm/validation.js.map +0 -1
- package/lib/types/CompletionStream.d.ts +0 -20
- package/lib/types/CompletionStream.d.ts.map +0 -1
- package/lib/types/Driver.d.ts +0 -86
- package/lib/types/Driver.d.ts.map +0 -1
- package/lib/types/async.d.ts +0 -27
- package/lib/types/async.d.ts.map +0 -1
- package/lib/types/conversation-utils.d.ts +0 -112
- package/lib/types/conversation-utils.d.ts.map +0 -1
- package/lib/types/formatters/commons.d.ts +0 -3
- package/lib/types/formatters/commons.d.ts.map +0 -1
- package/lib/types/formatters/generic.d.ts +0 -13
- package/lib/types/formatters/generic.d.ts.map +0 -1
- package/lib/types/formatters/index.d.ts +0 -4
- package/lib/types/formatters/index.d.ts.map +0 -1
- package/lib/types/formatters/nova.d.ts +0 -40
- package/lib/types/formatters/nova.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -6
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/json.d.ts +0 -4
- package/lib/types/json.d.ts.map +0 -1
- package/lib/types/resolver.d.ts +0 -2
- package/lib/types/resolver.d.ts.map +0 -1
- package/lib/types/stream.d.ts +0 -4
- package/lib/types/stream.d.ts.map +0 -1
- package/lib/types/validation.d.ts +0 -7
- package/lib/types/validation.d.ts.map +0 -1
package/lib/esm/json.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsonrepair } from 'jsonrepair';
|
|
2
|
-
function extractJsonFromText(text) {
|
|
3
|
-
const start = text.indexOf("{");
|
|
4
|
-
const end = text.lastIndexOf("}");
|
|
5
|
-
return text.substring(start, end + 1);
|
|
6
|
-
}
|
|
7
|
-
export function extractAndParseJSON(text) {
|
|
8
|
-
return parseJSON(extractJsonFromText(text));
|
|
9
|
-
}
|
|
10
|
-
export function parseJSON(text) {
|
|
11
|
-
text = text.trim();
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(text);
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
// use a relaxed parser
|
|
17
|
-
try {
|
|
18
|
-
return JSON.parse(jsonrepair(text));
|
|
19
|
-
}
|
|
20
|
-
catch (err2) { // throw the original error
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=json.js.map
|
package/lib/esm/json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,SAAS,mBAAmB,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC5C,OAAO,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IAClC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAChB,uBAAuB;QACvB,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,IAAS,EAAE,CAAC,CAAC,2BAA2B;YAC7C,MAAM,GAAG,CAAC;QACd,CAAC;IACL,CAAC;AACL,CAAC"}
|
package/lib/esm/resolver.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the property named by "name" of the given object
|
|
3
|
-
* If an array is indexed using a string key then a map is done and an array with the content of the properties with that name are returned
|
|
4
|
-
* Ex: docs.text => will return an array of text properties of the docs array
|
|
5
|
-
* @param object the object
|
|
6
|
-
* @param name the name of the property.
|
|
7
|
-
* @returns the property value
|
|
8
|
-
*/
|
|
9
|
-
function _prop(object, name) {
|
|
10
|
-
if (object === undefined) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(object)) {
|
|
14
|
-
const index = +name;
|
|
15
|
-
if (isNaN(index)) {
|
|
16
|
-
// map array to property
|
|
17
|
-
return object.map(item => item[name]);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return object[index];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return object[name];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function resolveField(object, path) {
|
|
28
|
-
let p = object;
|
|
29
|
-
if (!p)
|
|
30
|
-
return p;
|
|
31
|
-
if (!path.length)
|
|
32
|
-
return p;
|
|
33
|
-
const last = path.length - 1;
|
|
34
|
-
for (let i = 0; i < last; i++) {
|
|
35
|
-
p = _prop(p, path[i]);
|
|
36
|
-
if (!p) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return _prop(p, path[last]);
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=resolver.js.map
|
package/lib/esm/resolver.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","source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+0,0 @@
|
|
|
1
|
-
export async function readStreamAsBase64(stream) {
|
|
2
|
-
const uint8Array = await readStreamAsUint8Array(stream);
|
|
3
|
-
return Buffer.from(uint8Array).toString('base64');
|
|
4
|
-
}
|
|
5
|
-
export async function readStreamAsString(stream) {
|
|
6
|
-
const uint8Array = await readStreamAsUint8Array(stream);
|
|
7
|
-
return Buffer.from(uint8Array).toString();
|
|
8
|
-
}
|
|
9
|
-
export async function readStreamAsUint8Array(stream) {
|
|
10
|
-
const chunks = [];
|
|
11
|
-
let totalLength = 0;
|
|
12
|
-
for await (const chunk of stream) {
|
|
13
|
-
const uint8Chunk = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk);
|
|
14
|
-
chunks.push(uint8Chunk);
|
|
15
|
-
totalLength += uint8Chunk.length;
|
|
16
|
-
}
|
|
17
|
-
const combined = new Uint8Array(totalLength);
|
|
18
|
-
let offset = 0;
|
|
19
|
-
for (const chunk of chunks) {
|
|
20
|
-
combined.set(chunk, offset);
|
|
21
|
-
offset += chunk.length;
|
|
22
|
-
}
|
|
23
|
-
return combined;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=stream.js.map
|
package/lib/esm/stream.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAsB;IAC3D,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAsB;IAC3D,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAsB;IAC/D,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QAE/E,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxB,WAAW,IAAI,UAAU,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/lib/esm/validation.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Ajv } from 'ajv';
|
|
2
|
-
import addFormats from 'ajv-formats';
|
|
3
|
-
import { extractAndParseJSON } from "./json.js";
|
|
4
|
-
import { resolveField } from './resolver.js';
|
|
5
|
-
const ajv = new Ajv({
|
|
6
|
-
coerceTypes: 'array',
|
|
7
|
-
allowDate: true,
|
|
8
|
-
strict: false,
|
|
9
|
-
useDefaults: true,
|
|
10
|
-
removeAdditional: "failing"
|
|
11
|
-
});
|
|
12
|
-
//use ts ignore to avoid error with ESM and ajv-formats
|
|
13
|
-
// @ts-ignore This expression is not callable
|
|
14
|
-
addFormats(ajv);
|
|
15
|
-
export class ValidationError extends Error {
|
|
16
|
-
code;
|
|
17
|
-
constructor(code, message) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.code = code;
|
|
20
|
-
this.name = 'ValidationError';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function parseCompletionAsJson(data) {
|
|
24
|
-
let lastError;
|
|
25
|
-
for (const part of data) {
|
|
26
|
-
if (part.type === "text") {
|
|
27
|
-
const text = part.value.trim();
|
|
28
|
-
try {
|
|
29
|
-
return extractAndParseJSON(text);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
lastError = new ValidationError("json_error", error.message);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (!lastError) {
|
|
37
|
-
lastError = new ValidationError("json_error", "No JSON compatible response found in completion result");
|
|
38
|
-
}
|
|
39
|
-
throw lastError;
|
|
40
|
-
}
|
|
41
|
-
export function validateResult(data, schema) {
|
|
42
|
-
let json;
|
|
43
|
-
if (Array.isArray(data)) {
|
|
44
|
-
const jsonResults = data.filter(r => r.type === "json");
|
|
45
|
-
if (jsonResults.length > 0) {
|
|
46
|
-
json = jsonResults[0].value;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
try {
|
|
50
|
-
json = parseCompletionAsJson(data);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new ValidationError("json_error", error.message);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw new Error("Data to validate must be an array");
|
|
59
|
-
}
|
|
60
|
-
const validate = ajv.compile(schema);
|
|
61
|
-
const valid = validate(json);
|
|
62
|
-
if (!valid && validate.errors) {
|
|
63
|
-
let errors = [];
|
|
64
|
-
for (const e of validate.errors) {
|
|
65
|
-
const path = e.instancePath.split("/").slice(1);
|
|
66
|
-
const value = resolveField(json, path);
|
|
67
|
-
const schemaPath = e.schemaPath.split("/").slice(1);
|
|
68
|
-
const schemaFieldFormat = resolveField(schema, schemaPath);
|
|
69
|
-
const schemaField = resolveField(schema, schemaPath.slice(0, -3));
|
|
70
|
-
//ignore date if empty or null
|
|
71
|
-
if (!value
|
|
72
|
-
&& ["date", "date-time"].includes(schemaFieldFormat)
|
|
73
|
-
&& !schemaField?.required?.includes(path[path.length - 1])) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
errors.push(e);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
//console.log("Errors", errors)
|
|
81
|
-
if (errors.length > 0) {
|
|
82
|
-
const errorsMessage = errors.map(e => `${e.instancePath}: ${e.message}\n${JSON.stringify(e.params)}`).join(",\n\n");
|
|
83
|
-
throw new ValidationError("validation_error", errorsMessage);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return [{ type: "json", value: json }];
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAChB,WAAW,EAAE,OAAO;IACpB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,SAAS;CAC9B,CAAC,CAAC;AAEH,uDAAuD;AACvD,6CAA6C;AAC7C,UAAU,CAAC,GAAG,CAAC,CAAA;AAGf,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAE3B;IADX,YACW,IAAuC,EAC9C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAHP,SAAI,GAAJ,IAAI,CAAmC;QAI9C,IAAI,CAAC,IAAI,GAAG,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C;YACpB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpH,MAAM,IAAI,eAAe,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAA;QAChE,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CompletionStream, DriverOptions, ExecutionOptions, ExecutionResponse } from "@llumiverse/common";
|
|
2
|
-
import { AbstractDriver } from "./Driver.js";
|
|
3
|
-
export declare class DefaultCompletionStream<PromptT = any> implements CompletionStream<PromptT> {
|
|
4
|
-
driver: AbstractDriver<DriverOptions, PromptT>;
|
|
5
|
-
prompt: PromptT;
|
|
6
|
-
options: ExecutionOptions;
|
|
7
|
-
chunks: number;
|
|
8
|
-
completion: ExecutionResponse<PromptT> | undefined;
|
|
9
|
-
constructor(driver: AbstractDriver<DriverOptions, PromptT>, prompt: PromptT, options: ExecutionOptions);
|
|
10
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
11
|
-
}
|
|
12
|
-
export declare class FallbackCompletionStream<PromptT = any> implements CompletionStream<PromptT> {
|
|
13
|
-
driver: AbstractDriver<DriverOptions, PromptT>;
|
|
14
|
-
prompt: PromptT;
|
|
15
|
-
options: ExecutionOptions;
|
|
16
|
-
completion: ExecutionResponse<PromptT> | undefined;
|
|
17
|
-
constructor(driver: AbstractDriver<DriverOptions, PromptT>, prompt: PromptT, options: ExecutionOptions);
|
|
18
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=CompletionStream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionStream.d.ts","sourceRoot":"","sources":["../../src/CompletionStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAgC,MAAM,oBAAoB,CAAC;AACxI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,uBAAuB,CAAC,OAAO,GAAG,GAAG,CAAE,YAAW,gBAAgB,CAAC,OAAO,CAAC;IAKjE,MAAM,EAAE,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC;IACtD,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,gBAAgB;IALpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;gBAEhC,MAAM,EAAE,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,EACtD,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,gBAAgB;IAI7B,CAAC,MAAM,CAAC,aAAa,CAAC;CAkMhC;AAED,qBAAa,wBAAwB,CAAC,OAAO,GAAG,GAAG,CAAE,YAAW,gBAAgB,CAAC,OAAO,CAAC;IAIlE,MAAM,EAAE,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC;IACtD,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,gBAAgB;IAJpC,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;gBAEhC,MAAM,EAAE,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,EACtD,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,gBAAgB;IAG7B,CAAC,MAAM,CAAC,aAAa,CAAC;CA8BhC"}
|
package/lib/types/Driver.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classes to handle the execution of an interaction in an execution environment.
|
|
3
|
-
* Base abstract class is then implemented by each environment
|
|
4
|
-
* (eg: OpenAI, HuggingFace, etc.)
|
|
5
|
-
*/
|
|
6
|
-
import { AIModel, Completion, CompletionChunkObject, CompletionStream, DataSource, DriverOptions, EmbeddingsOptions, EmbeddingsResult, ExecutionOptions, ExecutionResponse, Logger, ModelSearchPayload, PromptOptions, PromptSegment, TrainingJob, TrainingOptions, TrainingPromptOptions } from "@llumiverse/common";
|
|
7
|
-
export declare function createLogger(logger: Logger | "console" | undefined): Logger;
|
|
8
|
-
export interface Driver<PromptT = unknown> {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param segments
|
|
12
|
-
* @param completion
|
|
13
|
-
* @param model the model to train
|
|
14
|
-
*/
|
|
15
|
-
createTrainingPrompt(options: TrainingPromptOptions): Promise<string>;
|
|
16
|
-
createPrompt(segments: PromptSegment[], opts: ExecutionOptions): Promise<PromptT>;
|
|
17
|
-
execute(segments: PromptSegment[], options: ExecutionOptions): Promise<ExecutionResponse<PromptT>>;
|
|
18
|
-
stream(segments: PromptSegment[], options: ExecutionOptions): Promise<CompletionStream<PromptT>>;
|
|
19
|
-
startTraining(dataset: DataSource, options: TrainingOptions): Promise<TrainingJob>;
|
|
20
|
-
cancelTraining(jobId: string): Promise<TrainingJob>;
|
|
21
|
-
getTrainingJob(jobId: string): Promise<TrainingJob>;
|
|
22
|
-
listModels(params?: ModelSearchPayload): Promise<AIModel[]>;
|
|
23
|
-
listTrainableModels(): Promise<AIModel[]>;
|
|
24
|
-
validateConnection(): Promise<boolean>;
|
|
25
|
-
generateEmbeddings(options: EmbeddingsOptions): Promise<EmbeddingsResult>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* To be implemented by each driver
|
|
29
|
-
*/
|
|
30
|
-
export declare abstract class AbstractDriver<OptionsT extends DriverOptions = DriverOptions, PromptT = unknown> implements Driver<PromptT> {
|
|
31
|
-
options: OptionsT;
|
|
32
|
-
logger: Logger;
|
|
33
|
-
abstract provider: string;
|
|
34
|
-
constructor(opts: OptionsT);
|
|
35
|
-
createTrainingPrompt(options: TrainingPromptOptions): Promise<string>;
|
|
36
|
-
startTraining(_dataset: DataSource, _options: TrainingOptions): Promise<TrainingJob>;
|
|
37
|
-
cancelTraining(_jobId: string): Promise<TrainingJob>;
|
|
38
|
-
getTrainingJob(_jobId: string): Promise<TrainingJob>;
|
|
39
|
-
validateResult(result: Completion, options: ExecutionOptions): void;
|
|
40
|
-
execute(segments: PromptSegment[], options: ExecutionOptions): Promise<ExecutionResponse<PromptT>>;
|
|
41
|
-
_execute(prompt: PromptT, options: ExecutionOptions): Promise<ExecutionResponse<PromptT>>;
|
|
42
|
-
protected isImageModel(_model: string): boolean;
|
|
43
|
-
stream(segments: PromptSegment[], options: ExecutionOptions): Promise<CompletionStream<PromptT>>;
|
|
44
|
-
/**
|
|
45
|
-
* Override this method to provide a custom prompt formatter
|
|
46
|
-
* @param segments
|
|
47
|
-
* @param options
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
protected formatPrompt(segments: PromptSegment[], opts: PromptOptions): Promise<PromptT>;
|
|
51
|
-
createPrompt(segments: PromptSegment[], opts: PromptOptions): Promise<PromptT>;
|
|
52
|
-
/**
|
|
53
|
-
* Must be overridden if the implementation cannot stream.
|
|
54
|
-
* Some implementation may be able to stream for certain models but not for others.
|
|
55
|
-
* You must overwrite and return false if the current model doesn't support streaming.
|
|
56
|
-
* The default implementation returns true, so it is assumed that the streaming can be done.
|
|
57
|
-
* If this method returns false then the streaming execution will fallback on a blocking execution streaming the entire response as a single event.
|
|
58
|
-
* @param options the execution options containing the target model name.
|
|
59
|
-
* @returns true if the execution can be streamed false otherwise.
|
|
60
|
-
*/
|
|
61
|
-
protected canStream(_options: ExecutionOptions): Promise<boolean>;
|
|
62
|
-
/**
|
|
63
|
-
* Get a list of models that can be trained.
|
|
64
|
-
* The default is to return an empty array
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
listTrainableModels(): Promise<AIModel[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Build the conversation context after streaming completion.
|
|
70
|
-
* Override this in driver implementations that support multi-turn conversations.
|
|
71
|
-
*
|
|
72
|
-
* @param prompt - The prompt that was sent (includes prior conversation context)
|
|
73
|
-
* @param result - The completion results from the streamed response
|
|
74
|
-
* @param toolUse - The tool calls from the streamed response (if any)
|
|
75
|
-
* @param options - The execution options
|
|
76
|
-
* @returns The updated conversation context, or undefined if not supported
|
|
77
|
-
*/
|
|
78
|
-
buildStreamingConversation(_prompt: PromptT, _result: unknown[], _toolUse: unknown[] | undefined, _options: ExecutionOptions): unknown | undefined;
|
|
79
|
-
abstract requestTextCompletion(prompt: PromptT, options: ExecutionOptions): Promise<Completion>;
|
|
80
|
-
abstract requestTextCompletionStream(prompt: PromptT, options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>>;
|
|
81
|
-
requestImageGeneration(_prompt: PromptT, _options: ExecutionOptions): Promise<Completion>;
|
|
82
|
-
abstract listModels(params?: ModelSearchPayload): Promise<AIModel[]>;
|
|
83
|
-
abstract validateConnection(): Promise<boolean>;
|
|
84
|
-
abstract generateEmbeddings(options: EmbeddingsOptions): Promise<EmbeddingsResult>;
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=Driver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Driver.d.ts","sourceRoot":"","sources":["../../src/Driver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACH,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EAEN,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,WAAW,EACX,eAAe,EACf,qBAAqB,EACxB,MAAM,oBAAoB,CAAC;AAkC5B,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SA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;;;;;OASG;IACH,0BAA0B,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAAE,EAClB,QAAQ,EAAE,OAAO,EAAE,GAAG,SAAS,EAC/B,QAAQ,EAAE,gBAAgB,GAC3B,OAAO,GAAG,SAAS;IAKtB,QAAQ,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAE/F,QAAQ,CAAC,2BAA2B,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAEzH,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAM/F,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAGpE,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAG/C,QAAQ,CAAC,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAErF"}
|
package/lib/types/async.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ServerSentEvent } from "@vertesia/api-fetch-client";
|
|
2
|
-
import { CompletionChunkObject } from "@llumiverse/common";
|
|
3
|
-
export declare function asyncMap<T, R>(asyncIterable: AsyncIterable<T>, callback: (value: T, index: number) => R): AsyncGenerator<Awaited<R>, void, unknown>;
|
|
4
|
-
export declare function oneAsyncIterator<T>(value: T): AsyncIterable<T>;
|
|
5
|
-
/**
|
|
6
|
-
* Given a ReadableStream of server sent events, tran
|
|
7
|
-
*/
|
|
8
|
-
export declare function transformSSEStream(stream: ReadableStream<ServerSentEvent>, transform: (data: string) => CompletionChunkObject): ReadableStream<CompletionChunkObject> & AsyncIterable<CompletionChunkObject>;
|
|
9
|
-
export declare class EventStream<T, ReturnT = any> implements AsyncIterable<T> {
|
|
10
|
-
private queue;
|
|
11
|
-
private pending?;
|
|
12
|
-
private done;
|
|
13
|
-
push(event: T): void;
|
|
14
|
-
/**
|
|
15
|
-
* Close the stream. This means the stream cannot be fed anymore.
|
|
16
|
-
* But the consumer can still consume the remaining events.
|
|
17
|
-
*/
|
|
18
|
-
close(value?: ReturnT): void;
|
|
19
|
-
[Symbol.asyncIterator](): AsyncIterator<T, ReturnT | undefined>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Transform an async iterator by applying a function to each value.
|
|
23
|
-
* @param originalGenerator
|
|
24
|
-
* @param transform
|
|
25
|
-
**/
|
|
26
|
-
export declare function transformAsyncIterator<T, V>(originalGenerator: AsyncIterable<T>, transform: (value: T) => V | Promise<V>, initCallback?: () => V | Promise<V>): AsyncIterable<V>;
|
|
27
|
-
//# sourceMappingURL=async.d.ts.map
|
package/lib/types/async.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,wBAAuB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,6CAI9G;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAM9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,qBAAqB,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAe5M;AAED,qBAAa,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,GAAG,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAElE,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,OAAO,CAAC,CAGd;IACF,OAAO,CAAC,IAAI,CAAS;IAGrB,IAAI,CAAC,KAAK,EAAE,CAAC;IAYb;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IAQrB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CA0BlE;AAID;;;;IAII;AACJ,wBAAuB,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAC9C,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC,EACnC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACvC,YAAY,CAAC,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACpC,aAAa,CAAC,CAAC,CAAC,CAOlB"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for cleaning up conversation objects before storage.
|
|
3
|
-
*
|
|
4
|
-
* These functions strip binary data (Uint8Array) and large base64 strings
|
|
5
|
-
* from conversation objects to prevent JSON.stringify corruption and reduce
|
|
6
|
-
* storage bloat.
|
|
7
|
-
*
|
|
8
|
-
* IMPORTANT: These functions replace entire image/document/video BLOCKS with
|
|
9
|
-
* text placeholders, not just the data. This ensures the conversation remains
|
|
10
|
-
* valid for subsequent API calls.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Metadata stored in conversation objects to track turn numbers for deferred image stripping.
|
|
14
|
-
*/
|
|
15
|
-
export interface ConversationMeta {
|
|
16
|
-
/** Current turn number (incremented each time a message is added) */
|
|
17
|
-
turnNumber: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Options for stripping functions
|
|
21
|
-
*/
|
|
22
|
-
export interface StripOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Number of turns to keep images before stripping.
|
|
25
|
-
* - 0 or undefined: Strip immediately (default)
|
|
26
|
-
* - N > 0: Keep images for N turns, then strip
|
|
27
|
-
*/
|
|
28
|
-
keepForTurns?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Current turn number. Used with keepForTurns to determine when to strip.
|
|
31
|
-
* If not provided, will be read from conversation metadata.
|
|
32
|
-
*/
|
|
33
|
-
currentTurn?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Maximum tokens for text content in tool results.
|
|
36
|
-
* Text exceeding this limit will be truncated.
|
|
37
|
-
* - undefined/0: No truncation (default)
|
|
38
|
-
* - N > 0: Truncate text to approximately N tokens (~4 chars/token)
|
|
39
|
-
*/
|
|
40
|
-
textMaxTokens?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get metadata from a conversation object, or return defaults.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getConversationMeta(conversation: unknown): ConversationMeta;
|
|
46
|
-
/**
|
|
47
|
-
* Set metadata on a conversation object.
|
|
48
|
-
* Arrays are wrapped in an object to preserve their type through JSON serialization.
|
|
49
|
-
*/
|
|
50
|
-
export declare function setConversationMeta(conversation: unknown, meta: ConversationMeta): unknown;
|
|
51
|
-
/**
|
|
52
|
-
* Unwrap a conversation array that was wrapped by setConversationMeta.
|
|
53
|
-
* If the conversation is not a wrapped array, returns undefined.
|
|
54
|
-
* Use this to extract the actual message array from a conversation object.
|
|
55
|
-
*/
|
|
56
|
-
export declare function unwrapConversationArray<T = unknown>(conversation: unknown): T[] | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Increment the turn number in a conversation and return the updated conversation.
|
|
59
|
-
*/
|
|
60
|
-
export declare function incrementConversationTurn(conversation: unknown): unknown;
|
|
61
|
-
/**
|
|
62
|
-
* Strip binary data (Uint8Array) from conversation to prevent JSON.stringify corruption.
|
|
63
|
-
*
|
|
64
|
-
* When Uint8Array is passed through JSON.stringify, it gets corrupted into an object
|
|
65
|
-
* like { "0": 137, "1": 80, ... } instead of proper binary data. This breaks
|
|
66
|
-
* subsequent API calls that expect binary data.
|
|
67
|
-
*
|
|
68
|
-
* This function either:
|
|
69
|
-
* - Strips images immediately (keepForTurns = 0, default)
|
|
70
|
-
* - Serializes images to base64 for safe storage, then strips after N turns
|
|
71
|
-
*
|
|
72
|
-
* @param obj The conversation object to strip binary data from
|
|
73
|
-
* @param options Optional settings for turn-based stripping
|
|
74
|
-
* @returns A new object with binary content handled appropriately
|
|
75
|
-
*/
|
|
76
|
-
export declare function stripBinaryFromConversation(obj: unknown, options?: StripOptions): unknown;
|
|
77
|
-
/**
|
|
78
|
-
* Restore Uint8Array from base64 serialization.
|
|
79
|
-
* Call this before sending conversation to API if images were preserved.
|
|
80
|
-
*/
|
|
81
|
-
export declare function deserializeBinaryFromStorage(obj: unknown): unknown;
|
|
82
|
-
/**
|
|
83
|
-
* Strip large base64 image data from conversation to reduce storage bloat.
|
|
84
|
-
*
|
|
85
|
-
* While base64 strings survive JSON.stringify (unlike Uint8Array), they can
|
|
86
|
-
* significantly bloat conversation storage. This function replaces entire
|
|
87
|
-
* image blocks with text placeholders:
|
|
88
|
-
* - OpenAI: { type: "image_url", image_url: { url: "data:..." } } → { type: "text", text: "[placeholder]" }
|
|
89
|
-
* - Gemini: { inlineData: { data: "...", mimeType: "..." } } → { text: "[placeholder]" }
|
|
90
|
-
*
|
|
91
|
-
* @param obj The conversation object to strip base64 images from
|
|
92
|
-
* @param options Optional settings for turn-based stripping
|
|
93
|
-
* @returns A new object with image blocks replaced with text placeholders
|
|
94
|
-
*/
|
|
95
|
-
export declare function stripBase64ImagesFromConversation(obj: unknown, options?: StripOptions): unknown;
|
|
96
|
-
/**
|
|
97
|
-
* Truncate large text content in conversation to reduce storage and context bloat.
|
|
98
|
-
*
|
|
99
|
-
* This function finds text strings in tool results and truncates them if they
|
|
100
|
-
* exceed the specified token limit (using ~4 chars/token estimate).
|
|
101
|
-
*
|
|
102
|
-
* Works with:
|
|
103
|
-
* - Bedrock: toolResult.content[].text
|
|
104
|
-
* - OpenAI: tool message content (string)
|
|
105
|
-
* - Gemini: function response content
|
|
106
|
-
*
|
|
107
|
-
* @param obj The conversation object to truncate text in
|
|
108
|
-
* @param options Options including textMaxTokens
|
|
109
|
-
* @returns A new object with large text content truncated
|
|
110
|
-
*/
|
|
111
|
-
export declare function truncateLargeTextInConversation(obj: unknown, options?: StripOptions): unknown;
|
|
112
|
-
//# sourceMappingURL=conversation-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-utils.d.ts","sourceRoot":"","sources":["../../src/conversation-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAyID;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,GAAG,gBAAgB,CAQ3E;AAKD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAS1F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,SAAS,CAQ3F;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAGxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAYzF;AA2BD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAwBlE;AAkDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAW/F;AA2CD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAU7F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commons.d.ts","sourceRoot":"","sources":["../../../src/formatters/commons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,UAErD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { JSONSchema } from "@llumiverse/common";
|
|
2
|
-
import { PromptSegment } from "@llumiverse/common";
|
|
3
|
-
interface Labels {
|
|
4
|
-
user: string;
|
|
5
|
-
system: string;
|
|
6
|
-
assistant: string;
|
|
7
|
-
safety: string;
|
|
8
|
-
instruction: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function createTextPromptFormatter(labels?: Labels): (segments: PromptSegment[], schema?: JSONSchema) => string;
|
|
11
|
-
declare const formatTextPrompt: (segments: PromptSegment[], schema?: JSONSchema) => string;
|
|
12
|
-
export { formatTextPrompt };
|
|
13
|
-
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/formatters/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG/D,UAAU,MAAM;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,MAMjD,IACqC,UAAU,aAAa,EAAE,EAAE,SAAS,UAAU,KAAG,MAAM,CA2C5F;AAED,QAAA,MAAM,gBAAgB,aA7C0B,aAAa,EAAE,WAAW,UAAU,KAAG,MA6CnC,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatters/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { JSONSchema } from "@llumiverse/common";
|
|
2
|
-
import { PromptSegment } from "@llumiverse/common";
|
|
3
|
-
export interface NovaMessage {
|
|
4
|
-
role: 'user' | 'assistant';
|
|
5
|
-
content: NovaMessagePart[];
|
|
6
|
-
}
|
|
7
|
-
export interface NovaSystemMessage {
|
|
8
|
-
text: string;
|
|
9
|
-
}
|
|
10
|
-
interface NovaMessagePart {
|
|
11
|
-
text?: string;
|
|
12
|
-
image?: {
|
|
13
|
-
format: "jpeg" | "png" | "gif" | "webp";
|
|
14
|
-
source: {
|
|
15
|
-
bytes: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
video?: {
|
|
19
|
-
format: "mkv" | "mov" | "mp4" | "webm" | "three_gp" | "flv" | "mpeg" | "mpg" | "wmv";
|
|
20
|
-
source: {
|
|
21
|
-
s3Location?: {
|
|
22
|
-
uri: string;
|
|
23
|
-
bucketOwner: string;
|
|
24
|
-
};
|
|
25
|
-
bytes?: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface NovaMessagesPrompt {
|
|
30
|
-
system?: NovaSystemMessage[];
|
|
31
|
-
messages: NovaMessage[];
|
|
32
|
-
negative?: string;
|
|
33
|
-
mask?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* A formatter used by Bedrock to format prompts for nova related models
|
|
37
|
-
*/
|
|
38
|
-
export declare function formatNovaPrompt(segments: PromptSegment[], schema?: JSONSchema): Promise<NovaMessagesPrompt>;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=nova.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nova.d.ts","sourceRoot":"","sources":["../../../src/formatters/nova.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAI/D,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAA;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAA;CACf;AAED,UAAU,eAAe;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE;QACJ,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;QACxC,MAAM,EAAE;YACJ,KAAK,EAAE,MAAM,CAAA;SAChB,CAAA;KACJ,CAAA;IACD,KAAK,CAAC,EAAE;QACJ,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;QACrF,MAAM,EAAE;YAEJ,UAAU,CAAC,EAAE;gBACT,GAAG,EAAE,MAAM,CAAC;gBACZ,WAAW,EAAE,MAAM,CAAA;aACtB,CAAA;YAED,KAAK,CAAC,EAAE,MAAM,CAAA;SACjB,CAAA;KACJ,CAAA;CACJ;AAED,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AAEH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6FlH"}
|
package/lib/types/index.d.ts
DELETED
package/lib/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
package/lib/types/json.d.ts
DELETED
package/lib/types/json.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAE3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAYjD"}
|
package/lib/types/resolver.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/resolver.ts"],"names":[],"mappings":"AA0BA,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAYvD"}
|
package/lib/types/stream.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function readStreamAsBase64(stream: ReadableStream): Promise<string>;
|
|
2
|
-
export declare function readStreamAsString(stream: ReadableStream): Promise<string>;
|
|
3
|
-
export declare function readStreamAsUint8Array(stream: ReadableStream): Promise<Uint8Array>;
|
|
4
|
-
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AACA,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhF;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhF;AAED,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAmBxF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CompletionResult, ResultValidationError } from "@llumiverse/common";
|
|
2
|
-
export declare class ValidationError extends Error implements ResultValidationError {
|
|
3
|
-
code: 'validation_error' | 'json_error';
|
|
4
|
-
constructor(code: 'validation_error' | 'json_error', message: string);
|
|
5
|
-
}
|
|
6
|
-
export declare function validateResult(data: CompletionResult[], schema: Object): CompletionResult[];
|
|
7
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAoB7E,qBAAa,eAAgB,SAAQ,KAAM,YAAW,qBAAqB;IAE5D,IAAI,EAAE,kBAAkB,GAAG,YAAY;gBAAvC,IAAI,EAAE,kBAAkB,GAAG,YAAY,EAC9C,OAAO,EAAE,MAAM;CAKtB;AAqBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAgD3F"}
|