@far-world-labs/verblets 0.1.7 → 0.3.2

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.
Files changed (306) hide show
  1. package/README.md +86 -213
  2. package/dist/index.browser.js +74 -0
  3. package/dist/index.js +548 -0
  4. package/dist/shared-C6kPWghF.js +7806 -0
  5. package/package.json +32 -8
  6. package/.cursor/launch.json +0 -30
  7. package/.cursor/settings.json +0 -20
  8. package/.github/workflows/branch-protection.yml +0 -22
  9. package/.github/workflows/ci.yml +0 -165
  10. package/.husky/pre-commit +0 -4
  11. package/.prettierrc +0 -6
  12. package/.release-it.json +0 -12
  13. package/.vitest.config.examples.js +0 -8
  14. package/.vitest.config.js +0 -8
  15. package/.vscode/launch.json +0 -31
  16. package/AGENTS.md +0 -220
  17. package/DEVELOPING.md +0 -105
  18. package/docker-compose.yml +0 -7
  19. package/eslint.config.js +0 -80
  20. package/scripts/generate-chain/index.js +0 -111
  21. package/scripts/generate-lib/index.js +0 -68
  22. package/scripts/generate-test/index.js +0 -137
  23. package/scripts/generate-verblet/README.md +0 -17
  24. package/scripts/generate-verblet/index.js +0 -110
  25. package/scripts/run.sh +0 -15
  26. package/scripts/runner/index.js +0 -56
  27. package/scripts/simple-editor/README.md +0 -34
  28. package/scripts/simple-editor/index.js +0 -79
  29. package/scripts/summarize-files/index.js +0 -70
  30. package/src/chains/README.md +0 -30
  31. package/src/chains/anonymize/README.md +0 -21
  32. package/src/chains/anonymize/index.examples.js +0 -75
  33. package/src/chains/anonymize/index.js +0 -121
  34. package/src/chains/anonymize/index.spec.js +0 -78
  35. package/src/chains/bulk-central-tendency/index.examples.js +0 -138
  36. package/src/chains/bulk-central-tendency/index.js +0 -91
  37. package/src/chains/bulk-filter/README.md +0 -21
  38. package/src/chains/bulk-filter/index.examples.js +0 -22
  39. package/src/chains/bulk-filter/index.js +0 -58
  40. package/src/chains/bulk-filter/index.spec.js +0 -38
  41. package/src/chains/bulk-find/README.md +0 -16
  42. package/src/chains/bulk-find/index.examples.js +0 -20
  43. package/src/chains/bulk-find/index.js +0 -30
  44. package/src/chains/bulk-find/index.spec.js +0 -26
  45. package/src/chains/bulk-group/README.md +0 -23
  46. package/src/chains/bulk-group/index.examples.js +0 -18
  47. package/src/chains/bulk-group/index.js +0 -34
  48. package/src/chains/bulk-group/index.spec.js +0 -41
  49. package/src/chains/bulk-map/README.md +0 -43
  50. package/src/chains/bulk-map/index.examples.js +0 -17
  51. package/src/chains/bulk-map/index.js +0 -86
  52. package/src/chains/bulk-map/index.spec.js +0 -44
  53. package/src/chains/bulk-reduce/README.md +0 -12
  54. package/src/chains/bulk-reduce/index.examples.js +0 -15
  55. package/src/chains/bulk-reduce/index.js +0 -13
  56. package/src/chains/bulk-reduce/index.spec.js +0 -25
  57. package/src/chains/bulk-score/README.md +0 -16
  58. package/src/chains/bulk-score/bulk-score-result.json +0 -18
  59. package/src/chains/bulk-score/index.examples.js +0 -22
  60. package/src/chains/bulk-score/index.js +0 -133
  61. package/src/chains/bulk-score/index.spec.js +0 -30
  62. package/src/chains/category-samples/README.md +0 -61
  63. package/src/chains/category-samples/index.examples.js +0 -103
  64. package/src/chains/category-samples/index.js +0 -134
  65. package/src/chains/collect-terms/README.md +0 -12
  66. package/src/chains/collect-terms/index.examples.js +0 -16
  67. package/src/chains/collect-terms/index.js +0 -44
  68. package/src/chains/collect-terms/index.spec.js +0 -25
  69. package/src/chains/date/README.md +0 -12
  70. package/src/chains/date/index.examples.js +0 -47
  71. package/src/chains/date/index.js +0 -74
  72. package/src/chains/date/index.spec.js +0 -62
  73. package/src/chains/disambiguate/README.md +0 -22
  74. package/src/chains/disambiguate/disambiguate-meanings-result.json +0 -16
  75. package/src/chains/disambiguate/index.examples.js +0 -18
  76. package/src/chains/disambiguate/index.js +0 -92
  77. package/src/chains/disambiguate/index.spec.js +0 -25
  78. package/src/chains/dismantle/README.md +0 -67
  79. package/src/chains/dismantle/dismantle.examples.js +0 -27
  80. package/src/chains/dismantle/index.examples.js +0 -30
  81. package/src/chains/dismantle/index.js +0 -303
  82. package/src/chains/dismantle/index.spec.js +0 -32
  83. package/src/chains/expect/README.md +0 -171
  84. package/src/chains/expect/index.examples.js +0 -146
  85. package/src/chains/expect/index.js +0 -173
  86. package/src/chains/expect/index.spec.js +0 -324
  87. package/src/chains/filter-ambiguous/README.md +0 -11
  88. package/src/chains/filter-ambiguous/index.examples.js +0 -20
  89. package/src/chains/filter-ambiguous/index.js +0 -49
  90. package/src/chains/filter-ambiguous/index.spec.js +0 -31
  91. package/src/chains/glossary/README.md +0 -19
  92. package/src/chains/glossary/index.examples.js +0 -386
  93. package/src/chains/glossary/index.js +0 -75
  94. package/src/chains/glossary/index.spec.js +0 -19
  95. package/src/chains/intersections/README.md +0 -152
  96. package/src/chains/intersections/index.examples.js +0 -279
  97. package/src/chains/intersections/index.js +0 -366
  98. package/src/chains/intersections/intersection-result.json +0 -38
  99. package/src/chains/list/index.examples.js +0 -68
  100. package/src/chains/list/index.js +0 -214
  101. package/src/chains/list/index.spec.js +0 -67
  102. package/src/chains/list/list-result.json +0 -16
  103. package/src/chains/list/schema.json +0 -24
  104. package/src/chains/llm-logger/README.md +0 -208
  105. package/src/chains/llm-logger/index.js +0 -205
  106. package/src/chains/llm-logger/index.spec.js +0 -330
  107. package/src/chains/questions/index.examples.js +0 -69
  108. package/src/chains/questions/index.js +0 -135
  109. package/src/chains/questions/index.spec.js +0 -29
  110. package/src/chains/scan-js/index.js +0 -116
  111. package/src/chains/set-interval/README.md +0 -81
  112. package/src/chains/set-interval/index.examples.js +0 -36
  113. package/src/chains/set-interval/index.js +0 -131
  114. package/src/chains/set-interval/index.spec.js +0 -70
  115. package/src/chains/socratic/README.md +0 -17
  116. package/src/chains/socratic/index.js +0 -64
  117. package/src/chains/socratic/index.spec.js +0 -24
  118. package/src/chains/sort/index.examples.js +0 -36
  119. package/src/chains/sort/index.js +0 -163
  120. package/src/chains/sort/index.spec.js +0 -112
  121. package/src/chains/sort/sort-result.json +0 -16
  122. package/src/chains/summary-map/README.md +0 -41
  123. package/src/chains/summary-map/index.examples.js +0 -64
  124. package/src/chains/summary-map/index.js +0 -226
  125. package/src/chains/summary-map/index.spec.js +0 -153
  126. package/src/chains/test/index.js +0 -114
  127. package/src/chains/test-advice/index.js +0 -35
  128. package/src/chains/themes/README.md +0 -20
  129. package/src/chains/themes/index.examples.js +0 -17
  130. package/src/chains/themes/index.js +0 -28
  131. package/src/chains/themes/index.spec.js +0 -19
  132. package/src/chains/veiled-variants/index.examples.js +0 -18
  133. package/src/chains/veiled-variants/index.js +0 -107
  134. package/src/chains/veiled-variants/index.spec.js +0 -40
  135. package/src/constants/common.js +0 -7
  136. package/src/constants/messages.js +0 -3
  137. package/src/constants/models.js +0 -183
  138. package/src/index.js +0 -193
  139. package/src/json-schemas/README.md +0 -13
  140. package/src/json-schemas/cars-test.json +0 -11
  141. package/src/json-schemas/index.js +0 -12
  142. package/src/json-schemas/intent.json +0 -38
  143. package/src/json-schemas/schema-dot-org-photograph.json +0 -133
  144. package/src/json-schemas/schema-dot-org-place.json +0 -129
  145. package/src/lib/README.md +0 -26
  146. package/src/lib/any-signal/index.js +0 -28
  147. package/src/lib/bulk-filter/README.md +0 -22
  148. package/src/lib/bulk-filter/index.examples.js +0 -27
  149. package/src/lib/bulk-filter/index.js +0 -63
  150. package/src/lib/bulk-filter/index.spec.js +0 -38
  151. package/src/lib/bulk-find/README.md +0 -18
  152. package/src/lib/bulk-find/index.examples.js +0 -19
  153. package/src/lib/bulk-find/index.js +0 -30
  154. package/src/lib/bulk-find/index.spec.js +0 -41
  155. package/src/lib/chatgpt/index.js +0 -163
  156. package/src/lib/combinations/index.js +0 -30
  157. package/src/lib/combinations/index.spec.js +0 -23
  158. package/src/lib/editor/index.js +0 -31
  159. package/src/lib/functional/index.js +0 -28
  160. package/src/lib/logger-service/index.js +0 -32
  161. package/src/lib/parse-js-parts/index.js +0 -321
  162. package/src/lib/parse-js-parts/index.spec.js +0 -156
  163. package/src/lib/parse-llm-list/README.md +0 -39
  164. package/src/lib/parse-llm-list/index.js +0 -54
  165. package/src/lib/parse-llm-list/index.spec.js +0 -59
  166. package/src/lib/path-aliases/index.js +0 -37
  167. package/src/lib/path-aliases/index.spec.js +0 -64
  168. package/src/lib/pave/index.js +0 -34
  169. package/src/lib/pave/index.spec.js +0 -76
  170. package/src/lib/prompt-cache/index.js +0 -50
  171. package/src/lib/retry/index.js +0 -66
  172. package/src/lib/retry/index.spec.js +0 -86
  173. package/src/lib/ring-buffer/README.md +0 -460
  174. package/src/lib/ring-buffer/index.js +0 -1074
  175. package/src/lib/search-best-first/city-walk.spec.js +0 -37
  176. package/src/lib/search-best-first/index.js +0 -97
  177. package/src/lib/search-best-first/index.spec.js +0 -35
  178. package/src/lib/search-js-files/code-features-property-definitions.json +0 -123
  179. package/src/lib/search-js-files/index.examples.js +0 -22
  180. package/src/lib/search-js-files/index.js +0 -155
  181. package/src/lib/search-js-files/index.spec.js +0 -34
  182. package/src/lib/search-js-files/scan-file.js +0 -242
  183. package/src/lib/shorten-text/index.js +0 -25
  184. package/src/lib/shorten-text/index.spec.js +0 -68
  185. package/src/lib/strip-numeric/index.js +0 -5
  186. package/src/lib/strip-response/index.js +0 -30
  187. package/src/lib/template-replace/index.js +0 -23
  188. package/src/lib/template-replace/index.spec.js +0 -60
  189. package/src/lib/timed-abort-controller/index.js +0 -41
  190. package/src/lib/to-bool/index.js +0 -8
  191. package/src/lib/to-date/index.js +0 -11
  192. package/src/lib/to-enum/index.js +0 -14
  193. package/src/lib/to-number/index.js +0 -12
  194. package/src/lib/to-number-with-units/index.js +0 -51
  195. package/src/lib/transcribe/index.js +0 -78
  196. package/src/prompts/README.md +0 -17
  197. package/src/prompts/as-enum.js +0 -5
  198. package/src/prompts/as-json-schema.js +0 -9
  199. package/src/prompts/as-object-with-schema.js +0 -26
  200. package/src/prompts/as-schema-org-text.js +0 -25
  201. package/src/prompts/as-schema-org-type.js +0 -1
  202. package/src/prompts/blog-post.js +0 -7
  203. package/src/prompts/code-features.js +0 -24
  204. package/src/prompts/constants.js +0 -101
  205. package/src/prompts/features-json-schema.js +0 -27
  206. package/src/prompts/generate-collection.js +0 -26
  207. package/src/prompts/generate-list.js +0 -48
  208. package/src/prompts/generate-questions.js +0 -19
  209. package/src/prompts/index.js +0 -20
  210. package/src/prompts/intent.js +0 -60
  211. package/src/prompts/output-succinct-names.js +0 -3
  212. package/src/prompts/select-from-threshold.js +0 -17
  213. package/src/prompts/sort.js +0 -31
  214. package/src/prompts/style.js +0 -38
  215. package/src/prompts/summarize.js +0 -13
  216. package/src/prompts/token-budget.js +0 -3
  217. package/src/prompts/wrap-list.js +0 -11
  218. package/src/prompts/wrap-variable.js +0 -36
  219. package/src/services/llm-model/global-overrides.spec.js +0 -432
  220. package/src/services/llm-model/index.js +0 -308
  221. package/src/services/llm-model/model.js +0 -21
  222. package/src/services/llm-model/negotiate.spec.js +0 -447
  223. package/src/services/redis/index.js +0 -147
  224. package/src/test/setup.js +0 -20
  225. package/src/verblets/README.md +0 -26
  226. package/src/verblets/auto/index.examples.js +0 -31
  227. package/src/verblets/auto/index.js +0 -28
  228. package/src/verblets/auto/index.spec.js +0 -32
  229. package/src/verblets/bool/README.md +0 -36
  230. package/src/verblets/bool/index.examples.js +0 -80
  231. package/src/verblets/bool/index.js +0 -25
  232. package/src/verblets/bool/index.schema.json +0 -14
  233. package/src/verblets/bool/index.spec.js +0 -33
  234. package/src/verblets/central-tendency/README.md +0 -166
  235. package/src/verblets/central-tendency/central-tendency-result.json +0 -24
  236. package/src/verblets/central-tendency/index.examples.js +0 -196
  237. package/src/verblets/central-tendency/index.js +0 -171
  238. package/src/verblets/central-tendency/index.spec.js +0 -148
  239. package/src/verblets/enum/index.examples.js +0 -30
  240. package/src/verblets/enum/index.js +0 -18
  241. package/src/verblets/enum/index.spec.js +0 -35
  242. package/src/verblets/expect/README.md +0 -64
  243. package/src/verblets/expect/index.examples.js +0 -109
  244. package/src/verblets/expect/index.js +0 -75
  245. package/src/verblets/expect/index.spec.js +0 -127
  246. package/src/verblets/intent/index.examples.js +0 -139
  247. package/src/verblets/intent/index.js +0 -60
  248. package/src/verblets/intent/index.spec.js +0 -31
  249. package/src/verblets/intersection/README.md +0 -16
  250. package/src/verblets/intersection/index.examples.js +0 -89
  251. package/src/verblets/intersection/index.js +0 -84
  252. package/src/verblets/intersection/index.spec.js +0 -60
  253. package/src/verblets/intersection/intersection-result.json +0 -16
  254. package/src/verblets/list-expand/README.md +0 -10
  255. package/src/verblets/list-expand/index.examples.js +0 -14
  256. package/src/verblets/list-expand/index.js +0 -104
  257. package/src/verblets/list-expand/index.spec.js +0 -18
  258. package/src/verblets/list-expand/list-expand-result.json +0 -16
  259. package/src/verblets/list-filter/README.md +0 -22
  260. package/src/verblets/list-filter/index.examples.js +0 -26
  261. package/src/verblets/list-filter/index.js +0 -18
  262. package/src/verblets/list-filter/index.spec.js +0 -19
  263. package/src/verblets/list-find/README.md +0 -11
  264. package/src/verblets/list-find/index.examples.js +0 -15
  265. package/src/verblets/list-find/index.js +0 -17
  266. package/src/verblets/list-find/index.spec.js +0 -19
  267. package/src/verblets/list-group/README.md +0 -16
  268. package/src/verblets/list-group/index.examples.js +0 -16
  269. package/src/verblets/list-group/index.js +0 -112
  270. package/src/verblets/list-group/index.spec.js +0 -35
  271. package/src/verblets/list-group/list-group-result.json +0 -16
  272. package/src/verblets/list-map/README.md +0 -11
  273. package/src/verblets/list-map/index.examples.js +0 -15
  274. package/src/verblets/list-map/index.js +0 -26
  275. package/src/verblets/list-map/index.spec.js +0 -17
  276. package/src/verblets/list-reduce/README.md +0 -10
  277. package/src/verblets/list-reduce/index.examples.js +0 -14
  278. package/src/verblets/list-reduce/index.js +0 -21
  279. package/src/verblets/list-reduce/index.spec.js +0 -27
  280. package/src/verblets/list-reduce/index.spec.jsx +0 -27
  281. package/src/verblets/name/README.md +0 -15
  282. package/src/verblets/name/index.examples.js +0 -28
  283. package/src/verblets/name/index.js +0 -19
  284. package/src/verblets/name/index.spec.js +0 -33
  285. package/src/verblets/name-similar-to/README.md +0 -26
  286. package/src/verblets/name-similar-to/index.examples.js +0 -18
  287. package/src/verblets/name-similar-to/index.js +0 -20
  288. package/src/verblets/name-similar-to/index.spec.js +0 -13
  289. package/src/verblets/number/index.examples.js +0 -199
  290. package/src/verblets/number/index.js +0 -25
  291. package/src/verblets/number/index.spec.js +0 -33
  292. package/src/verblets/number-with-units/index.examples.js +0 -38
  293. package/src/verblets/number-with-units/index.js +0 -84
  294. package/src/verblets/number-with-units/index.spec.js +0 -46
  295. package/src/verblets/number-with-units/number-with-units-result.json +0 -23
  296. package/src/verblets/schema-org/index.examples.js +0 -51
  297. package/src/verblets/schema-org/index.js +0 -37
  298. package/src/verblets/schema-org/index.spec.js +0 -39
  299. package/src/verblets/sentiment/README.md +0 -10
  300. package/src/verblets/sentiment/index.examples.js +0 -20
  301. package/src/verblets/sentiment/index.js +0 -9
  302. package/src/verblets/sentiment/index.spec.js +0 -20
  303. package/src/verblets/to-object/README.md +0 -38
  304. package/src/verblets/to-object/index.examples.js +0 -29
  305. package/src/verblets/to-object/index.js +0 -131
  306. package/src/verblets/to-object/index.spec.js +0 -71
@@ -1,17 +0,0 @@
1
- # Prompts
2
-
3
- Prompts are functions that produce a single LLM prompt. They can be parameterized in a number of ways in order to fit their problem as closely as possible.
4
-
5
- ## Prompt Functions
6
-
7
- Currently there isn't much to the structure of these functions, and they're not currently tested.
8
-
9
- Going forward, functions should output a structured representation whose contents can be validated. An obvious candidate for this representation is HTML.
10
-
11
- The functions can generate HTML from their inputs and this structure can be transformed into text before sending to ChatGPT. This approach has many benefits. We can use all the tools available for working with HTML. The function outputs can be tested. All varieties of markup problems, like nested content, are trivially solved as well.
12
-
13
- # Constants
14
-
15
- The text snippets used by many prompt functions are collected in
16
- [`constants.js`](./constants.js). As the set of fragments grows it may make sense
17
- to manage them with a CMS such as Strapi.
@@ -1,5 +0,0 @@
1
- export default (enumVal) => {
2
- const keys = Object.keys(enumVal);
3
- const options = keys.map((k) => `"${k}"`).join(', ');
4
- return `Choose from one of the following options: ${options}.`;
5
- };
@@ -1,9 +0,0 @@
1
- import { onlyJSON } from './constants.js';
2
-
3
- export default (propertiesDescription) => {
4
- return `Give me a JSONSchema definition for the following properties: ${propertiesDescription}
5
-
6
- Include per-property metadata as JSON comments.
7
-
8
- ${onlyJSON}`;
9
- };
@@ -1,26 +0,0 @@
1
- import { contentIsExampleObject, onlyJSON } from './constants.js';
2
-
3
- const jsonSchemaDefault = {
4
- type: 'object',
5
- properties: {
6
- name: {
7
- type: 'string',
8
- },
9
- },
10
- };
11
-
12
- export default (jsonSchema = jsonSchemaDefault) => {
13
- const propertiesJoined = Object.entries(jsonSchema.properties)
14
- .map(([key, val]) => {
15
- const annotations = Object.entries(val).filter(
16
- ([annKey, annVal]) => ['format', 'description'].includes(annKey) && !!annVal
17
- );
18
- const annotationsFormatted = annotations.map(([k, v]) => `${k}: ${v}`).join(', ');
19
- const annotationsWrapped = annotations.length ? ` (${annotationsFormatted})` : '';
20
- return `"${key}": "<${val.type ?? ''}${annotationsWrapped}>"`;
21
- })
22
- .join(', ');
23
-
24
- return `${contentIsExampleObject} \`{ ${propertiesJoined} }\`. ${onlyJSON}.
25
- `;
26
- };
@@ -1,25 +0,0 @@
1
- import { contentIsSchema, onlyJSON } from './constants.js';
2
- import asSchemaOrgType from './as-schema-org-type.js';
3
- import wrapVariable from './wrap-variable.js';
4
-
5
- const ensureNumbers = 'ensure values meant to be numbers are numbers';
6
- const ensureSchemaOrgType = 'ensure the type is a real schema.org type';
7
- const ensureProperties = 'ensure the returned object has @context, name';
8
-
9
- export default (object, type, schema) => {
10
- const typeText = `${asSchemaOrgType(type)}`;
11
- const schemaText = schema
12
- ? `\n${contentIsSchema} ${wrapVariable(JSON.stringify(schema), {
13
- tag: 'schema',
14
- })}`
15
- : '';
16
-
17
- return `Give me "${object}" in schema.org JSON format with a full set of properties. ${
18
- typeText ? `${typeText}.` : ''
19
- }
20
- - ${ensureNumbers}
21
- - ${ensureSchemaOrgType}
22
- - ${ensureProperties}
23
- ${schemaText}
24
- ${onlyJSON}`;
25
- };
@@ -1 +0,0 @@
1
- export default (type) => (type ? `Ensure the type is ${type}. ` : '');
@@ -1,7 +0,0 @@
1
- export default (
2
- text
3
- ) => `Use the following information to create a blog post. Don't necessarily use all of the information. Keep your sentences varied, but nothing too long. Focus on writing an interesting, engaging post:
4
- \`\`\`
5
- ${text}
6
- \`\`\`
7
- `;
@@ -1,24 +0,0 @@
1
- import { asJSON, explainAndSeparate, explainAndSeparateJSON } from './constants.js';
2
-
3
- export default ({ text, schema }) => {
4
- return `Analyze the following code to provide scores for each of the features described below.
5
-
6
- For each feature, assign a score between 0.0 and 1.0 based on the criteria outlined in the description. If the code does not exhibit the feature, provide a score of 0.0.
7
-
8
- Ensure that all scores are assigned as numeric decimal values, even if the feature is not applicable or not present in the code.
9
-
10
- Include only the properties defined in the schema, no comment, description, summary, evaluation or any similar properties.
11
-
12
- <json-schema defines-output output-shape>
13
- ${JSON.stringify(schema, null, 2)}
14
- </json-schema>
15
-
16
- <code-to-analyze do-not-output>
17
- ${text}
18
- </code-to-analyze>
19
-
20
- ${asJSON}
21
-
22
- ${explainAndSeparate} ${explainAndSeparateJSON}
23
- `;
24
- };
@@ -1,101 +0,0 @@
1
- // Basic
2
- export const asUndefinedByDefault = 'If you are unsure, say "undefined" as your answer.';
3
- export const asBool = 'Answer the question either with "true" or "false" as your answer.';
4
- export const asNumber =
5
- 'Answer the question with a number that could be parsed by the JS Number constructor. Do not include formatting, units, digit group separators, or spelled-out numbers in your answer.';
6
- export const asDate =
7
- 'Answer the question with a date that can be parsed by the JS Date constructor. ISO format is preferred. Do not include additional text or punctuation.';
8
- export const asJSON =
9
- 'Respond with a JSON object or array that parses with JSON.parse, with no wrapping code block, and no wrapping XML.';
10
-
11
- // Response steering
12
- export const useLineNumber = 'Include the line number where each check is performed.';
13
- export const noFalseInformation = 'Do not include false information.';
14
- export const strictFormat = 'You MUST follow the format as described.';
15
- export const tryCompleteData = 'Err towards giving complete data, even if you have to guess.';
16
-
17
- // JSON Output
18
- export const onlyJSON =
19
- 'Respond with a JSON object or array that parses with JSON.parse, with no other text and no code block.';
20
- const onlyJSONArrayBase =
21
- 'Respond with a JSON array that parses with JSON.parse, with no additional text, no punctuation, and no code block.';
22
- export const onlyJSONArray = onlyJSONArrayBase;
23
- export const onlyJSONStringArray = `${onlyJSONArrayBase} The array should only contain text. No additional structure.`;
24
- export const onlyJSONStringArrayPerLine =
25
- 'For each input line, return exactly one line containing a JSON array of strings. No additional text, no code blocks.';
26
- export const onlyJSONObjectArray =
27
- 'Return an array of obects--not strings, and not just the objects.';
28
- export const onlyJSONStringArrayAlt1 = 'Output an JSON array of strings.';
29
- export const asSplitIntoJSONArray = 'Split the following to a JSON array.';
30
- export const onlyFullCode =
31
- 'Output only the full code generated, with no other text and no code block.';
32
- export const asNumberWithUnits = `${onlyJSON} It should take the form "{ "value": 42, "unit": "<SI or other unit name>" }".`;
33
- export const shapeAsJSON =
34
- 'Even if the input is not JSON, describe as much as possible in a JSON structure that corresponds to the input.';
35
-
36
- // Content headers
37
- export const contentIsQuestion = 'Question:';
38
- export const contentIsInstructions = 'Instructions:';
39
- export const contentIsDetails = 'Details:';
40
- export const contentIsFixes = 'Fixes:';
41
- export const contentIsMain = 'Focus all efforts on this content here:';
42
- export const contentToJSON = 'Contents to convert to JSON:';
43
- export const contentIsExample = 'Use this as example output only:';
44
- export const contentIsChoices = 'Choose only from the following:';
45
- export const contentIsTransformationSource = 'Transform the following object:';
46
- export const contentListCriteria = 'Create a list of items with the following description:';
47
- export const contentListItemCriteria = 'Make sure each item meets the following conditions:';
48
- export const contentListToOmit = 'Do not use any of the following items:';
49
- export const contentIsExampleObject =
50
- 'The returned object must look like the following, including all the same properties:';
51
- export const contentIsSchema = 'Make it conform exactly to the following schema:';
52
- export const contentHasIntent = 'What is the intent of the following message:';
53
- export const contentIsSortCriteria = 'Sort the following items by:';
54
- export const contentIsIntent = 'Give me an intent response for the following:';
55
- export const contentIsOperationOption = 'The extracted operation must be one of the following:';
56
- export const contentIsParametersOptions =
57
- 'The extracted parameters must be from the following options:';
58
-
59
- // Give explanation
60
- export const explainAndSeparate =
61
- 'Give an explanation followed by a succinct answer. The explanation part should come first, and should be at least 100 words. Next, insert a row of 20 equal signs (=) to create a clear separation.';
62
- export const explainAndSeparateJSON =
63
- 'The content below the dividing line should only be valid JSON that can be parsed with JSON.parse.';
64
- export const explainAndSeparatePrimitive =
65
- 'Next insert the succinctly-stated answer should be below the dividing line and work as a primitive datatype in JS. Be as succinct as possible as it will be parsed by a script.';
66
-
67
- // Reflective
68
- export const thinkStepByStep = "Let's think step by step";
69
- export const identifyUnclearInfo =
70
- 'Identify any unclear or ambiguous information in your response, and rephrase it for clarity.';
71
- export const argueAgainstOutput =
72
- 'Try to argue against your own output and see if you can find any flaws. If so, address them. Walk me through the process';
73
- export const rateBasic =
74
- 'Rate on a scale in the decimal from 0-1 how the content satisfies the following criteria. Be candidly critical and strict in your assessment.';
75
- export const rateSatisfaction =
76
- 'Rate on a scale in the decimal from 0-1 how well you satisfied each point in the initial prompt. Be very critical, no need to justify yourself.';
77
- export const rewriteBasedOnRating = 'If 0.3 or lower, rewrite to address.';
78
- export const requestAdditionalInput =
79
- 'What additional input do you need from me to help you write better output?';
80
- export const summarizeRequest =
81
- 'Please summarise what I am asking for you before you begin your answer.';
82
-
83
- // Analytical
84
- export const considerProsCons = 'Consider both pros and cons before arriving at a conclusion.';
85
- export const provideExamples = 'Provide specific examples to illustrate your point.';
86
- export const explainReasoning = 'Explain the reasoning behind your answer.';
87
- export const alternativeSolutions =
88
- 'If there are any alternative solutions or perspectives, please share them.';
89
- export const explainToChild = 'How would you explain this topic to a child?';
90
- export const identifyAssumptions = 'What assumptions are you making?';
91
- export const alternativeInterpretations = 'How else could this be interpreted?';
92
-
93
- // Evidence-Based
94
- export const evidenceSupportsView = 'What evidence supports your view?';
95
- export const expertResponse = 'How would an expert in this field respond?';
96
- export const limitationsOfApproach = 'What are the limitations of your approach?';
97
- export const missingInformation = 'What information is still missing?';
98
- export const evaluateDifferingViews = 'How would you evaluate differing views?';
99
- export const confidenceInResponse = 'How confident are you in your response?';
100
- export const lessKnowledgeResponse = 'How would you answer this if you knew less about the topic?';
101
- export const analogyForUnderstanding = 'Come up with an analogy to make this easier to understand.';
@@ -1,27 +0,0 @@
1
- const makeFeatureDefinition = ({ name, criteria, score0, score1 }) => {
2
- const descriptionPrompt = `criteria: "${criteria}", scoring: "${score0} ${score1}"`;
3
-
4
- return {
5
- [name]: {
6
- type: 'number',
7
- minimum: 0,
8
- maximum: 1,
9
- description: descriptionPrompt,
10
- },
11
- };
12
- };
13
-
14
- export default (features) => {
15
- if (!features?.length) {
16
- throw new Error('Features json schema [error]: Features list not defined');
17
- }
18
-
19
- return {
20
- $schema: 'http://json-schema.org/draft-07/schema#',
21
- type: 'object',
22
- properties: features.reduce((acc, feature) => {
23
- return { ...acc, ...makeFeatureDefinition(feature) };
24
- }, {}),
25
- required: features.map((f) => f.name),
26
- };
27
- };
@@ -1,26 +0,0 @@
1
- import {
2
- contentListItemCriteria,
3
- onlyJSON,
4
- onlyJSONObjectArray,
5
- tryCompleteData,
6
- } from './constants.js';
7
- import asObjectWithSchema from './as-object-with-schema.js';
8
-
9
- const schemaDefault = {
10
- type: 'object',
11
- properties: {
12
- name: {
13
- type: 'string',
14
- },
15
- },
16
- };
17
-
18
- export default (text, { schema = schemaDefault } = {}) => {
19
- return `Make an array of "${text}" objects.
20
-
21
- ${contentListItemCriteria}
22
- - ${asObjectWithSchema(schema)}
23
- - ${tryCompleteData}
24
-
25
- ${onlyJSON} ${onlyJSONObjectArray}`;
26
- };
@@ -1,48 +0,0 @@
1
- import {
2
- contentIsDetails,
3
- contentListCriteria,
4
- contentListItemCriteria,
5
- contentListToOmit,
6
- onlyJSONStringArray,
7
- } from './constants.js';
8
- import wrapVariable from './wrap-variable.js';
9
-
10
- const instruction = 'Please continue building the list.';
11
-
12
- const targetNewItemsCountDefault = 10;
13
-
14
- export default (
15
- description,
16
- {
17
- existing = [],
18
- attachments = {},
19
- fixes = '',
20
- targetNewItemsCount = targetNewItemsCountDefault,
21
- } = {}
22
- ) => {
23
- const existingJoined = JSON.stringify(existing, null, 2);
24
-
25
- const attachmentsJoined = Object.entries(attachments).map(([key, value]) => {
26
- return `${wrapVariable(value, { tag: 'reference-material', name: key })}
27
- `;
28
- });
29
-
30
- return `${onlyJSONStringArray}
31
- ${contentListCriteria} ${wrapVariable(description, { tag: 'criteria' })}
32
-
33
- ${attachmentsJoined}
34
-
35
- ${contentListToOmit} ${wrapVariable(existingJoined, { tag: 'omitted' })}
36
-
37
- ${instruction}
38
- You must return least ${targetNewItemsCount} unless the items are thoroughly exhausted.
39
-
40
- ${contentListItemCriteria}
41
- - Meet the description criteria
42
- - Not already in the list
43
- - Not a duplicate or a variant of an existing item
44
-
45
- ${contentIsDetails} ${wrapVariable(fixes, { tag: 'fixes' })}
46
-
47
- ${onlyJSONStringArray}`;
48
- };
@@ -1,19 +0,0 @@
1
- import {
2
- contentIsQuestion,
3
- contentListToOmit,
4
- expertResponse,
5
- onlyJSONStringArrayAlt1,
6
- } from './constants.js';
7
- import wrapVariable from './wrap-variable.js';
8
-
9
- export default (text, { existing = [] } = {}) => {
10
- const existingJoined = existing.map((item) => `"${item}"`).join(', ');
11
-
12
- return `Instead of answering the following question, I would like you to generate additional questions. Consider interesting perspectives. Consider what information is unknown. ${expertResponse}. Overall, just come up with good questions.
13
-
14
- ${contentIsQuestion} ${text}
15
-
16
- ${contentListToOmit} ${wrapVariable(existingJoined, { tag: 'omitted' })}
17
-
18
- ${onlyJSONStringArrayAlt1} One question per string.`;
19
- };
@@ -1,20 +0,0 @@
1
- export * as constants from './constants.js';
2
-
3
- export { default as asEnum } from './as-enum.js';
4
- export { default as asJSONSchema } from './as-json-schema.js';
5
- export { default as asObjectWithSchema } from './as-object-with-schema.js';
6
- export { default as asSchemaOrgText } from './as-schema-org-text.js';
7
- export { default as asSchemaOrgType } from './as-schema-org-type.js';
8
- export { default as blogPost } from './blog-post.js';
9
- export { default as generateCollection } from './generate-collection.js';
10
- export { default as generateList } from './generate-list.js';
11
- export { default as generateQuestions } from './generate-questions.js';
12
- export { default as intent } from './intent.js';
13
- export { default as selectFromThreshold } from './select-from-threshold.js';
14
- export { default as outputSuccinctNames } from './output-succinct-names.js';
15
- export { default as wrapVariable } from './wrap-variable.js';
16
- export { default as sort } from './sort.js';
17
- export { default as style } from './style.js';
18
- export { default as tokenBudget } from './token-budget.js';
19
- export { default as summarize } from './summarize.js';
20
- export { default as wrapList } from './wrap-list.js';
@@ -1,60 +0,0 @@
1
- import fs from 'fs/promises';
2
- import { fileURLToPath } from 'url';
3
- import { dirname, join } from 'path';
4
- import wrapVariable from './wrap-variable.js';
5
- import { onlyJSON } from './constants.js';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = dirname(__filename);
9
-
10
- const contentIsIntent = 'The intent is:';
11
- const contentIsSchema = 'The schema is:';
12
- const contentIsExample = 'An example of the output is:';
13
- const contentIsOperationOption = 'The possible operations are:';
14
- const contentIsParametersOptions = 'The possible parameters are:';
15
-
16
- const exampleJSON = `{
17
- "intent": "play_music",
18
- "parameters": {
19
- "genre": "rock"
20
- },
21
- "optionalParameters": {
22
- "artist": "The Beatles"
23
- }
24
- }`;
25
-
26
- const intentSchema = JSON.parse(await fs.readFile(join(__dirname, '../json-schemas/intent.json')));
27
-
28
- /**
29
- * Approximates intent recognition like you might find with Wit.ai,
30
- * for tasks where you want the model to extract the intent and parameters
31
- * so an existing function can compute the result.
32
- */
33
- export default (text, { operations = [], parameters = [] } = {}) => {
34
- let operationsSection = '';
35
- if (operations.length) {
36
- operationsSection = `\n${contentIsOperationOption} ${operations.join(', ')}\n`;
37
- }
38
- let parametersSection = '';
39
- if (parameters.length) {
40
- parametersSection = `\n${contentIsParametersOptions} ${parameters.join(', ')}\n`;
41
- }
42
-
43
- return `
44
- ${contentIsIntent} ${wrapVariable(text ?? 'None given', { tag: 'input' })}
45
-
46
- ${contentIsSchema} ${wrapVariable(intentSchema ?? 'None given', {
47
- tag: 'schema',
48
- })}
49
-
50
- ${contentIsExample} ${wrapVariable(exampleJSON ?? 'None given', {
51
- tag: 'example',
52
- })}
53
- ${operationsSection ?? ''}${parametersSection ?? ''}
54
- Ensure the result is sufficiently abstract.
55
- Include the full list of supplied parameters.
56
- Don't include optional parameters under "parameters" unless they were found when the intent was parsed.
57
-
58
- ${onlyJSON}
59
- `;
60
- };
@@ -1,3 +0,0 @@
1
- export default (numWords = 10) => {
2
- return `Provide a (<${numWords} words) descriptive name for each result.`;
3
- };
@@ -1,17 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- // Returns a modifier function that generates a prompt fragment based on a given value
4
- /*
5
- * let openEndedDegree = findDegreeModifier(openEnded, [
6
- * { threshold: 0.2, degree: 'must not be' },
7
- * { threshold: 0.4, degree: 'must be minimally' },
8
- * { threshold: 0.6, degree: 'must be somewhat' },
9
- * { threshold: 0.8, degree: 'must be very' },
10
- * { threshold: 1.0, degree: 'must be extremely' },
11
- * ]);
12
- * const openEndedPrompt = `Questions ${openEndedDegree} open-ended. `
13
- */
14
- export default (value, thresholds = []) => {
15
- const threshold = thresholds.find((t) => value <= t.threshold) || R.last(thresholds);
16
- return threshold.degree;
17
- };
@@ -1,31 +0,0 @@
1
- import wrapVariable from './wrap-variable.js';
2
- import {
3
- contentIsDetails,
4
- contentIsFixes,
5
- contentIsMain,
6
- contentIsSortCriteria,
7
- onlyJSONStringArray,
8
- } from './constants.js';
9
-
10
- export const defaultSortDescription = 'alphabetical order';
11
- export const defaultFixes = 'Ignore duplicates in the list';
12
- export const defaultSortOrder = 'descending';
13
-
14
- export default (
15
- { description = defaultSortDescription, fixes = defaultFixes, sortOrder = defaultSortOrder },
16
- list
17
- ) => {
18
- const listLines = JSON.stringify(list, undefined, 2);
19
-
20
- return `${contentIsSortCriteria} ${wrapVariable(description, {
21
- tag: 'criteria',
22
- })}
23
-
24
- ${contentIsMain} ${wrapVariable(listLines, { tag: 'main-content' })}
25
-
26
- ${contentIsDetails} ${sortOrder} order
27
-
28
- ${contentIsFixes} ${wrapVariable(fixes, { tag: 'fixes' })}
29
-
30
- ${onlyJSONStringArray}`;
31
- };
@@ -1,38 +0,0 @@
1
- export default (
2
- text,
3
- {
4
- tone = ['informal'],
5
- vocabulary = ['software engineering'],
6
- sentenceStructure = ['varied sentence length', 'active voice'],
7
- pointOfView = ['first person plural'],
8
- noise = 0,
9
- minWords = 0,
10
- maxWords,
11
- } = {}
12
- ) => {
13
- const toneModifiers = `Tone: ${tone.join(', ')}`;
14
- const vocabularyModifiers = `Vocabulary: ${vocabulary.join(', ')}`;
15
- const sentenceStructureModifiers = `Sentence structure: ${sentenceStructure.join(', ')}`;
16
- const pointOfViewModifiers = `Point of view: ${pointOfView.join(', ')}`;
17
- const lengthModifier = `Use between ${minWords} and ${maxWords ?? 'any number'} of words`;
18
-
19
- let noiseModifier = '';
20
- if (noise > 0.5) {
21
- noiseModifier =
22
- "Completely reshape the ideas here, don't stick with the original structure. Don't change the meaning of the content though.";
23
- }
24
-
25
- return `Rewrite the following content:
26
- \`\`\`
27
- ${text}
28
- \`\`\`
29
-
30
- Use the following style:
31
- ${toneModifiers}
32
- ${vocabularyModifiers}
33
- ${sentenceStructureModifiers}
34
- ${pointOfViewModifiers}
35
- ${lengthModifier}
36
- ${noiseModifier}
37
- `;
38
- };
@@ -1,13 +0,0 @@
1
- import wrapVariable from './wrap-variable.js';
2
- import { onlyFullCode } from './constants.js';
3
-
4
- export default (text, instructions = '') => {
5
- return `Summarize the following content. ${onlyFullCode}
6
-
7
- ${wrapVariable(instructions, {
8
- forceHTML: true,
9
- tag: 'summarization-instructions',
10
- })}
11
-
12
- ${wrapVariable(text, { forceHTML: true, tag: 'content-to-summarize' })}`;
13
- };
@@ -1,3 +0,0 @@
1
- export default (budget = 10) => {
2
- return `Keep the output within ${budget} tokens.`;
3
- };
@@ -1,11 +0,0 @@
1
- import wrapVariable from './wrap-variable.js';
2
-
3
- export default (list = [], { introText = 'Consider the following items:' } = {}) => {
4
- const listText = list.map((f, i) => ` - ${i + 1}. ${f}`).join('\n');
5
-
6
- let listFragment = wrapVariable('\n');
7
- if (list.length) {
8
- listFragment = `${introText} ${wrapVariable(listText)}`;
9
- }
10
- return listFragment;
11
- };
@@ -1,36 +0,0 @@
1
- export default (
2
- variable,
3
- { forceHTML = false, name, tag = 'data', title, fit = 'comfortable' } = {}
4
- ) => {
5
- if (!variable) {
6
- return '';
7
- }
8
-
9
- let nameAttribute = '';
10
- if (name) {
11
- nameAttribute = `name="${name}"`;
12
- }
13
-
14
- let variableResolved = typeof variable !== 'undefined' ? variable : '';
15
- if (typeof variable !== 'string') {
16
- variableResolved = JSON.stringify(variable, null, 2);
17
- }
18
-
19
- const isHTML = /\n/.test(variableResolved) || forceHTML || name;
20
- let variableWrapped = !isHTML ? `"${variableResolved}"` : variableResolved;
21
- if (isHTML) {
22
- let fitChar = '\n';
23
- if (fit !== 'comfortable') {
24
- fitChar = '';
25
- }
26
-
27
- variableWrapped = `<${tag}${nameAttribute}>${fitChar}${variableResolved}${fitChar}</${tag}>`;
28
- }
29
-
30
- let titlePrefixed = variableWrapped;
31
- if (title && variableResolved.length > 0) {
32
- titlePrefixed = `${title} ${variableWrapped}`;
33
- }
34
-
35
- return titlePrefixed;
36
- };