@sprucelabs/sprucebot-llm 2.4.13 → 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.
@@ -0,0 +1 @@
1
+ export declare const FIRST_MESSAGES: string[];
@@ -0,0 +1,10 @@
1
+ export const FIRST_MESSAGES = [
2
+ 'hey',
3
+ 'Hey!',
4
+ "What's up!?",
5
+ 'Hello!',
6
+ 'Anyone there?',
7
+ 'test',
8
+ 'Hi',
9
+ 'Hi!',
10
+ ];
@@ -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(10).fill(0).forEach(() => generateCompletion(c));
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 generateCompletion(c) {
17
- const completion = `{{#${c + 1}}}`;
23
+ function generateOffTheRails(off) {
18
24
  const greeting = random(GREETINGS);
19
25
  const topics = renderTopics();
20
- const topic = TOPICS[c];
21
- const conversation = random(topic.conversations);
22
- const messages = render(conversation.messages
23
- .map((m) => `__${m.from}__: ${random(m.text)}`)
24
- .join('\n') + '\n__You__:', { topics });
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, { topics, greeting, messages }),
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[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIRST_MESSAGES = void 0;
4
+ exports.FIRST_MESSAGES = [
5
+ 'hey',
6
+ 'Hey!',
7
+ "What's up!?",
8
+ 'Hello!',
9
+ 'Anyone there?',
10
+ 'test',
11
+ 'Hi',
12
+ 'Hi!',
13
+ ];
@@ -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(10).fill(0).forEach(() => generateCompletion(c));
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 generateCompletion(c) {
42
- const completion = `{{#${c + 1}}}`;
48
+ function generateOffTheRails(off) {
43
49
  const greeting = random(GREETINGS_1.GREETINGS);
44
50
  const topics = renderTopics();
45
- const topic = TOPICS_1.TOPICS[c];
46
- const conversation = random(topic.conversations);
47
- const messages = render(conversation.messages
48
- .map((m) => `__${m.from}__: ${random(m.text)}`)
49
- .join('\n') + '\n__You__:', { topics });
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, { topics, greeting, messages }),
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
  }
@@ -15,6 +15,6 @@ DONE_DONE_DONE
15
15
 
16
16
  Let's get started:
17
17
 
18
- __Me__: hey
18
+ __Me__: {{firstMessage}}
19
19
  __You__: {{greeting}} {{topics}}
20
20
  {{messages}}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "@sprucelabs/spruce-test-fixtures"
10
10
  ]
11
11
  },
12
- "version": "2.4.13",
12
+ "version": "2.4.14",
13
13
  "files": [
14
14
  "build"
15
15
  ],