@far-world-labs/verblets 0.1.1 → 0.1.3

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 (300) hide show
  1. package/.cursor/launch.json +30 -0
  2. package/.cursor/settings.json +20 -0
  3. package/.github/workflows/branch-protection.yml +22 -0
  4. package/.github/workflows/ci.yml +120 -0
  5. package/.prettierrc +6 -0
  6. package/.release-it.json +4 -1
  7. package/.vscode/launch.json +31 -0
  8. package/AGENTS.md +220 -0
  9. package/DEVELOPING.md +105 -0
  10. package/README.md +254 -0
  11. package/eslint.config.js +80 -0
  12. package/package.json +29 -17
  13. package/scripts/generate-test/index.js +29 -3
  14. package/scripts/runner/index.js +26 -0
  15. package/scripts/simple-editor/index.js +29 -18
  16. package/scripts/summarize-files/index.js +28 -4
  17. package/src/chains/README.md +30 -0
  18. package/src/chains/anonymize/README.md +21 -0
  19. package/src/chains/anonymize/index.examples.js +75 -0
  20. package/src/chains/anonymize/index.js +121 -0
  21. package/src/chains/anonymize/index.spec.js +78 -0
  22. package/src/chains/bulk-central-tendency/index.examples.js +138 -0
  23. package/src/chains/bulk-central-tendency/index.js +91 -0
  24. package/src/chains/bulk-filter/README.md +21 -0
  25. package/src/chains/bulk-filter/index.examples.js +22 -0
  26. package/src/chains/bulk-filter/index.js +58 -0
  27. package/src/chains/bulk-filter/index.spec.js +38 -0
  28. package/src/chains/bulk-find/README.md +16 -0
  29. package/src/chains/bulk-find/index.examples.js +20 -0
  30. package/src/chains/bulk-find/index.js +30 -0
  31. package/src/chains/bulk-find/index.spec.js +26 -0
  32. package/src/chains/bulk-group/README.md +23 -0
  33. package/src/chains/bulk-group/index.examples.js +18 -0
  34. package/src/chains/bulk-group/index.js +34 -0
  35. package/src/chains/bulk-group/index.spec.js +41 -0
  36. package/src/chains/bulk-map/README.md +43 -0
  37. package/src/chains/bulk-map/index.examples.js +17 -0
  38. package/src/chains/bulk-map/index.js +86 -0
  39. package/src/chains/bulk-map/index.spec.js +44 -0
  40. package/src/chains/bulk-reduce/README.md +12 -0
  41. package/src/chains/bulk-reduce/index.examples.js +15 -0
  42. package/src/chains/bulk-reduce/index.js +13 -0
  43. package/src/chains/bulk-reduce/index.spec.js +25 -0
  44. package/src/chains/bulk-score/README.md +16 -0
  45. package/src/chains/bulk-score/bulk-score-result.json +18 -0
  46. package/src/chains/bulk-score/index.examples.js +22 -0
  47. package/src/chains/bulk-score/index.js +133 -0
  48. package/src/chains/bulk-score/index.spec.js +30 -0
  49. package/src/chains/category-samples/README.md +61 -0
  50. package/src/chains/category-samples/index.examples.js +103 -0
  51. package/src/chains/category-samples/index.js +134 -0
  52. package/src/chains/collect-terms/README.md +12 -0
  53. package/src/chains/collect-terms/index.examples.js +16 -0
  54. package/src/chains/collect-terms/index.js +44 -0
  55. package/src/chains/collect-terms/index.spec.js +25 -0
  56. package/src/chains/date/README.md +12 -0
  57. package/src/chains/date/index.examples.js +47 -0
  58. package/src/chains/date/index.js +74 -0
  59. package/src/chains/date/index.spec.js +62 -0
  60. package/src/chains/disambiguate/README.md +22 -0
  61. package/src/chains/disambiguate/disambiguate-meanings-result.json +16 -0
  62. package/src/chains/disambiguate/index.examples.js +18 -0
  63. package/src/chains/disambiguate/index.js +92 -0
  64. package/src/chains/disambiguate/index.spec.js +25 -0
  65. package/src/chains/dismantle/README.md +67 -0
  66. package/src/chains/dismantle/dismantle.examples.js +27 -0
  67. package/src/chains/dismantle/index.js +6 -17
  68. package/src/chains/dismantle/index.spec.js +1 -2
  69. package/src/chains/expect/README.md +171 -0
  70. package/src/chains/expect/index.examples.js +146 -0
  71. package/src/chains/expect/index.js +173 -0
  72. package/src/chains/expect/index.spec.js +324 -0
  73. package/src/chains/filter-ambiguous/README.md +11 -0
  74. package/src/chains/filter-ambiguous/index.examples.js +20 -0
  75. package/src/chains/filter-ambiguous/index.js +49 -0
  76. package/src/chains/filter-ambiguous/index.spec.js +31 -0
  77. package/src/chains/glossary/README.md +19 -0
  78. package/src/chains/glossary/index.examples.js +386 -0
  79. package/src/chains/glossary/index.js +75 -0
  80. package/src/chains/glossary/index.spec.js +19 -0
  81. package/src/chains/intersections/README.md +152 -0
  82. package/src/chains/intersections/index.examples.js +279 -0
  83. package/src/chains/intersections/index.js +366 -0
  84. package/src/chains/intersections/intersection-result.json +38 -0
  85. package/src/chains/list/index.examples.js +12 -16
  86. package/src/chains/list/index.js +106 -53
  87. package/src/chains/list/index.spec.js +8 -9
  88. package/src/chains/list/list-result.json +16 -0
  89. package/src/chains/llm-logger/README.md +208 -0
  90. package/src/chains/llm-logger/index.js +205 -0
  91. package/src/chains/llm-logger/index.spec.js +330 -0
  92. package/src/chains/questions/index.examples.js +2 -1
  93. package/src/chains/questions/index.js +14 -15
  94. package/src/chains/scan-js/index.js +6 -9
  95. package/src/chains/set-interval/README.md +81 -0
  96. package/src/chains/set-interval/index.examples.js +36 -0
  97. package/src/chains/set-interval/index.js +131 -0
  98. package/src/chains/set-interval/index.spec.js +70 -0
  99. package/src/chains/socratic/README.md +17 -0
  100. package/src/chains/socratic/index.js +64 -0
  101. package/src/chains/socratic/index.spec.js +24 -0
  102. package/src/chains/sort/index.examples.js +3 -7
  103. package/src/chains/sort/index.js +65 -15
  104. package/src/chains/sort/index.spec.js +5 -8
  105. package/src/chains/sort/sort-result.json +16 -0
  106. package/src/chains/summary-map/README.md +9 -1
  107. package/src/chains/summary-map/index.examples.js +9 -2
  108. package/src/chains/summary-map/index.js +43 -25
  109. package/src/chains/summary-map/index.spec.js +78 -3
  110. package/src/chains/test/index.js +9 -13
  111. package/src/chains/test-advice/index.js +4 -5
  112. package/src/chains/themes/README.md +20 -0
  113. package/src/chains/themes/index.examples.js +17 -0
  114. package/src/chains/themes/index.js +28 -0
  115. package/src/chains/themes/index.spec.js +19 -0
  116. package/src/chains/veiled-variants/index.examples.js +18 -0
  117. package/src/chains/veiled-variants/index.js +107 -0
  118. package/src/chains/veiled-variants/index.spec.js +40 -0
  119. package/src/constants/common.js +0 -2
  120. package/src/constants/models.js +172 -0
  121. package/src/index.js +178 -18
  122. package/src/json-schemas/README.md +13 -0
  123. package/src/json-schemas/index.js +8 -14
  124. package/src/json-schemas/schema-dot-org-photograph.json +11 -5
  125. package/src/json-schemas/schema-dot-org-place.json +78 -5
  126. package/src/lib/README.md +26 -0
  127. package/src/lib/bulk-filter/README.md +22 -0
  128. package/src/lib/bulk-filter/index.examples.js +27 -0
  129. package/src/lib/bulk-filter/index.js +63 -0
  130. package/src/lib/bulk-filter/index.spec.js +38 -0
  131. package/src/lib/bulk-find/README.md +18 -0
  132. package/src/lib/bulk-find/index.examples.js +19 -0
  133. package/src/lib/bulk-find/index.js +30 -0
  134. package/src/lib/bulk-find/index.spec.js +41 -0
  135. package/src/lib/chatgpt/index.js +63 -43
  136. package/src/lib/combinations/index.js +30 -0
  137. package/src/lib/combinations/index.spec.js +23 -0
  138. package/src/lib/functional/index.js +28 -0
  139. package/src/lib/logger-service/index.js +32 -0
  140. package/src/lib/parse-js-parts/index.js +9 -21
  141. package/src/lib/parse-llm-list/README.md +39 -0
  142. package/src/lib/parse-llm-list/index.js +54 -0
  143. package/src/lib/parse-llm-list/index.spec.js +59 -0
  144. package/src/lib/path-aliases/index.js +1 -3
  145. package/src/lib/path-aliases/index.spec.js +2 -8
  146. package/src/lib/pave/index.js +4 -4
  147. package/src/lib/pave/index.spec.js +6 -3
  148. package/src/lib/prompt-cache/index.js +14 -10
  149. package/src/lib/retry/index.js +11 -8
  150. package/src/lib/ring-buffer/README.md +460 -0
  151. package/src/lib/ring-buffer/index.js +1074 -0
  152. package/src/lib/search-best-first/city-walk.spec.js +37 -0
  153. package/src/lib/search-best-first/index.js +42 -11
  154. package/src/lib/search-best-first/index.spec.js +35 -0
  155. package/src/lib/search-js-files/index.js +44 -47
  156. package/src/lib/search-js-files/scan-file.js +10 -21
  157. package/src/lib/shorten-text/index.js +2 -7
  158. package/src/lib/shorten-text/index.spec.js +3 -3
  159. package/src/lib/strip-response/index.js +2 -7
  160. package/src/lib/template-replace/index.js +23 -0
  161. package/src/lib/template-replace/index.spec.js +60 -0
  162. package/src/lib/to-date/index.js +11 -0
  163. package/src/lib/to-number/index.js +1 -1
  164. package/src/lib/transcribe/index.js +26 -9
  165. package/src/prompts/README.md +3 -1
  166. package/src/prompts/as-object-with-schema.js +3 -8
  167. package/src/prompts/as-schema-org-text.js +10 -2
  168. package/src/prompts/code-features.js +1 -5
  169. package/src/prompts/constants.js +27 -27
  170. package/src/prompts/generate-collection.js +1 -1
  171. package/src/prompts/intent.js +16 -22
  172. package/src/prompts/select-from-threshold.js +1 -2
  173. package/src/prompts/sort.js +4 -8
  174. package/src/prompts/style.js +4 -7
  175. package/src/prompts/wrap-list.js +1 -4
  176. package/src/services/llm-model/global-overrides.spec.js +432 -0
  177. package/src/services/llm-model/index.js +234 -40
  178. package/src/services/llm-model/model.js +2 -2
  179. package/src/services/llm-model/negotiate.spec.js +447 -0
  180. package/src/services/redis/index.js +70 -7
  181. package/src/test/setup.js +20 -0
  182. package/src/verblets/README.md +26 -0
  183. package/src/verblets/auto/index.examples.js +12 -9
  184. package/src/verblets/auto/index.js +10 -10
  185. package/src/verblets/auto/index.spec.js +4 -6
  186. package/src/verblets/bool/README.md +36 -0
  187. package/src/verblets/bool/index.examples.js +53 -1
  188. package/src/verblets/bool/index.js +6 -9
  189. package/src/verblets/bool/index.spec.js +1 -3
  190. package/src/verblets/central-tendency/README.md +166 -0
  191. package/src/verblets/central-tendency/central-tendency-result.json +24 -0
  192. package/src/verblets/central-tendency/index.examples.js +196 -0
  193. package/src/verblets/central-tendency/index.js +171 -0
  194. package/src/verblets/central-tendency/index.spec.js +148 -0
  195. package/src/verblets/enum/index.examples.js +1 -4
  196. package/src/verblets/enum/index.js +7 -4
  197. package/src/verblets/expect/README.md +64 -0
  198. package/src/verblets/expect/index.examples.js +109 -0
  199. package/src/verblets/expect/index.js +75 -0
  200. package/src/verblets/expect/index.spec.js +127 -0
  201. package/src/verblets/intent/index.examples.js +95 -7
  202. package/src/verblets/intent/index.js +56 -68
  203. package/src/verblets/intersection/README.md +16 -0
  204. package/src/verblets/intersection/index.examples.js +89 -0
  205. package/src/verblets/intersection/index.js +84 -0
  206. package/src/verblets/intersection/index.spec.js +60 -0
  207. package/src/verblets/intersection/intersection-result.json +16 -0
  208. package/src/verblets/list-expand/README.md +10 -0
  209. package/src/verblets/list-expand/index.examples.js +14 -0
  210. package/src/verblets/list-expand/index.js +104 -0
  211. package/src/verblets/list-expand/index.spec.js +18 -0
  212. package/src/verblets/list-expand/list-expand-result.json +16 -0
  213. package/src/verblets/list-filter/README.md +22 -0
  214. package/src/verblets/list-filter/index.examples.js +26 -0
  215. package/src/verblets/list-filter/index.js +18 -0
  216. package/src/verblets/list-filter/index.spec.js +19 -0
  217. package/src/verblets/list-find/README.md +11 -0
  218. package/src/verblets/list-find/index.examples.js +15 -0
  219. package/src/verblets/list-find/index.js +17 -0
  220. package/src/verblets/list-find/index.spec.js +19 -0
  221. package/src/verblets/list-group/README.md +16 -0
  222. package/src/verblets/list-group/index.examples.js +16 -0
  223. package/src/verblets/list-group/index.js +112 -0
  224. package/src/verblets/list-group/index.spec.js +35 -0
  225. package/src/verblets/list-group/list-group-result.json +16 -0
  226. package/src/verblets/list-map/README.md +11 -0
  227. package/src/verblets/list-map/index.examples.js +15 -0
  228. package/src/verblets/list-map/index.js +26 -0
  229. package/src/verblets/list-map/index.spec.js +17 -0
  230. package/src/verblets/list-reduce/README.md +10 -0
  231. package/src/verblets/list-reduce/index.examples.js +14 -0
  232. package/src/verblets/list-reduce/index.js +21 -0
  233. package/src/verblets/list-reduce/index.spec.js +27 -0
  234. package/src/verblets/list-reduce/index.spec.jsx +27 -0
  235. package/src/verblets/name/README.md +15 -0
  236. package/src/verblets/name/index.examples.js +28 -0
  237. package/src/verblets/name/index.js +19 -0
  238. package/src/verblets/name/index.spec.js +33 -0
  239. package/src/verblets/name-similar-to/README.md +26 -0
  240. package/src/verblets/name-similar-to/index.examples.js +18 -0
  241. package/src/verblets/name-similar-to/index.js +20 -0
  242. package/src/verblets/name-similar-to/index.spec.js +13 -0
  243. package/src/verblets/number/index.examples.js +173 -7
  244. package/src/verblets/number/index.js +5 -2
  245. package/src/verblets/number/index.spec.js +1 -3
  246. package/src/verblets/number-with-units/index.examples.js +5 -1
  247. package/src/verblets/number-with-units/index.js +74 -9
  248. package/src/verblets/number-with-units/number-with-units-result.json +23 -0
  249. package/src/verblets/schema-org/index.examples.js +2 -7
  250. package/src/verblets/schema-org/index.js +32 -3
  251. package/src/verblets/sentiment/README.md +10 -0
  252. package/src/verblets/sentiment/index.examples.js +20 -0
  253. package/src/verblets/sentiment/index.js +9 -0
  254. package/src/verblets/sentiment/index.spec.js +20 -0
  255. package/src/verblets/to-object/index.js +10 -15
  256. package/src/verblets/to-object/index.spec.js +1 -4
  257. package/.eslintrc.json +0 -42
  258. package/docs/README.md +0 -41
  259. package/docs/babel.config.js +0 -3
  260. package/docs/blog/2019-05-28-first-blog-post.md +0 -12
  261. package/docs/blog/2019-05-29-long-blog-post.md +0 -44
  262. package/docs/blog/2021-08-01-mdx-blog-post.mdx +0 -20
  263. package/docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
  264. package/docs/blog/2021-08-26-welcome/index.md +0 -25
  265. package/docs/blog/authors.yml +0 -17
  266. package/docs/docs/api/bool.md +0 -74
  267. package/docs/docs/api/search.md +0 -51
  268. package/docs/docs/intro.md +0 -47
  269. package/docs/docs/tutorial-basics/_category_.json +0 -8
  270. package/docs/docs/tutorial-basics/congratulations.md +0 -23
  271. package/docs/docs/tutorial-basics/create-a-blog-post.md +0 -34
  272. package/docs/docs/tutorial-basics/create-a-document.md +0 -57
  273. package/docs/docs/tutorial-basics/create-a-page.md +0 -43
  274. package/docs/docs/tutorial-basics/deploy-your-site.md +0 -31
  275. package/docs/docs/tutorial-basics/markdown-features.mdx +0 -152
  276. package/docs/docs/tutorial-extras/_category_.json +0 -7
  277. package/docs/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
  278. package/docs/docs/tutorial-extras/img/localeDropdown.png +0 -0
  279. package/docs/docs/tutorial-extras/manage-docs-versions.md +0 -55
  280. package/docs/docs/tutorial-extras/translate-your-site.md +0 -88
  281. package/docs/docusaurus.config.js +0 -120
  282. package/docs/package.json +0 -44
  283. package/docs/sidebars.js +0 -31
  284. package/docs/src/components/HomepageFeatures/index.js +0 -61
  285. package/docs/src/components/HomepageFeatures/styles.module.css +0 -11
  286. package/docs/src/css/custom.css +0 -30
  287. package/docs/src/pages/index.js +0 -43
  288. package/docs/src/pages/index.module.css +0 -23
  289. package/docs/src/pages/markdown-page.md +0 -7
  290. package/docs/static/.nojekyll +0 -0
  291. package/docs/static/img/docusaurus-social-card.jpg +0 -0
  292. package/docs/static/img/docusaurus.png +0 -0
  293. package/docs/static/img/favicon.ico +0 -0
  294. package/docs/static/img/logo.svg +0 -1
  295. package/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
  296. package/docs/static/img/undraw_docusaurus_react.svg +0 -170
  297. package/docs/static/img/undraw_docusaurus_tree.svg +0 -40
  298. package/src/constants/openai.js +0 -65
  299. /package/{.vite.config.examples.js → .vitest.config.examples.js} +0 -0
  300. /package/{.vite.config.js → .vitest.config.js} +0 -0
@@ -0,0 +1,172 @@
1
+ // Importing dotenv config to load environment variables from .env file
2
+ // eslint-disable-next-line no-unused-vars
3
+ import dotenv from 'dotenv/config';
4
+
5
+ const _models = {};
6
+
7
+ const systemPrompt = `You are a superintelligent processing unit, answering prompts with precise instructions.
8
+ You are a small but critical component in a complex system, so your role in giving quality outputs to your given inputs and instructions is critical.
9
+ You must obey those instructions to the letter at all costs--do not deviate or add your own interpretation or flair. Stick to the instructions.
10
+ Aim to be direct, accurate, correct, and concise.
11
+ You'll often be given complex inputs alongside your instructions. Consider the inputs carefully and think through your answer in relation to the inputs and instructions.
12
+ Most prompts will ask for a specific output format, so comply with those details exactly as well.`;
13
+
14
+ // // $0.10-0.40/1M tokens
15
+ // // cutoff: 5/2024
16
+ // // supports image inputs, very high speed, 1M token context, 32K output
17
+ // // low intelligence, but > 3.5 turbo
18
+ // _models.fastCheapMulti = {
19
+ // endpoint: 'v1/chat/completions',
20
+ // name: 'gpt-4.1-nano-2025-04-14',
21
+ // maxContextWindow: 1_047_576,
22
+ // maxOutputTokens: 32_768,
23
+ // requestTimeout: 20_000,
24
+ // apiKey: process.env.OPENAI_API_KEY,
25
+ // apiUrl: 'https://api.openai.com/',
26
+ // systemPrompt,
27
+ // };
28
+
29
+ // // $.40-$1.60/1M tokens
30
+ // // cutoff: 05/2024
31
+ // // supports image inputs, high speed, 1M token context, 32K output
32
+ // _models.fastGoodMulti = {
33
+ // endpoint: 'v1/chat/completions',
34
+ // name: 'gpt-4.1-mini-2025-04-14',
35
+ // maxContextWindow: 1_047_576,
36
+ // maxOutputTokens: 32_768,
37
+ // requestTimeout: 20_000,
38
+ // apiKey: process.env.OPENAI_API_KEY,
39
+ // apiUrl: 'https://api.openai.com/',
40
+ // systemPrompt,
41
+ // };
42
+ _models.fastCheapMulti = {
43
+ endpoint: 'v1/chat/completions',
44
+ name: 'gpt-4o',
45
+ maxContextWindow: 128_000,
46
+ maxOutputTokens: 16_384,
47
+ requestTimeout: 20_000,
48
+ apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
49
+ apiUrl: 'https://api.openai.com/',
50
+ systemPrompt,
51
+ };
52
+
53
+ // $2.5-$10.00/1M tokens
54
+ // cutoff: 09/2023
55
+ // supports image inputs, moderate speed
56
+ _models.goodMulti = {
57
+ endpoint: 'v1/chat/completions',
58
+ name: 'gpt-4o-2024-11-20',
59
+ maxContextWindow: 128_000,
60
+ maxOutputTokens: 16_384,
61
+ requestTimeout: 20_000,
62
+ apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
63
+ apiUrl: 'https://api.openai.com/',
64
+ systemPrompt,
65
+ };
66
+
67
+ // Caution!: $1.1-4.4/1M tokens
68
+ // cutoff: 05/2024
69
+ // supports image inputs, moderate speed
70
+ _models.fastCheapReasoningMulti = {
71
+ endpoint: 'v1/chat/completions',
72
+ name: 'o4-mini-2025-04-16',
73
+ maxContextWindow: 128_000,
74
+ maxOutputTokens: 16_384,
75
+ requestTimeout: 40_000,
76
+ apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
77
+ apiUrl: 'https://api.openai.com/',
78
+ systemPrompt,
79
+ };
80
+
81
+ // Caution!: $10-40/1M tokens
82
+ // cutoff: 05/2024
83
+ // supports image inputs
84
+ _models.reasoningNoImage = {
85
+ endpoint: 'v1/chat/completions',
86
+ name: 'o3-2025-04-16',
87
+ maxContextWindow: 200_000,
88
+ maxOutputTokens: 100_000,
89
+ requestTimeout: 120_000,
90
+ apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
91
+ apiUrl: 'https://api.openai.com/',
92
+ systemPrompt,
93
+ };
94
+
95
+ // Full matrix with explicit names (no aliases)
96
+ _models.fastGoodMulti = _models.fastCheapMulti;
97
+ _models.fastGoodCheapMulti = _models.fastGoodMulti; // Default system model
98
+ _models.fastGoodCheap = _models.fastGoodMulti;
99
+ _models.fastMulti = _models.fastGoodMulti;
100
+ _models.fast = _models.fastGoodMulti;
101
+ _models.fastGood = _models.fastGoodMulti;
102
+ _models.fastReasoningMulti = _models.fastCheapReasoningMulti;
103
+ _models.fastReasoning = _models.fastCheapReasoningMulti;
104
+
105
+ // eslint-disable-next-line no-self-assign
106
+ _models.fastCheapMulti = _models.fastCheapMulti;
107
+ _models.fastCheap = _models.fastCheapMulti;
108
+ _models.fastCheapReasoning = _models.fastCheapReasoningMulti;
109
+
110
+ _models.cheapMulti = _models.fastCheapMulti;
111
+ _models.cheap = _models.fastCheapMulti;
112
+ _models.cheapGoodMulti = _models.fastGoodMulti;
113
+ _models.cheapGood = _models.fastGoodMulti;
114
+ _models.cheapReasoningMulti = _models.fastCheapReasoningMulti;
115
+ _models.cheapReasoning = _models.fastCheapReasoningMulti;
116
+
117
+ // eslint-disable-next-line no-self-assign
118
+ _models.goodMulti = _models.goodMulti; // Caution: Moderate cost
119
+ _models.good = _models.goodMulti; // Caution: Moderate cost
120
+
121
+ _models.reasoningMulti = _models.fastCheapReasoningMulti; // Caution: Moderate cost
122
+ _models.reasoning = _models.reasoningNoImage; // Caution: High cost
123
+
124
+ // cutoff: 03/2024
125
+ // Supports image inputs
126
+ _models.privacy = {
127
+ name: 'gemma3:latest', // same as gemma3:4b
128
+ endpoint: 'api/chat/completions',
129
+ maxContextWindow: 128_000,
130
+ maxOutputTokens: 8_192,
131
+ requestTimeout: 120_000,
132
+ apiUrl: (process.env.OPENWEBUI_API_URL ?? '').endsWith('/')
133
+ ? process.env.OPENWEBUI_API_URL
134
+ : `${process.env.OPENWEBUI_API_URL}/`,
135
+ apiKey: process.env.OPENWEBUI_API_KEY ?? 'undefined',
136
+ systemPrompt,
137
+ modelOptions: {
138
+ stop: ['</s>'],
139
+ },
140
+ };
141
+
142
+ // Allow tests to run without requiring an API key
143
+ if (process.env.NODE_ENV !== 'test') {
144
+ // expect(process.env.OPENAI_API_KEY).to.exist;
145
+ }
146
+
147
+ const secondsInDay = 60 * 60 * 24;
148
+ export const cacheTTL = process.env.CHATGPT_CACHE_TTL ?? secondsInDay;
149
+
150
+ // Caching can be disabled by setting DISABLE_CACHE=true
151
+ // By default, caching is enabled when Redis is available and working
152
+ export const cachingEnabled = process.env.DISABLE_CACHE !== 'true';
153
+
154
+ export const debugPromptGlobally = process.env.CHATGPT_DEBUG_PROMPT ?? false;
155
+
156
+ export const debugPromptGloballyIfChanged = process.env.CHATGPT_DEBUG_REQUEST_IF_CHANGED ?? false;
157
+
158
+ export const debugResultGlobally = process.env.CHATGPT_DEBUG_RESPONSE ?? false;
159
+
160
+ export const debugResultGloballyIfChanged = process.env.CHATGPT_DEBUG_RESPONSE_IF_CHANGED ?? false;
161
+
162
+ export const frequencyPenalty = process.env.CHATGPT_FREQUENCY_PENALTY ?? 0;
163
+
164
+ export const models = _models;
165
+
166
+ export const operationTimeoutMultiplier = 2;
167
+
168
+ export const presencePenalty = process.env.CHATGPT_PRESENCE_PENALTY ?? 0;
169
+
170
+ export const temperature = process.env.CHATGPT_TEMPERATURE ?? 0;
171
+
172
+ export const topP = process.env.CHATGPT_TOPP ?? 0.5;
package/src/index.js CHANGED
@@ -1,33 +1,193 @@
1
- // Importing dotenv config to load environment variables from .env file
1
+ // Importing dotenv config to load environment variables from .env file
2
2
  // eslint-disable-next-line no-unused-vars
3
3
  import dotenv from 'dotenv/config';
4
4
 
5
- export { default as Dismantle } from './chains/dismantle/index.js';
6
- export { default as list } from './chains/list/index.js';
5
+ import chatGPT from './lib/chatgpt/index.js';
7
6
 
8
- export { default as questions } from './chains/questions/index.js';
9
- export { default as scanJS } from './chains/scan-js/index.js';
10
- export { default as sort } from './chains/sort/index.js';
11
- export { default as SummaryMap } from './chains/summary-map/index.js';
7
+ // chains are consumed as verblets
12
8
 
13
- export { default as schemas } from './json-schemas/index.js';
9
+ import anonymize from './chains/anonymize/index.js';
10
+
11
+ import Dismantle from './chains/dismantle/index.js';
12
+
13
+ import intersections from './chains/intersections/index.js';
14
+
15
+ import list from './chains/list/index.js';
16
+ import glossary from './chains/glossary/index.js';
17
+
18
+ import questions from './chains/questions/index.js';
19
+
20
+ import SocraticMethod from './chains/socratic/index.js';
21
+
22
+ import scanJS from './chains/scan-js/index.js';
23
+
24
+ import sort from './chains/sort/index.js';
25
+ import date from './chains/date/index.js';
26
+ import setInterval from './chains/set-interval/index.js';
27
+ import bulkScore from './chains/bulk-score/index.js';
28
+ import filterAmbiguous from './chains/filter-ambiguous/index.js';
29
+
30
+ import SummaryMap from './chains/summary-map/index.js';
31
+ import themes from './chains/themes/index.js';
32
+
33
+ import test from './chains/test/index.js';
34
+
35
+ import testAdvice from './chains/test-advice/index.js';
36
+
37
+ import schemas from './json-schemas/index.js';
38
+ import * as common from './constants/common.js';
39
+ import * as messages from './constants/messages.js';
40
+ import * as models from './constants/models.js';
41
+
42
+ // exported lib utilities
43
+ // internal-only: anySignal, editor, parseJsParts, pathAliases, pave, TimedAbortController
44
+ import * as promptCache from './lib/prompt-cache/index.js';
45
+ import retry from './lib/retry/index.js';
46
+ import searchBestFirst from './lib/search-best-first/index.js';
47
+ import searchJSFiles from './lib/search-js-files/index.js';
48
+ import shortenText from './lib/shorten-text/index.js';
49
+ import bulkMap, { bulkMapRetry } from './chains/bulk-map/index.js';
50
+ import bulkFind, { bulkFindRetry } from './chains/bulk-find/index.js';
51
+ import bulkFilter, { bulkFilterRetry } from './chains/bulk-filter/index.js';
52
+ import stripNumeric from './lib/strip-numeric/index.js';
53
+ import stripResponse from './lib/strip-response/index.js';
54
+ import toBool from './lib/to-bool/index.js';
55
+ import toEnum from './lib/to-enum/index.js';
56
+ import toNumber from './lib/to-number/index.js';
57
+ import toNumberWithUnits from './lib/to-number-with-units/index.js';
58
+ import toDate from './lib/to-date/index.js';
59
+ import transcribe from './lib/transcribe/index.js';
60
+ import combinations, { rangeCombinations } from './lib/combinations/index.js';
61
+
62
+ // prompts
63
+ import * as prompts from './prompts/index.js';
64
+
65
+ // services
66
+ import * as redis from './services/redis/index.js';
67
+ import modelService from './services/llm-model/index.js';
68
+
69
+ // verblets
70
+
71
+ import auto from './verblets/auto/index.js';
72
+
73
+ import bool from './verblets/bool/index.js';
74
+
75
+ import enums from './verblets/enum/index.js';
76
+
77
+ import intent from './verblets/intent/index.js';
78
+
79
+ import number from './verblets/number/index.js';
80
+
81
+ import numberWithUnits from './verblets/number-with-units/index.js';
82
+
83
+ import schemaOrg from './verblets/schema-org/index.js';
84
+ import nameSimilarTo from './verblets/name-similar-to/index.js';
85
+
86
+ import name from './verblets/name/index.js';
87
+
88
+ import toObject from './verblets/to-object/index.js';
89
+
90
+ import listMap from './verblets/list-map/index.js';
91
+ import listFind from './verblets/list-find/index.js';
92
+
93
+ import bulkGroup from './chains/bulk-group/index.js';
94
+
95
+ import listGroup from './verblets/list-group/index.js';
96
+ import intersection from './verblets/intersection/index.js';
97
+
98
+ // # Concept Science
99
+ import centralTendency from './verblets/central-tendency/index.js';
100
+ import bulkCentralTendency, {
101
+ bulkCentralTendencyRetry,
102
+ } from './chains/bulk-central-tendency/index.js';
14
103
 
15
- import chatGPT from './lib/chatgpt/index.js';
16
104
  export { default as retry } from './lib/retry/index.js';
17
105
  export { default as stripResponse } from './lib/strip-response/index.js';
18
106
  export { default as searchJSFiles } from './lib/search-js-files/index.js';
107
+ export { default as searchBestFirst } from './lib/search-best-first/index.js';
108
+ export {
109
+ bulkMap,
110
+ bulkMapRetry,
111
+ bulkFind,
112
+ bulkFindRetry,
113
+ bulkFilter,
114
+ bulkFilterRetry,
115
+ bulkCentralTendency,
116
+ bulkCentralTendencyRetry,
117
+ };
118
+ export { rangeCombinations } from './lib/combinations/index.js';
119
+
120
+ export const lib = {
121
+ chatGPT,
122
+ promptCache,
123
+ retry,
124
+ searchBestFirst,
125
+ searchJSFiles,
126
+ shortenText,
127
+ stripNumeric,
128
+ stripResponse,
129
+ toBool,
130
+ toEnum,
131
+ toNumber,
132
+ toNumberWithUnits,
133
+ toDate,
134
+ transcribe,
135
+ combinations,
136
+ rangeCombinations,
137
+ };
19
138
 
20
- export * as prompts from './prompts/index.js';
139
+ export const verblets = {
140
+ auto,
141
+ bool,
142
+ enums,
143
+ intent,
144
+ number,
145
+ numberWithUnits,
146
+ schemaOrg,
147
+ nameSimilarTo,
148
+ name,
149
+ toObject,
150
+ listMap,
151
+ listFind,
152
+ bulkMap,
153
+ bulkFind,
154
+ anonymize,
155
+ Dismantle,
156
+ intersections,
157
+ list,
158
+ glossary,
159
+ questions,
160
+ SocraticMethod,
161
+ scanJS,
162
+ sort,
163
+ date,
164
+ SummaryMap,
165
+ themes,
166
+ setInterval,
167
+ test,
168
+ testAdvice,
169
+ bulkScore,
170
+ filterAmbiguous,
171
+ bulkGroup,
172
+ bulkFilter,
173
+ listGroup,
174
+ intersection,
175
+ // # Concept Science
176
+ centralTendency,
177
+ bulkCentralTendency,
178
+ };
21
179
 
22
- export { getClient as getRedis } from './services/redis/index.js';
180
+ export const services = {
181
+ redis,
182
+ modelService,
183
+ };
23
184
 
24
- export { default as auto } from './verblets/auto/index.js';
25
- export { default as bool } from './verblets/bool/index.js';
26
- export { default as enums } from './verblets/enum/index.js';
27
- export { default as intent } from './verblets/intent/index.js';
28
- export { default as number } from './verblets/number/index.js';
29
- export { default as schemaOrg } from './verblets/schema-org/index.js';
30
- export { default as toObject } from './verblets/to-object/index.js';
185
+ export const constants = {
186
+ common,
187
+ messages,
188
+ models,
189
+ };
31
190
 
191
+ export { prompts, schemas };
32
192
 
33
193
  export default chatGPT;
@@ -0,0 +1,13 @@
1
+ # JSON Schemas
2
+
3
+ This folder contains example schemas used throughout the project. Schemas are referenced by certain verblets and chains for validating or shaping structured output.
4
+
5
+ Included files:
6
+
7
+ - `cars-test.json`
8
+ - `intent.json`
9
+ - `schema-dot-org-photograph.json`
10
+ - `schema-dot-org-place.json`
11
+ - `index.js` – helper that loads a subset of schemas for quick access.
12
+
13
+ Additional schemas may live alongside the modules that use them (for example in `../verblets` or `../chains`).
@@ -1,18 +1,12 @@
1
1
  import fs from 'node:fs/promises';
2
2
 
3
- const schemaFileNames = [
4
- '../verblets/bool/index.schema.json',
5
- '../chains/list/schema.json'
6
- ];
7
-
8
- const schemas = [];
9
-
10
- for (let schemaFileName of schemaFileNames) {
11
- const schemaText = await fs.readFile(
12
- new URL(schemaFileName, import.meta.url)
13
- );
14
- const schema = JSON.parse(schemaText);
15
- schemas.push(schema)
16
- }
3
+ const schemaFileNames = ['../verblets/bool/index.schema.json', '../chains/list/schema.json'];
4
+
5
+ const schemas = await Promise.all(
6
+ schemaFileNames.map(async (schemaFileName) => {
7
+ const schemaText = await fs.readFile(new URL(schemaFileName, import.meta.url));
8
+ return JSON.parse(schemaText);
9
+ })
10
+ );
17
11
 
18
12
  export default schemas;
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://example.com/schemas/photograph.json",
4
4
  "type": "object",
5
+ "additionalProperties": false,
5
6
  "properties": {
6
7
  "@context": {
7
8
  "type": "string",
@@ -28,6 +29,7 @@
28
29
  },
29
30
  "thumbnail": {
30
31
  "type": "object",
32
+ "additionalProperties": false,
31
33
  "properties": {
32
34
  "@type": {
33
35
  "type": "string",
@@ -45,10 +47,11 @@
45
47
  "minimum": 1
46
48
  }
47
49
  },
48
- "required": ["url"]
50
+ "required": ["@type", "url"]
49
51
  },
50
52
  "image": {
51
53
  "type": "object",
54
+ "additionalProperties": false,
52
55
  "properties": {
53
56
  "@type": {
54
57
  "type": "string",
@@ -66,10 +69,11 @@
66
69
  "minimum": 1
67
70
  }
68
71
  },
69
- "required": ["url"]
72
+ "required": ["@type", "url"]
70
73
  },
71
74
  "contentLocation": {
72
75
  "type": "object",
76
+ "additionalProperties": false,
73
77
  "properties": {
74
78
  "@type": {
75
79
  "type": "string",
@@ -80,6 +84,7 @@
80
84
  },
81
85
  "address": {
82
86
  "type": "object",
87
+ "additionalProperties": false,
83
88
  "properties": {
84
89
  "@type": {
85
90
  "type": "string",
@@ -101,10 +106,11 @@
101
106
  "type": "string"
102
107
  }
103
108
  },
104
- "required": ["streetAddress", "addressLocality", "addressRegion", "postalCode", "addressCountry"]
109
+ "required": ["@type", "addressLocality", "addressCountry"]
105
110
  },
106
111
  "geo": {
107
112
  "type": "object",
113
+ "additionalProperties": false,
108
114
  "properties": {
109
115
  "@type": {
110
116
  "type": "string",
@@ -117,10 +123,10 @@
117
123
  "type": "number"
118
124
  }
119
125
  },
120
- "required": ["latitude", "longitude"]
126
+ "required": ["@type", "latitude", "longitude"]
121
127
  }
122
128
  },
123
- "required": ["name"]
129
+ "required": ["@type", "name"]
124
130
  }
125
131
  },
126
132
  "required": ["@context", "@type", "name"]
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "type": "object",
4
+ "additionalProperties": false,
4
5
  "properties": {
6
+ "@context": {
7
+ "type": "string",
8
+ "pattern": "^https://schema.org$"
9
+ },
5
10
  "@type": {
6
11
  "type": "string",
7
12
  "enum": ["Place", "City"]
@@ -9,8 +14,52 @@
9
14
  "name": {
10
15
  "type": "string"
11
16
  },
17
+ "alternateName": {
18
+ "type": "string"
19
+ },
20
+ "description": {
21
+ "type": "string"
22
+ },
23
+ "population": {
24
+ "type": "integer",
25
+ "minimum": 0
26
+ },
27
+ "area": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "@type": {
32
+ "type": "string",
33
+ "enum": ["QuantitativeValue"]
34
+ },
35
+ "value": {
36
+ "type": "number",
37
+ "minimum": 0
38
+ },
39
+ "unitCode": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ },
44
+ "elevation": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "properties": {
48
+ "@type": {
49
+ "type": "string",
50
+ "enum": ["QuantitativeValue"]
51
+ },
52
+ "value": {
53
+ "type": "number"
54
+ },
55
+ "unitCode": {
56
+ "type": "string"
57
+ }
58
+ }
59
+ },
12
60
  "address": {
13
61
  "type": "object",
62
+ "additionalProperties": false,
14
63
  "properties": {
15
64
  "@type": {
16
65
  "type": "string",
@@ -31,11 +80,11 @@
31
80
  "addressCountry": {
32
81
  "type": "string"
33
82
  }
34
- },
35
- "additionalProperties": true
83
+ }
36
84
  },
37
85
  "geo": {
38
86
  "type": "object",
87
+ "additionalProperties": false,
39
88
  "properties": {
40
89
  "@type": {
41
90
  "type": "string",
@@ -47,10 +96,34 @@
47
96
  "longitude": {
48
97
  "type": "number"
49
98
  }
50
- },
51
- "additionalProperties": true
99
+ }
100
+ },
101
+ "areaServed": {
102
+ "oneOf": [
103
+ {
104
+ "type": "string"
105
+ },
106
+ {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "properties": {
110
+ "@type": {
111
+ "type": "string",
112
+ "enum": ["AdministrativeArea"]
113
+ },
114
+ "name": {
115
+ "type": "string"
116
+ }
117
+ }
118
+ }
119
+ ]
120
+ },
121
+ "additionalType": {
122
+ "type": "string"
123
+ },
124
+ "sameAs": {
125
+ "type": "string"
52
126
  }
53
127
  },
54
- "additionalProperties": true,
55
128
  "required": ["@type", "name"]
56
129
  }
@@ -0,0 +1,26 @@
1
+ # Library Helpers
2
+
3
+ The `lib` directory houses reusable utilities used by verblets and chains. Each subfolder contains a focused helper function or class.
4
+
5
+ Modules include:
6
+
7
+ <!-- commonly used utilities -->
8
+ - [chatgpt](./chatgpt) – wrapper around OpenAI's ChatGPT API.
9
+ - [prompt-cache](./prompt-cache) – cache prompts/responses locally.
10
+ - [retry](./retry) – generic async retry helper.
11
+ - [search-best-first](./search-best-first) – best-first tree search algorithm.
12
+ - [search-js-files](./search-js-files) – locate and analyze JavaScript files.
13
+ - [combinations](./combinations) – generate array combinations.
14
+ - [rangeCombinations](./combinations) – combinations across multiple sizes.
15
+ - [shorten-text](./shorten-text) – shorten text using an LLM.
16
+ - [bulk-map](./bulk-map) – map lists in retryable batches.
17
+ - [bulk-filter](./bulk-filter) – filter lists in retryable batches.
18
+ - [strip-numeric](./strip-numeric) – remove non-digit characters.
19
+ - [strip-response](./strip-response) – clean up model responses.
20
+ - [to-bool](./to-bool) – parse text into a boolean.
21
+ - [to-enum](./to-enum) – parse text into an enum value.
22
+ - [to-number](./to-number) – parse text into a number.
23
+ - [to-number-with-units](./to-number-with-units) – parse numbers that include units.
24
+ - [transcribe](./transcribe) – microphone transcription via Whisper.
25
+
26
+ These helpers are building blocks used throughout the rest of the project.
@@ -0,0 +1,22 @@
1
+ # bulk-filter
2
+
3
+ Filter long lists in batches using `listFilter`. Batches that fail can be retried.
4
+
5
+ ```javascript
6
+ import bulkFilter from './index.js';
7
+
8
+ const reflections = [
9
+ 'Losing that match taught me the value of persistence.',
10
+ "I hate losing and it proves I'm worthless.",
11
+ 'After failing my exam, I studied harder and passed the retake.',
12
+ "No matter what I do, I'll never succeed.",
13
+ ];
14
+ const growth = await bulkFilter(
15
+ reflections,
16
+ 'keep only reflections that show personal growth or learning from mistakes'
17
+ );
18
+ // growth === [
19
+ // 'Losing that match taught me the value of persistence.',
20
+ // 'After failing my exam, I studied harder and passed the retake.',
21
+ // ]
22
+ ```