@sprucelabs/sprucebot-llm 2.4.12 → 2.4.14
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/build/esm/fineTuningSprucebot/constants/FIRST_MESSAGES.d.ts +1 -0
- package/build/esm/fineTuningSprucebot/constants/FIRST_MESSAGES.js +10 -0
- package/build/esm/fineTuningSprucebot/generateSamples.js +41 -9
- package/build/fineTuningSprucebot/constants/FIRST_MESSAGES.d.ts +1 -0
- package/build/fineTuningSprucebot/constants/FIRST_MESSAGES.js +13 -0
- package/build/fineTuningSprucebot/generateSamples.js +41 -9
- package/build/fineTuningSprucebot/promptTemplate.txt +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIRST_MESSAGES: string[];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
+
import { DONE_TOKEN } from '../bots/templates.js';
|
|
4
|
+
import { FIRST_MESSAGES } from './constants/FIRST_MESSAGES.js';
|
|
3
5
|
import { GREETINGS } from './constants/GREETINGS.js';
|
|
6
|
+
import { OFF_THE_RAILS_CONVERSATIONS } from './constants/OFF_THE_RAILS_CONVERSATIONS.js';
|
|
4
7
|
import { TOPICS } from './constants/TOPICS.js';
|
|
5
8
|
const promptTemplatePath = path.join(__dirname, 'promptTemplate.txt');
|
|
6
9
|
const promptTemplate = fs.readFileSync(promptTemplatePath, 'utf8');
|
|
@@ -10,23 +13,52 @@ if (!outputPath) {
|
|
|
10
13
|
throw new Error('No output path provided. Example: node generateSamples.js ~/output.json');
|
|
11
14
|
}
|
|
12
15
|
for (let c = 0; c < TOPICS.length; c++) {
|
|
13
|
-
new Array(
|
|
16
|
+
new Array(15).fill(0).forEach(() => generateCompletion(TOPICS, c));
|
|
17
|
+
}
|
|
18
|
+
for (let c = 0; c < OFF_THE_RAILS_CONVERSATIONS.length; c++) {
|
|
19
|
+
const off = OFF_THE_RAILS_CONVERSATIONS[c];
|
|
20
|
+
new Array(15).fill(0).forEach(() => generateOffTheRails(off));
|
|
14
21
|
}
|
|
15
22
|
fs.writeFileSync(outputPath, JSON.stringify(output, null, 2));
|
|
16
|
-
function
|
|
17
|
-
const completion = `{{#${c + 1}}}`;
|
|
23
|
+
function generateOffTheRails(off) {
|
|
18
24
|
const greeting = random(GREETINGS);
|
|
19
25
|
const topics = renderTopics();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
const messages = renderMessages([off.messages[0]], topics);
|
|
27
|
+
output.push({
|
|
28
|
+
prompt: render(promptTemplate, {
|
|
29
|
+
greeting,
|
|
30
|
+
topics,
|
|
31
|
+
messages,
|
|
32
|
+
firstMessage: random(FIRST_MESSAGES),
|
|
33
|
+
}),
|
|
34
|
+
completion: render(random(off.messages[1].text), { topics }),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function generateCompletion(ts, c) {
|
|
38
|
+
const completion = `{{#${c + 1}}}\n\n${DONE_TOKEN}`;
|
|
39
|
+
const greeting = random(GREETINGS);
|
|
40
|
+
const topic = ts[c];
|
|
41
|
+
const { topics, messages } = renderMessagesAndTopics(topic.conversations);
|
|
25
42
|
output.push({
|
|
26
|
-
prompt: render(promptTemplate, {
|
|
43
|
+
prompt: render(promptTemplate, {
|
|
44
|
+
firstMessage: random(FIRST_MESSAGES),
|
|
45
|
+
topics,
|
|
46
|
+
greeting,
|
|
47
|
+
messages,
|
|
48
|
+
}),
|
|
27
49
|
completion,
|
|
28
50
|
});
|
|
29
51
|
}
|
|
52
|
+
function renderMessagesAndTopics(conversations) {
|
|
53
|
+
const conversation = random(conversations);
|
|
54
|
+
const topics = renderTopics();
|
|
55
|
+
const rendered = renderMessages(conversation.messages, topics);
|
|
56
|
+
return { topics, messages: rendered };
|
|
57
|
+
}
|
|
58
|
+
function renderMessages(messages, topics) {
|
|
59
|
+
return render(messages.map((m) => `__${m.from}__: ${random(m.text)}`).join('\n') +
|
|
60
|
+
'\n__You__:', { topics });
|
|
61
|
+
}
|
|
30
62
|
function renderTopics() {
|
|
31
63
|
return TOPICS.map((t, idx) => `${idx + 1}. ${random(t.name)}`).join('\n');
|
|
32
64
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIRST_MESSAGES: string[];
|
|
@@ -25,7 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const fs = __importStar(require("fs"));
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
|
+
const templates_1 = require("../bots/templates");
|
|
29
|
+
const FIRST_MESSAGES_1 = require("./constants/FIRST_MESSAGES");
|
|
28
30
|
const GREETINGS_1 = require("./constants/GREETINGS");
|
|
31
|
+
const OFF_THE_RAILS_CONVERSATIONS_1 = require("./constants/OFF_THE_RAILS_CONVERSATIONS");
|
|
29
32
|
const TOPICS_1 = require("./constants/TOPICS");
|
|
30
33
|
const promptTemplatePath = path.join(__dirname, 'promptTemplate.txt');
|
|
31
34
|
const promptTemplate = fs.readFileSync(promptTemplatePath, 'utf8');
|
|
@@ -35,23 +38,52 @@ if (!outputPath) {
|
|
|
35
38
|
throw new Error('No output path provided. Example: node generateSamples.js ~/output.json');
|
|
36
39
|
}
|
|
37
40
|
for (let c = 0; c < TOPICS_1.TOPICS.length; c++) {
|
|
38
|
-
new Array(
|
|
41
|
+
new Array(15).fill(0).forEach(() => generateCompletion(TOPICS_1.TOPICS, c));
|
|
42
|
+
}
|
|
43
|
+
for (let c = 0; c < OFF_THE_RAILS_CONVERSATIONS_1.OFF_THE_RAILS_CONVERSATIONS.length; c++) {
|
|
44
|
+
const off = OFF_THE_RAILS_CONVERSATIONS_1.OFF_THE_RAILS_CONVERSATIONS[c];
|
|
45
|
+
new Array(15).fill(0).forEach(() => generateOffTheRails(off));
|
|
39
46
|
}
|
|
40
47
|
fs.writeFileSync(outputPath, JSON.stringify(output, null, 2));
|
|
41
|
-
function
|
|
42
|
-
const completion = `{{#${c + 1}}}`;
|
|
48
|
+
function generateOffTheRails(off) {
|
|
43
49
|
const greeting = random(GREETINGS_1.GREETINGS);
|
|
44
50
|
const topics = renderTopics();
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
const messages = renderMessages([off.messages[0]], topics);
|
|
52
|
+
output.push({
|
|
53
|
+
prompt: render(promptTemplate, {
|
|
54
|
+
greeting,
|
|
55
|
+
topics,
|
|
56
|
+
messages,
|
|
57
|
+
firstMessage: random(FIRST_MESSAGES_1.FIRST_MESSAGES),
|
|
58
|
+
}),
|
|
59
|
+
completion: render(random(off.messages[1].text), { topics }),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function generateCompletion(ts, c) {
|
|
63
|
+
const completion = `{{#${c + 1}}}\n\n${templates_1.DONE_TOKEN}`;
|
|
64
|
+
const greeting = random(GREETINGS_1.GREETINGS);
|
|
65
|
+
const topic = ts[c];
|
|
66
|
+
const { topics, messages } = renderMessagesAndTopics(topic.conversations);
|
|
50
67
|
output.push({
|
|
51
|
-
prompt: render(promptTemplate, {
|
|
68
|
+
prompt: render(promptTemplate, {
|
|
69
|
+
firstMessage: random(FIRST_MESSAGES_1.FIRST_MESSAGES),
|
|
70
|
+
topics,
|
|
71
|
+
greeting,
|
|
72
|
+
messages,
|
|
73
|
+
}),
|
|
52
74
|
completion,
|
|
53
75
|
});
|
|
54
76
|
}
|
|
77
|
+
function renderMessagesAndTopics(conversations) {
|
|
78
|
+
const conversation = random(conversations);
|
|
79
|
+
const topics = renderTopics();
|
|
80
|
+
const rendered = renderMessages(conversation.messages, topics);
|
|
81
|
+
return { topics, messages: rendered };
|
|
82
|
+
}
|
|
83
|
+
function renderMessages(messages, topics) {
|
|
84
|
+
return render(messages.map((m) => `__${m.from}__: ${random(m.text)}`).join('\n') +
|
|
85
|
+
'\n__You__:', { topics });
|
|
86
|
+
}
|
|
55
87
|
function renderTopics() {
|
|
56
88
|
return TOPICS_1.TOPICS.map((t, idx) => `${idx + 1}. ${random(t.name)}`).join('\n');
|
|
57
89
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"@sprucelabs/spruce-test-fixtures"
|
|
10
10
|
]
|
|
11
11
|
},
|
|
12
|
-
"version": "2.4.
|
|
12
|
+
"version": "2.4.14",
|
|
13
13
|
"files": [
|
|
14
14
|
"build"
|
|
15
15
|
],
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@sprucelabs/error": "^5.0.605",
|
|
58
|
-
"@sprucelabs/mercury-event-emitter": "^39.0.
|
|
59
|
-
"@sprucelabs/mercury-types": "^44.0.
|
|
58
|
+
"@sprucelabs/mercury-event-emitter": "^39.0.33",
|
|
59
|
+
"@sprucelabs/mercury-types": "^44.0.34",
|
|
60
60
|
"@sprucelabs/schema": "^28.6.18",
|
|
61
61
|
"eta": "^2.0.1",
|
|
62
62
|
"openai": "^3.2.1"
|