llaminate 0.1.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/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/assets/llaminate-256.webp +0 -0
- package/assets/llaminate.jpg +0 -0
- package/assets/llaminate.webp +0 -0
- package/dist/build-info.json +5 -0
- package/dist/config.schema.json +126 -0
- package/dist/llaminate.d.ts +202 -0
- package/dist/llaminate.min.js +9 -0
- package/dist/llaminate.min.js.map +1 -0
- package/dist/ratelimiter.d.ts +33 -0
- package/dist/ratelimiter.min.js +7 -0
- package/dist/ratelimiter.min.js.map +1 -0
- package/dist/system.hbs +3 -0
- package/docs/LICENSE +21 -0
- package/docs/Llaminate.html +1040 -0
- package/docs/Llaminate.module_Endpoints.html +278 -0
- package/docs/Llaminate.module_Llaminate.html +200 -0
- package/docs/Llaminate.module_MimeTypes.html +275 -0
- package/docs/LlaminateConfig.html +667 -0
- package/docs/LlaminateMessage.html +328 -0
- package/docs/LlaminateResponse.html +253 -0
- package/docs/assets/llaminate-256.webp +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/index.html +142 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +358 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/jsdoc.json +23 -0
- package/package.json +38 -0
- package/scripts/build.sh +21 -0
- package/scripts/docs.sh +28 -0
- package/scripts/prebuild.js +43 -0
- package/scripts/prepare.sh +11 -0
- package/scripts/pretest.js +14 -0
- package/src/config.schema.json +126 -0
- package/src/llaminate.d.ts +99 -0
- package/src/llaminate.ts +1326 -0
- package/src/llaminate.types.js +176 -0
- package/src/ratelimiter.ts +95 -0
- package/src/system.hbs +3 -0
- package/tests/attachments.test.js +66 -0
- package/tests/common/base64.js +13 -0
- package/tests/common/matches.js +69 -0
- package/tests/common/setup.js +45 -0
- package/tests/complete.test.js +27 -0
- package/tests/extensions/toMatchSchema.js +20 -0
- package/tests/history.test.js +86 -0
- package/tests/stream.test.js +67 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Define source and destination paths, package information, and files to copy
|
|
5
|
+
|
|
6
|
+
const src = path.join(__dirname, "../src");
|
|
7
|
+
const dist = path.join(__dirname, "../dist");
|
|
8
|
+
|
|
9
|
+
const package = require("../package.json");
|
|
10
|
+
const files = ["config.schema.json", "system.hbs"];
|
|
11
|
+
|
|
12
|
+
// Ensure the dist directory exists
|
|
13
|
+
|
|
14
|
+
console.log('Preparing the dist directory.');
|
|
15
|
+
|
|
16
|
+
if (fs.existsSync(dist)) {
|
|
17
|
+
fs.rmSync(dist, { recursive: true, force: true });
|
|
18
|
+
}
|
|
19
|
+
fs.mkdirSync(dist);
|
|
20
|
+
|
|
21
|
+
// Generate build-info.json
|
|
22
|
+
|
|
23
|
+
console.log("Generating build-info.json.");
|
|
24
|
+
|
|
25
|
+
const build = {
|
|
26
|
+
name: package.name,
|
|
27
|
+
version: package.version,
|
|
28
|
+
date: new Date().toISOString(),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
fs.writeFileSync(
|
|
32
|
+
path.join(dist, "build-info.json"),
|
|
33
|
+
JSON.stringify(build, null, 2)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Copy config.schema.json to dist directory
|
|
37
|
+
|
|
38
|
+
console.log("Copying files to dist directory:");
|
|
39
|
+
|
|
40
|
+
files.forEach(file => {
|
|
41
|
+
fs.copyFileSync(path.join(src, file), path.join(dist, file));
|
|
42
|
+
console.log(` - ${file}`);
|
|
43
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Remove development files not to be packed or published.
|
|
4
|
+
echo "Removing development files not to be packed or published."
|
|
5
|
+
rm .env
|
|
6
|
+
rm tests/jest.config.json
|
|
7
|
+
rm tests/scratch.*
|
|
8
|
+
|
|
9
|
+
# Build the package.
|
|
10
|
+
echo "Building the package."
|
|
11
|
+
npm run build
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const dotenvx = require('@dotenvx/dotenvx');
|
|
3
|
+
dotenvx.config();
|
|
4
|
+
|
|
5
|
+
const jestConfig = {
|
|
6
|
+
displayName: `${process.env.TEST_MODEL} @ ${process.env.TEST_ENDPOINT}`,
|
|
7
|
+
"silent": true,
|
|
8
|
+
"setupFiles": ["@dotenvx/dotenvx/config"],
|
|
9
|
+
"testTimeout": 3600000,
|
|
10
|
+
"openHandlesTimeout": 3600000,
|
|
11
|
+
"passWithNoTests": true
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
fs.writeFileSync("./tests/jest.config.json", JSON.stringify(jestConfig, null, 2));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"endpoint": { "type": "string" },
|
|
6
|
+
"key": { "type": "string" },
|
|
7
|
+
"model": { "type": "string" },
|
|
8
|
+
"schema": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"type": { "type": "string" },
|
|
12
|
+
"properties": { "type": "object" },
|
|
13
|
+
"required": { "type": "array", "items": { "type": "string" } }
|
|
14
|
+
},
|
|
15
|
+
"additionalProperties": true
|
|
16
|
+
},
|
|
17
|
+
"system": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"items": { "type": "string" }
|
|
20
|
+
},
|
|
21
|
+
"history": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"role": { "type": "string", "enum": ["user", "assistant", "system", "tool", "developer"] },
|
|
27
|
+
"content": {},
|
|
28
|
+
"name": { "type": "string" },
|
|
29
|
+
"tool_calls": { "type": "array" },
|
|
30
|
+
"tool_call_id": { "type": "string" }
|
|
31
|
+
},
|
|
32
|
+
"required": ["role", "content"],
|
|
33
|
+
"additionalProperties": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"attachments": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"type": { "type": "string" },
|
|
42
|
+
"url": { "type": "string" }
|
|
43
|
+
},
|
|
44
|
+
"required": ["type", "url"]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"window": {
|
|
48
|
+
"type": "integer",
|
|
49
|
+
"minimum": 1
|
|
50
|
+
},
|
|
51
|
+
"tools": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"function": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"name": { "type": "string" },
|
|
60
|
+
"description": { "type": "string" },
|
|
61
|
+
"parameters": { "type": "object" },
|
|
62
|
+
"strict": { "type": "boolean" }
|
|
63
|
+
},
|
|
64
|
+
"required": ["name"]
|
|
65
|
+
},
|
|
66
|
+
"handler": { "not": { "type": "null" } }
|
|
67
|
+
},
|
|
68
|
+
"required": ["function"]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"handler": { "not": { "type": "null" } },
|
|
72
|
+
"options": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": true
|
|
75
|
+
},
|
|
76
|
+
"headers": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"additionalProperties": {
|
|
79
|
+
"type": "string"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"rpm": {
|
|
83
|
+
"type": "integer",
|
|
84
|
+
"minimum": 1
|
|
85
|
+
},
|
|
86
|
+
"quirks": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"properties": {
|
|
89
|
+
"attachments": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"properties": {
|
|
92
|
+
"document_url": { "type": "string", "enum": ["image_url"] },
|
|
93
|
+
"file": { "type": "boolean" },
|
|
94
|
+
"source": { "type": "boolean" }
|
|
95
|
+
},
|
|
96
|
+
"additionalProperties": true
|
|
97
|
+
},
|
|
98
|
+
"input_schema": { "type": "boolean" },
|
|
99
|
+
"json_schema": { "type": "boolean" },
|
|
100
|
+
"max_tokens": { "type": "integer", "minimum": 1 },
|
|
101
|
+
"output_config": { "type": "boolean" },
|
|
102
|
+
"role": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"system": { "type": "boolean" },
|
|
106
|
+
"tool": { "type": "boolean" }
|
|
107
|
+
},
|
|
108
|
+
"additionalProperties": true
|
|
109
|
+
},
|
|
110
|
+
"stream_options": { "type": "boolean" },
|
|
111
|
+
"tools": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"json_schema": { "type": "boolean" },
|
|
115
|
+
"json_object": { "type": "boolean" }
|
|
116
|
+
},
|
|
117
|
+
"additionalProperties": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"additionalProperties": true
|
|
121
|
+
},
|
|
122
|
+
"fetch": { "not": { "type": "null" } }
|
|
123
|
+
},
|
|
124
|
+
"required": ["endpoint", "key", "model"],
|
|
125
|
+
"additionalProperties": false
|
|
126
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// PUBLIC INTERFACES
|
|
2
|
+
|
|
3
|
+
interface LlaminateConfig {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
key: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
schema?: Record<string, any>;
|
|
8
|
+
system?: string[];
|
|
9
|
+
tools?: Tool[];
|
|
10
|
+
attachments?: URLAttachment[];
|
|
11
|
+
window?: number;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
options?: Record<string, any>;
|
|
14
|
+
rpm?: number;
|
|
15
|
+
history?: LlaminateMessage[];
|
|
16
|
+
fetch?: (endpoint: string, options: Record<string, any>) => Promise<Response>;
|
|
17
|
+
handler?: (name: string, args: Record<string, any>) => Promise<any>;
|
|
18
|
+
quirks?: LlaminateQuirks;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface LlaminateResponse {
|
|
22
|
+
message: string | any;
|
|
23
|
+
result: LlaminateMessage[];
|
|
24
|
+
tokens: Tokens;
|
|
25
|
+
uuid: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface LlaminateMessage {
|
|
29
|
+
role: "assistant" | "developer" | "system" | "user" | "tool";
|
|
30
|
+
content?: string | any; // Content can be a string or any JSON-serializable object, especially for tool messages
|
|
31
|
+
name?: string; // For tool messages
|
|
32
|
+
tool_calls?: ToolCall[]; // For assistant messages with tool calls
|
|
33
|
+
tool_call_id?: string; // For tool messages to link back to the call
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// SUBJECT TO CHANGE WITHOUT A MAJOR VERSION BUMP
|
|
37
|
+
|
|
38
|
+
interface LlaminateQuirks {
|
|
39
|
+
attachments?: {
|
|
40
|
+
document_url?: "image_url";
|
|
41
|
+
file?: boolean;
|
|
42
|
+
source?: boolean;
|
|
43
|
+
},
|
|
44
|
+
json_schema?: boolean;
|
|
45
|
+
input_schema?: boolean;
|
|
46
|
+
max_tokens?: number;
|
|
47
|
+
output_config?: boolean;
|
|
48
|
+
parallel_tool_calls?: boolean;
|
|
49
|
+
role?: {
|
|
50
|
+
system?: boolean;
|
|
51
|
+
tool?: boolean;
|
|
52
|
+
};
|
|
53
|
+
stream_options?: boolean;
|
|
54
|
+
tools?: {
|
|
55
|
+
json_schema?: boolean;
|
|
56
|
+
json_object?: boolean;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// PRIVATE INTERFACES (USED INTERNALLY)
|
|
61
|
+
|
|
62
|
+
interface Context {
|
|
63
|
+
messages: LlaminateMessage[];
|
|
64
|
+
result: LlaminateMessage[];
|
|
65
|
+
tools: Tool[];
|
|
66
|
+
subtotal: Tokens;
|
|
67
|
+
config: LlaminateConfig;
|
|
68
|
+
recurse: (messages: LlaminateMessage[], subtotal: Tokens) => AsyncGenerator<LlaminateResponse> | Promise<LlaminateResponse>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface Tool {
|
|
72
|
+
function: {
|
|
73
|
+
name: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
parameters: Record<string, any>;
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
};
|
|
78
|
+
handler?: (id: string, args: Record<string, any>) => Promise<any>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface ToolCall {
|
|
82
|
+
type: string;
|
|
83
|
+
function: {
|
|
84
|
+
name: string;
|
|
85
|
+
arguments: Record<string, any>;
|
|
86
|
+
}
|
|
87
|
+
id: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface URLAttachment {
|
|
91
|
+
type: string;
|
|
92
|
+
url: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface Tokens {
|
|
96
|
+
input: number;
|
|
97
|
+
output: number;
|
|
98
|
+
total: number;
|
|
99
|
+
}
|