@ax-llm/ax 9.0.20 → 9.0.22

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 (570) hide show
  1. package/ai/anthropic/api.d.ts +19 -0
  2. package/ai/anthropic/api.js +326 -0
  3. package/ai/anthropic/api.js.map +1 -0
  4. package/ai/anthropic/index.d.ts +2 -0
  5. package/ai/anthropic/index.js +3 -0
  6. package/ai/anthropic/index.js.map +1 -0
  7. package/ai/anthropic/info.d.ts +2 -0
  8. package/ai/anthropic/info.js +40 -0
  9. package/ai/anthropic/info.js.map +1 -0
  10. package/ai/anthropic/types.d.ts +171 -0
  11. package/ai/anthropic/types.js +10 -0
  12. package/ai/anthropic/types.js.map +1 -0
  13. package/ai/azure-openai/api.d.ts +19 -0
  14. package/ai/azure-openai/api.js +30 -0
  15. package/ai/azure-openai/api.js.map +1 -0
  16. package/ai/azure-openai/index.d.ts +1 -0
  17. package/ai/azure-openai/index.js +2 -0
  18. package/ai/azure-openai/index.js.map +1 -0
  19. package/ai/balance.d.ts +23 -0
  20. package/ai/balance.js +87 -0
  21. package/ai/balance.js.map +1 -0
  22. package/ai/base.d.ts +55 -0
  23. package/ai/base.js +343 -0
  24. package/ai/base.js.map +1 -0
  25. package/ai/cohere/api.d.ts +22 -0
  26. package/ai/cohere/api.js +264 -0
  27. package/ai/cohere/api.js.map +1 -0
  28. package/ai/cohere/index.d.ts +2 -0
  29. package/ai/cohere/index.js +3 -0
  30. package/ai/cohere/index.js.map +1 -0
  31. package/ai/cohere/info.d.ts +2 -0
  32. package/ai/cohere/info.js +52 -0
  33. package/ai/cohere/info.js.map +1 -0
  34. package/ai/cohere/types.d.ts +102 -0
  35. package/ai/cohere/types.js +23 -0
  36. package/ai/cohere/types.js.map +1 -0
  37. package/ai/deepseek/api.d.ts +16 -0
  38. package/ai/deepseek/api.js +32 -0
  39. package/ai/deepseek/api.js.map +1 -0
  40. package/ai/deepseek/index.d.ts +2 -0
  41. package/ai/deepseek/index.js +3 -0
  42. package/ai/deepseek/index.js.map +1 -0
  43. package/ai/deepseek/info.d.ts +2 -0
  44. package/ai/deepseek/info.js +16 -0
  45. package/ai/deepseek/info.js.map +1 -0
  46. package/ai/deepseek/types.d.ts +8 -0
  47. package/ai/deepseek/types.js +10 -0
  48. package/ai/deepseek/types.js.map +1 -0
  49. package/ai/google-gemini/api.d.ts +36 -0
  50. package/ai/google-gemini/api.js +299 -0
  51. package/ai/google-gemini/api.js.map +1 -0
  52. package/ai/google-gemini/index.d.ts +2 -0
  53. package/ai/google-gemini/index.js +3 -0
  54. package/ai/google-gemini/index.js.map +1 -0
  55. package/ai/google-gemini/info.d.ts +6 -0
  56. package/ai/google-gemini/info.js +29 -0
  57. package/ai/google-gemini/info.js.map +1 -0
  58. package/ai/google-gemini/types.d.ts +146 -0
  59. package/ai/google-gemini/types.js +27 -0
  60. package/ai/google-gemini/types.js.map +1 -0
  61. package/ai/groq/api.d.ts +18 -0
  62. package/ai/groq/api.js +52 -0
  63. package/ai/groq/api.js.map +1 -0
  64. package/ai/groq/index.d.ts +1 -0
  65. package/ai/groq/index.js +2 -0
  66. package/ai/groq/index.js.map +1 -0
  67. package/ai/groq/types.d.ts +6 -0
  68. package/ai/groq/types.js +8 -0
  69. package/ai/groq/types.js.map +1 -0
  70. package/ai/huggingface/api.d.ts +19 -0
  71. package/ai/huggingface/api.js +115 -0
  72. package/ai/huggingface/api.js.map +1 -0
  73. package/ai/huggingface/index.d.ts +2 -0
  74. package/ai/huggingface/index.js +3 -0
  75. package/ai/huggingface/index.js.map +1 -0
  76. package/ai/huggingface/info.d.ts +6 -0
  77. package/ai/huggingface/info.js +6 -0
  78. package/ai/huggingface/info.js.map +1 -0
  79. package/ai/huggingface/types.d.ts +34 -0
  80. package/ai/huggingface/types.js +5 -0
  81. package/ai/huggingface/types.js.map +1 -0
  82. package/ai/index.d.ts +16 -0
  83. package/ai/index.js +16 -0
  84. package/ai/index.js.map +1 -0
  85. package/ai/mistral/api.d.ts +16 -0
  86. package/ai/mistral/api.js +32 -0
  87. package/ai/mistral/api.js.map +1 -0
  88. package/ai/mistral/index.d.ts +2 -0
  89. package/ai/mistral/index.js +3 -0
  90. package/ai/mistral/index.js.map +1 -0
  91. package/ai/mistral/info.d.ts +2 -0
  92. package/ai/mistral/info.js +34 -0
  93. package/ai/mistral/info.js.map +1 -0
  94. package/ai/mistral/types.d.ts +10 -0
  95. package/ai/mistral/types.js +13 -0
  96. package/ai/mistral/types.js.map +1 -0
  97. package/ai/ollama/api.d.ts +22 -0
  98. package/ai/ollama/api.js +32 -0
  99. package/ai/ollama/api.js.map +1 -0
  100. package/ai/ollama/index.d.ts +1 -0
  101. package/ai/ollama/index.js +2 -0
  102. package/ai/ollama/index.js.map +1 -0
  103. package/ai/openai/api.d.ts +29 -0
  104. package/ai/openai/api.js +283 -0
  105. package/ai/openai/api.js.map +1 -0
  106. package/ai/openai/index.d.ts +2 -0
  107. package/ai/openai/index.js +3 -0
  108. package/ai/openai/index.js.map +1 -0
  109. package/ai/openai/info.d.ts +6 -0
  110. package/ai/openai/info.js +50 -0
  111. package/ai/openai/info.js.map +1 -0
  112. package/ai/openai/types.d.ts +165 -0
  113. package/ai/openai/types.js +18 -0
  114. package/ai/openai/types.js.map +1 -0
  115. package/ai/together/api.d.ts +15 -0
  116. package/ai/together/api.js +28 -0
  117. package/ai/together/api.js.map +1 -0
  118. package/ai/together/index.d.ts +1 -0
  119. package/ai/together/index.js +2 -0
  120. package/ai/together/index.js.map +1 -0
  121. package/ai/together/info.d.ts +2 -0
  122. package/ai/together/info.js +2 -0
  123. package/ai/together/info.js.map +1 -0
  124. package/ai/types.d.ts +159 -0
  125. package/ai/types.js +2 -0
  126. package/ai/types.js.map +1 -0
  127. package/ai/util.d.ts +12 -0
  128. package/ai/util.js +63 -0
  129. package/ai/util.js.map +1 -0
  130. package/ai/wrap.d.ts +47 -0
  131. package/ai/wrap.js +95 -0
  132. package/ai/wrap.js.map +1 -0
  133. package/cjs/ai/anthropic/api.d.ts +19 -0
  134. package/cjs/ai/anthropic/api.js +331 -0
  135. package/cjs/ai/anthropic/api.js.map +1 -0
  136. package/cjs/ai/anthropic/index.d.ts +2 -0
  137. package/cjs/ai/anthropic/index.js +19 -0
  138. package/cjs/ai/anthropic/index.js.map +1 -0
  139. package/cjs/ai/anthropic/info.d.ts +2 -0
  140. package/cjs/ai/anthropic/info.js +43 -0
  141. package/cjs/ai/anthropic/info.js.map +1 -0
  142. package/cjs/ai/anthropic/types.d.ts +171 -0
  143. package/cjs/ai/anthropic/types.js +13 -0
  144. package/cjs/ai/anthropic/types.js.map +1 -0
  145. package/cjs/ai/azure-openai/api.d.ts +19 -0
  146. package/cjs/ai/azure-openai/api.js +34 -0
  147. package/cjs/ai/azure-openai/api.js.map +1 -0
  148. package/cjs/ai/azure-openai/index.d.ts +1 -0
  149. package/cjs/ai/azure-openai/index.js +18 -0
  150. package/cjs/ai/azure-openai/index.js.map +1 -0
  151. package/cjs/ai/balance.d.ts +23 -0
  152. package/cjs/ai/balance.js +91 -0
  153. package/cjs/ai/balance.js.map +1 -0
  154. package/cjs/ai/base.d.ts +55 -0
  155. package/cjs/ai/base.js +349 -0
  156. package/cjs/ai/base.js.map +1 -0
  157. package/cjs/ai/cohere/api.d.ts +22 -0
  158. package/cjs/ai/cohere/api.js +270 -0
  159. package/cjs/ai/cohere/api.js.map +1 -0
  160. package/cjs/ai/cohere/index.d.ts +2 -0
  161. package/cjs/ai/cohere/index.js +19 -0
  162. package/cjs/ai/cohere/index.js.map +1 -0
  163. package/cjs/ai/cohere/info.d.ts +2 -0
  164. package/cjs/ai/cohere/info.js +55 -0
  165. package/cjs/ai/cohere/info.js.map +1 -0
  166. package/cjs/ai/cohere/types.d.ts +102 -0
  167. package/cjs/ai/cohere/types.js +26 -0
  168. package/cjs/ai/cohere/types.js.map +1 -0
  169. package/cjs/ai/deepseek/api.d.ts +16 -0
  170. package/cjs/ai/deepseek/api.js +38 -0
  171. package/cjs/ai/deepseek/api.js.map +1 -0
  172. package/cjs/ai/deepseek/index.d.ts +2 -0
  173. package/cjs/ai/deepseek/index.js +19 -0
  174. package/cjs/ai/deepseek/index.js.map +1 -0
  175. package/cjs/ai/deepseek/info.d.ts +2 -0
  176. package/cjs/ai/deepseek/info.js +19 -0
  177. package/cjs/ai/deepseek/info.js.map +1 -0
  178. package/cjs/ai/deepseek/types.d.ts +8 -0
  179. package/cjs/ai/deepseek/types.js +13 -0
  180. package/cjs/ai/deepseek/types.js.map +1 -0
  181. package/cjs/ai/google-gemini/api.d.ts +36 -0
  182. package/cjs/ai/google-gemini/api.js +305 -0
  183. package/cjs/ai/google-gemini/api.js.map +1 -0
  184. package/cjs/ai/google-gemini/index.d.ts +2 -0
  185. package/cjs/ai/google-gemini/index.js +19 -0
  186. package/cjs/ai/google-gemini/index.js.map +1 -0
  187. package/cjs/ai/google-gemini/info.d.ts +6 -0
  188. package/cjs/ai/google-gemini/info.js +32 -0
  189. package/cjs/ai/google-gemini/info.js.map +1 -0
  190. package/cjs/ai/google-gemini/types.d.ts +146 -0
  191. package/cjs/ai/google-gemini/types.js +30 -0
  192. package/cjs/ai/google-gemini/types.js.map +1 -0
  193. package/cjs/ai/groq/api.d.ts +18 -0
  194. package/cjs/ai/groq/api.js +56 -0
  195. package/cjs/ai/groq/api.js.map +1 -0
  196. package/cjs/ai/groq/index.d.ts +1 -0
  197. package/cjs/ai/groq/index.js +18 -0
  198. package/cjs/ai/groq/index.js.map +1 -0
  199. package/cjs/ai/groq/types.d.ts +6 -0
  200. package/cjs/ai/groq/types.js +11 -0
  201. package/cjs/ai/groq/types.js.map +1 -0
  202. package/cjs/ai/huggingface/api.d.ts +19 -0
  203. package/cjs/ai/huggingface/api.js +121 -0
  204. package/cjs/ai/huggingface/api.js.map +1 -0
  205. package/cjs/ai/huggingface/index.d.ts +2 -0
  206. package/cjs/ai/huggingface/index.js +19 -0
  207. package/cjs/ai/huggingface/index.js.map +1 -0
  208. package/cjs/ai/huggingface/info.d.ts +6 -0
  209. package/cjs/ai/huggingface/info.js +9 -0
  210. package/cjs/ai/huggingface/info.js.map +1 -0
  211. package/cjs/ai/huggingface/types.d.ts +34 -0
  212. package/cjs/ai/huggingface/types.js +8 -0
  213. package/cjs/ai/huggingface/types.js.map +1 -0
  214. package/cjs/ai/index.d.ts +16 -0
  215. package/cjs/ai/index.js +32 -0
  216. package/cjs/ai/index.js.map +1 -0
  217. package/cjs/ai/mistral/api.d.ts +16 -0
  218. package/cjs/ai/mistral/api.js +38 -0
  219. package/cjs/ai/mistral/api.js.map +1 -0
  220. package/cjs/ai/mistral/index.d.ts +2 -0
  221. package/cjs/ai/mistral/index.js +19 -0
  222. package/cjs/ai/mistral/index.js.map +1 -0
  223. package/cjs/ai/mistral/info.d.ts +2 -0
  224. package/cjs/ai/mistral/info.js +37 -0
  225. package/cjs/ai/mistral/info.js.map +1 -0
  226. package/cjs/ai/mistral/types.d.ts +10 -0
  227. package/cjs/ai/mistral/types.js +16 -0
  228. package/cjs/ai/mistral/types.js.map +1 -0
  229. package/cjs/ai/ollama/api.d.ts +22 -0
  230. package/cjs/ai/ollama/api.js +38 -0
  231. package/cjs/ai/ollama/api.js.map +1 -0
  232. package/cjs/ai/ollama/index.d.ts +1 -0
  233. package/cjs/ai/ollama/index.js +18 -0
  234. package/cjs/ai/ollama/index.js.map +1 -0
  235. package/cjs/ai/openai/api.d.ts +29 -0
  236. package/cjs/ai/openai/api.js +291 -0
  237. package/cjs/ai/openai/api.js.map +1 -0
  238. package/cjs/ai/openai/index.d.ts +2 -0
  239. package/cjs/ai/openai/index.js +19 -0
  240. package/cjs/ai/openai/index.js.map +1 -0
  241. package/cjs/ai/openai/info.d.ts +6 -0
  242. package/cjs/ai/openai/info.js +53 -0
  243. package/cjs/ai/openai/info.js.map +1 -0
  244. package/cjs/ai/openai/types.d.ts +165 -0
  245. package/cjs/ai/openai/types.js +21 -0
  246. package/cjs/ai/openai/types.js.map +1 -0
  247. package/cjs/ai/together/api.d.ts +15 -0
  248. package/cjs/ai/together/api.js +33 -0
  249. package/cjs/ai/together/api.js.map +1 -0
  250. package/cjs/ai/together/index.d.ts +1 -0
  251. package/cjs/ai/together/index.js +18 -0
  252. package/cjs/ai/together/index.js.map +1 -0
  253. package/cjs/ai/together/info.d.ts +2 -0
  254. package/cjs/ai/together/info.js +5 -0
  255. package/cjs/ai/together/info.js.map +1 -0
  256. package/cjs/ai/types.d.ts +159 -0
  257. package/cjs/ai/types.js +3 -0
  258. package/cjs/ai/types.js.map +1 -0
  259. package/cjs/ai/util.d.ts +12 -0
  260. package/cjs/ai/util.js +71 -0
  261. package/cjs/ai/util.js.map +1 -0
  262. package/cjs/ai/wrap.d.ts +47 -0
  263. package/cjs/ai/wrap.js +99 -0
  264. package/cjs/ai/wrap.js.map +1 -0
  265. package/cjs/db/base.d.ts +23 -0
  266. package/cjs/db/base.js +91 -0
  267. package/cjs/db/base.js.map +1 -0
  268. package/cjs/db/cloudflare.d.ts +21 -0
  269. package/cjs/db/cloudflare.js +102 -0
  270. package/cjs/db/cloudflare.js.map +1 -0
  271. package/cjs/db/index.d.ts +6 -0
  272. package/cjs/db/index.js +23 -0
  273. package/cjs/db/index.js.map +1 -0
  274. package/cjs/db/memory.d.ts +21 -0
  275. package/cjs/db/memory.js +103 -0
  276. package/cjs/db/memory.js.map +1 -0
  277. package/cjs/db/pinecone.d.ts +21 -0
  278. package/cjs/db/pinecone.js +75 -0
  279. package/cjs/db/pinecone.js.map +1 -0
  280. package/cjs/db/types.d.ts +35 -0
  281. package/cjs/db/types.js +4 -0
  282. package/cjs/db/types.js.map +1 -0
  283. package/cjs/db/weaviate.d.ts +21 -0
  284. package/cjs/db/weaviate.js +131 -0
  285. package/cjs/db/weaviate.js.map +1 -0
  286. package/cjs/db/wrap.d.ts +13 -0
  287. package/cjs/db/wrap.js +39 -0
  288. package/cjs/db/wrap.js.map +1 -0
  289. package/cjs/docs/index.d.ts +4 -0
  290. package/cjs/docs/index.js +21 -0
  291. package/cjs/docs/index.js.map +1 -0
  292. package/cjs/docs/manager.d.ts +45 -0
  293. package/cjs/docs/manager.js +162 -0
  294. package/cjs/docs/manager.js.map +1 -0
  295. package/cjs/docs/reranker.d.ts +7 -0
  296. package/cjs/docs/reranker.js +30 -0
  297. package/cjs/docs/reranker.js.map +1 -0
  298. package/cjs/docs/rewriter.d.ts +4 -0
  299. package/cjs/docs/rewriter.js +13 -0
  300. package/cjs/docs/rewriter.js.map +1 -0
  301. package/cjs/docs/tika.d.ts +18 -0
  302. package/cjs/docs/tika.js +50 -0
  303. package/cjs/docs/tika.js.map +1 -0
  304. package/cjs/dsp/asserts.d.ts +32 -0
  305. package/cjs/dsp/asserts.js +98 -0
  306. package/cjs/dsp/asserts.js.map +1 -0
  307. package/cjs/dsp/eval.d.ts +43 -0
  308. package/cjs/dsp/eval.js +128 -0
  309. package/cjs/dsp/eval.js.map +1 -0
  310. package/cjs/dsp/evaluate.d.ts +12 -0
  311. package/cjs/dsp/evaluate.js +36 -0
  312. package/cjs/dsp/evaluate.js.map +1 -0
  313. package/cjs/dsp/extract.d.ts +25 -0
  314. package/cjs/dsp/extract.js +164 -0
  315. package/cjs/dsp/extract.js.map +1 -0
  316. package/cjs/dsp/generate.d.ts +55 -0
  317. package/cjs/dsp/generate.js +314 -0
  318. package/cjs/dsp/generate.js.map +1 -0
  319. package/cjs/dsp/index.d.ts +15 -0
  320. package/cjs/dsp/index.js +27 -0
  321. package/cjs/dsp/index.js.map +1 -0
  322. package/cjs/dsp/loader.d.ts +30 -0
  323. package/cjs/dsp/loader.js +85 -0
  324. package/cjs/dsp/loader.js.map +1 -0
  325. package/cjs/dsp/optimize.d.ts +27 -0
  326. package/cjs/dsp/optimize.js +99 -0
  327. package/cjs/dsp/optimize.js.map +1 -0
  328. package/cjs/dsp/parser.d.ts +87 -0
  329. package/cjs/dsp/parser.js +1545 -0
  330. package/cjs/dsp/parser.js.map +1 -0
  331. package/cjs/dsp/program.d.ts +73 -0
  332. package/cjs/dsp/program.js +120 -0
  333. package/cjs/dsp/program.js.map +1 -0
  334. package/cjs/dsp/prompt.d.ts +48 -0
  335. package/cjs/dsp/prompt.js +263 -0
  336. package/cjs/dsp/prompt.js.map +1 -0
  337. package/cjs/dsp/registry.d.ts +6 -0
  338. package/cjs/dsp/registry.js +19 -0
  339. package/cjs/dsp/registry.js.map +1 -0
  340. package/cjs/dsp/router.d.ts +26 -0
  341. package/cjs/dsp/router.js +76 -0
  342. package/cjs/dsp/router.js.map +1 -0
  343. package/cjs/dsp/sig.d.ts +37 -0
  344. package/cjs/dsp/sig.js +197 -0
  345. package/cjs/dsp/sig.js.map +1 -0
  346. package/cjs/dsp/stopwords.d.ts +1 -0
  347. package/cjs/dsp/stopwords.js +1167 -0
  348. package/cjs/dsp/stopwords.js.map +1 -0
  349. package/cjs/dsp/strutil.d.ts +11 -0
  350. package/cjs/dsp/strutil.js +63 -0
  351. package/cjs/dsp/strutil.js.map +1 -0
  352. package/cjs/dsp/util.d.ts +5 -0
  353. package/cjs/dsp/util.js +82 -0
  354. package/cjs/dsp/util.js.map +1 -0
  355. package/cjs/funcs/code.d.ts +9 -0
  356. package/cjs/funcs/code.js +90 -0
  357. package/cjs/funcs/code.js.map +1 -0
  358. package/cjs/funcs/embed.d.ts +6 -0
  359. package/cjs/funcs/embed.js +33 -0
  360. package/cjs/funcs/embed.js.map +1 -0
  361. package/cjs/funcs/functions.d.ts +16 -0
  362. package/cjs/funcs/functions.js +62 -0
  363. package/cjs/funcs/functions.js.map +1 -0
  364. package/cjs/funcs/index.d.ts +3 -0
  365. package/cjs/funcs/index.js +20 -0
  366. package/cjs/funcs/index.js.map +1 -0
  367. package/cjs/funcs/jsonschema.d.ts +2 -0
  368. package/cjs/funcs/jsonschema.js +101 -0
  369. package/cjs/funcs/jsonschema.js.map +1 -0
  370. package/cjs/index.d.ts +9 -0
  371. package/cjs/index.js +34 -0
  372. package/cjs/index.js.map +1 -0
  373. package/cjs/mem/index.d.ts +2 -0
  374. package/cjs/mem/index.js +19 -0
  375. package/cjs/mem/index.js.map +1 -0
  376. package/cjs/mem/memory.d.ts +16 -0
  377. package/cjs/mem/memory.js +81 -0
  378. package/cjs/mem/memory.js.map +1 -0
  379. package/cjs/mem/types.d.ts +10 -0
  380. package/cjs/mem/types.js +3 -0
  381. package/cjs/mem/types.js.map +1 -0
  382. package/cjs/prompts/agent.d.ts +34 -0
  383. package/cjs/prompts/agent.js +110 -0
  384. package/cjs/prompts/agent.js.map +1 -0
  385. package/cjs/prompts/cot.d.ts +9 -0
  386. package/cjs/prompts/cot.js +21 -0
  387. package/cjs/prompts/cot.js.map +1 -0
  388. package/cjs/prompts/index.d.ts +4 -0
  389. package/cjs/prompts/index.js +21 -0
  390. package/cjs/prompts/index.js.map +1 -0
  391. package/cjs/prompts/rag.d.ts +23 -0
  392. package/cjs/prompts/rag.js +33 -0
  393. package/cjs/prompts/rag.js.map +1 -0
  394. package/cjs/prompts/react.d.ts +8 -0
  395. package/cjs/prompts/react.js +26 -0
  396. package/cjs/prompts/react.js.map +1 -0
  397. package/cjs/trace/index.d.ts +171 -0
  398. package/cjs/trace/index.js +70 -0
  399. package/cjs/trace/index.js.map +1 -0
  400. package/cjs/util/apicall.d.ts +18 -0
  401. package/cjs/util/apicall.js +57 -0
  402. package/cjs/util/apicall.js.map +1 -0
  403. package/cjs/util/log.d.ts +14 -0
  404. package/cjs/util/log.js +35 -0
  405. package/cjs/util/log.js.map +1 -0
  406. package/cjs/util/other.d.ts +1 -0
  407. package/cjs/util/other.js +8 -0
  408. package/cjs/util/other.js.map +1 -0
  409. package/cjs/util/rate-limit.d.ts +24 -0
  410. package/cjs/util/rate-limit.js +53 -0
  411. package/cjs/util/rate-limit.js.map +1 -0
  412. package/cjs/util/stream.d.ts +9 -0
  413. package/cjs/util/stream.js +33 -0
  414. package/cjs/util/stream.js.map +1 -0
  415. package/cjs/util/transform.d.ts +7 -0
  416. package/cjs/util/transform.js +64 -0
  417. package/cjs/util/transform.js.map +1 -0
  418. package/db/base.d.ts +23 -0
  419. package/db/base.js +87 -0
  420. package/db/base.js.map +1 -0
  421. package/db/cloudflare.d.ts +21 -0
  422. package/db/cloudflare.js +98 -0
  423. package/db/cloudflare.js.map +1 -0
  424. package/db/index.d.ts +6 -0
  425. package/db/index.js +7 -0
  426. package/db/index.js.map +1 -0
  427. package/db/memory.d.ts +21 -0
  428. package/db/memory.js +99 -0
  429. package/db/memory.js.map +1 -0
  430. package/db/pinecone.d.ts +21 -0
  431. package/db/pinecone.js +71 -0
  432. package/db/pinecone.js.map +1 -0
  433. package/db/types.d.ts +35 -0
  434. package/db/types.js +3 -0
  435. package/db/types.js.map +1 -0
  436. package/db/weaviate.d.ts +21 -0
  437. package/db/weaviate.js +127 -0
  438. package/db/weaviate.js.map +1 -0
  439. package/db/wrap.d.ts +13 -0
  440. package/db/wrap.js +35 -0
  441. package/db/wrap.js.map +1 -0
  442. package/docs/index.d.ts +4 -0
  443. package/docs/index.js +5 -0
  444. package/docs/index.js.map +1 -0
  445. package/docs/manager.d.ts +45 -0
  446. package/docs/manager.js +159 -0
  447. package/docs/manager.js.map +1 -0
  448. package/docs/reranker.d.ts +7 -0
  449. package/docs/reranker.js +26 -0
  450. package/docs/reranker.js.map +1 -0
  451. package/docs/rewriter.d.ts +4 -0
  452. package/docs/rewriter.js +9 -0
  453. package/docs/rewriter.js.map +1 -0
  454. package/docs/tika.d.ts +18 -0
  455. package/docs/tika.js +46 -0
  456. package/docs/tika.js.map +1 -0
  457. package/dsp/asserts.d.ts +32 -0
  458. package/dsp/asserts.js +91 -0
  459. package/dsp/asserts.js.map +1 -0
  460. package/dsp/eval.d.ts +43 -0
  461. package/dsp/eval.js +125 -0
  462. package/dsp/eval.js.map +1 -0
  463. package/dsp/evaluate.d.ts +12 -0
  464. package/dsp/evaluate.js +32 -0
  465. package/dsp/evaluate.js.map +1 -0
  466. package/dsp/extract.d.ts +25 -0
  467. package/dsp/extract.js +153 -0
  468. package/dsp/extract.js.map +1 -0
  469. package/dsp/generate.d.ts +55 -0
  470. package/dsp/generate.js +311 -0
  471. package/dsp/generate.js.map +1 -0
  472. package/dsp/index.d.ts +15 -0
  473. package/dsp/index.js +11 -0
  474. package/dsp/index.js.map +1 -0
  475. package/dsp/loader.d.ts +30 -0
  476. package/dsp/loader.js +81 -0
  477. package/dsp/loader.js.map +1 -0
  478. package/dsp/optimize.d.ts +27 -0
  479. package/dsp/optimize.js +95 -0
  480. package/dsp/optimize.js.map +1 -0
  481. package/dsp/parser.d.ts +87 -0
  482. package/dsp/parser.js +1542 -0
  483. package/dsp/parser.js.map +1 -0
  484. package/dsp/program.d.ts +73 -0
  485. package/dsp/program.js +116 -0
  486. package/dsp/program.js.map +1 -0
  487. package/dsp/prompt.d.ts +48 -0
  488. package/dsp/prompt.js +260 -0
  489. package/dsp/prompt.js.map +1 -0
  490. package/dsp/registry.d.ts +6 -0
  491. package/dsp/registry.js +15 -0
  492. package/dsp/registry.js.map +1 -0
  493. package/dsp/router.d.ts +26 -0
  494. package/dsp/router.js +71 -0
  495. package/dsp/router.js.map +1 -0
  496. package/dsp/sig.d.ts +37 -0
  497. package/dsp/sig.js +193 -0
  498. package/dsp/sig.js.map +1 -0
  499. package/dsp/stopwords.d.ts +1 -0
  500. package/dsp/stopwords.js +1164 -0
  501. package/dsp/stopwords.js.map +1 -0
  502. package/dsp/strutil.d.ts +11 -0
  503. package/dsp/strutil.js +60 -0
  504. package/dsp/strutil.js.map +1 -0
  505. package/dsp/util.d.ts +5 -0
  506. package/dsp/util.js +76 -0
  507. package/dsp/util.js.map +1 -0
  508. package/funcs/code.d.ts +9 -0
  509. package/funcs/code.js +63 -0
  510. package/funcs/code.js.map +1 -0
  511. package/funcs/embed.d.ts +6 -0
  512. package/funcs/embed.js +29 -0
  513. package/funcs/embed.js.map +1 -0
  514. package/funcs/functions.d.ts +16 -0
  515. package/funcs/functions.js +55 -0
  516. package/funcs/functions.js.map +1 -0
  517. package/funcs/index.d.ts +3 -0
  518. package/funcs/index.js +4 -0
  519. package/funcs/index.js.map +1 -0
  520. package/funcs/jsonschema.d.ts +2 -0
  521. package/funcs/jsonschema.js +97 -0
  522. package/funcs/jsonschema.js.map +1 -0
  523. package/index.d.ts +9 -0
  524. package/index.js.map +1 -0
  525. package/mem/index.d.ts +2 -0
  526. package/mem/index.js +3 -0
  527. package/mem/index.js.map +1 -0
  528. package/mem/memory.d.ts +16 -0
  529. package/mem/memory.js +77 -0
  530. package/mem/memory.js.map +1 -0
  531. package/mem/types.d.ts +10 -0
  532. package/mem/types.js +2 -0
  533. package/mem/types.js.map +1 -0
  534. package/package.json +4 -7
  535. package/prompts/agent.d.ts +34 -0
  536. package/prompts/agent.js +108 -0
  537. package/prompts/agent.js.map +1 -0
  538. package/prompts/cot.d.ts +9 -0
  539. package/prompts/cot.js +17 -0
  540. package/prompts/cot.js.map +1 -0
  541. package/prompts/index.d.ts +4 -0
  542. package/prompts/index.js +5 -0
  543. package/prompts/index.js.map +1 -0
  544. package/prompts/rag.d.ts +23 -0
  545. package/prompts/rag.js +30 -0
  546. package/prompts/rag.js.map +1 -0
  547. package/prompts/react.d.ts +8 -0
  548. package/prompts/react.js +22 -0
  549. package/prompts/react.js.map +1 -0
  550. package/trace/index.d.ts +171 -0
  551. package/trace/index.js +67 -0
  552. package/trace/index.js.map +1 -0
  553. package/util/apicall.d.ts +18 -0
  554. package/util/apicall.js +50 -0
  555. package/util/apicall.js.map +1 -0
  556. package/util/log.d.ts +14 -0
  557. package/util/log.js +31 -0
  558. package/util/log.js.map +1 -0
  559. package/util/other.d.ts +1 -0
  560. package/util/other.js +5 -0
  561. package/util/other.js.map +1 -0
  562. package/util/rate-limit.d.ts +24 -0
  563. package/util/rate-limit.js +49 -0
  564. package/util/rate-limit.js.map +1 -0
  565. package/util/stream.d.ts +9 -0
  566. package/util/stream.js +29 -0
  567. package/util/stream.js.map +1 -0
  568. package/util/transform.d.ts +7 -0
  569. package/util/transform.js +59 -0
  570. package/util/transform.js.map +1 -0
@@ -0,0 +1 @@
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YACf,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAEO,GAAG,CAAC,SAAkB;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;CACF"}
package/mem/types.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { AxChatRequest, AxChatResponseResult } from '../ai/index.js';
2
+ export interface AxAIMemory {
3
+ add(result: Readonly<AxChatRequest['chatPrompt'] | AxChatRequest['chatPrompt'][0]>, sessionId?: string): void;
4
+ addResult(result: Readonly<AxChatResponseResult>, sessionId?: string): void;
5
+ updateResult(result: Readonly<AxChatResponseResult>, sessionId?: string): void;
6
+ history(sessionId?: string): AxChatRequest['chatPrompt'];
7
+ peek(sessionId?: string): AxChatRequest['chatPrompt'];
8
+ reset(sessionId?: string): void;
9
+ getLast(sessionId?: string): AxChatRequest['chatPrompt'][0] | undefined;
10
+ }
package/mem/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../mem/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ax-llm/ax",
3
- "version": "9.0.20",
3
+ "version": "9.0.22",
4
4
  "description": "The best library to work with LLMs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,12 +43,9 @@
43
43
  ]
44
44
  },
45
45
  "files": [
46
- "build",
47
- "!**/*.spec.*",
48
- "!**/*.json",
49
- "CHANGELOG.md",
50
- "LICENSE",
51
- "README.md"
46
+ "**/*",
47
+ "!**/*.test.*",
48
+ "!**/*.json"
52
49
  ],
53
50
  "bugs": {
54
51
  "url": "https://github.com/@ax-llm/ax/issues"
@@ -0,0 +1,34 @@
1
+ import type { AxAIService, AxFunction } from '../ai/types.js';
2
+ import { type AxGenerateOptions, AxSignature } from '../dsp/index.js';
3
+ import { type AxGenIn, type AxGenOut, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxTunable, type AxUsable } from '../dsp/program.js';
4
+ export interface AxAgentic extends AxTunable, AxUsable {
5
+ getFunction(): AxFunction;
6
+ }
7
+ export type AxAgentOptions = Omit<AxGenerateOptions, 'functions' | 'functionCall'>;
8
+ export declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAgentic {
9
+ private program;
10
+ private name;
11
+ private description;
12
+ private subAgentList?;
13
+ private func;
14
+ constructor(ai: AxAIService, { name, description, signature, agents, functions }: Readonly<{
15
+ name: string;
16
+ description: string;
17
+ signature: AxSignature | string;
18
+ agents?: AxAgentic[];
19
+ functions?: AxFunction[];
20
+ }>, options?: Readonly<AxAgentOptions>);
21
+ getSignature(): AxSignature;
22
+ setExamples(examples: Readonly<AxProgramExamples>): void;
23
+ setId(id: string): void;
24
+ setParentId(parentId: string): void;
25
+ getTraces(): import("../dsp/program.js").AxProgramTrace[];
26
+ setDemos(demos: readonly AxProgramDemos[]): void;
27
+ getUsage(): (import("../ai/types.js").AxTokenUsage & {
28
+ ai: string;
29
+ model: string;
30
+ })[];
31
+ resetUsage(): void;
32
+ getFunction(): AxFunction;
33
+ forward(values: IN, options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
34
+ }
@@ -0,0 +1,108 @@
1
+ import { AxSignature } from '../dsp/index.js';
2
+ import { AxProgram } from '../dsp/program.js';
3
+ import { AxSpanKind } from '../trace/index.js';
4
+ import { AxChainOfThought } from './cot.js';
5
+ import { AxReAct } from './react.js';
6
+ export class AxAgent {
7
+ program;
8
+ name;
9
+ description;
10
+ subAgentList;
11
+ func;
12
+ constructor(ai, { name, description, signature, agents, functions }, options) {
13
+ const funcs = [
14
+ ...(functions ?? []),
15
+ ...(agents?.map((a) => a.getFunction()) ?? [])
16
+ ];
17
+ const opt = {
18
+ ...options,
19
+ functions: funcs
20
+ };
21
+ this.program =
22
+ funcs.length > 0
23
+ ? new AxReAct(ai, signature, opt)
24
+ : new AxChainOfThought(ai, signature, opt);
25
+ if (!name || name.length < 5) {
26
+ throw new Error('Agent name must be at least 10 characters (more descriptive): ' + name);
27
+ }
28
+ if (!description || description.length < 20) {
29
+ throw new Error('Agent description must be at least 20 characters (explain in detail what the agent does): ' +
30
+ description);
31
+ }
32
+ this.name = name;
33
+ this.description = description;
34
+ this.subAgentList = agents?.map((a) => a.getFunction().name).join(', ');
35
+ this.func = {
36
+ name: toCamelCase(this.name),
37
+ description: this.description,
38
+ parameters: this.program.getSignature().toJSONSchema(),
39
+ func: () => this.forward
40
+ };
41
+ for (const agent of agents ?? []) {
42
+ this.program.register(agent);
43
+ }
44
+ }
45
+ getSignature() {
46
+ return this.program.getSignature();
47
+ }
48
+ setExamples(examples) {
49
+ this.program.setExamples(examples);
50
+ }
51
+ setId(id) {
52
+ this.program.setId(id);
53
+ }
54
+ setParentId(parentId) {
55
+ this.program.setParentId(parentId);
56
+ }
57
+ getTraces() {
58
+ return this.program.getTraces();
59
+ }
60
+ setDemos(demos) {
61
+ this.program.setDemos(demos);
62
+ }
63
+ getUsage() {
64
+ return this.program.getUsage();
65
+ }
66
+ resetUsage() {
67
+ this.program.resetUsage();
68
+ }
69
+ getFunction() {
70
+ return this.func;
71
+ }
72
+ async forward(values, options) {
73
+ if (!options?.tracer) {
74
+ return await this.program.forward(values, options);
75
+ }
76
+ const attributes = {
77
+ ['agent.name']: this.name,
78
+ ['agent.description']: this.description,
79
+ ['agent.subAgents']: this.subAgentList ?? 'none'
80
+ };
81
+ return await options?.tracer.startActiveSpan('Agent', {
82
+ kind: AxSpanKind.SERVER,
83
+ attributes
84
+ }, async (span) => {
85
+ const res = await this.program.forward(values, options);
86
+ span.end();
87
+ return res;
88
+ });
89
+ }
90
+ }
91
+ function toCamelCase(inputString) {
92
+ // Split the string by any non-alphanumeric character (including underscores, spaces, hyphens)
93
+ const words = inputString.split(/[^a-zA-Z0-9]/);
94
+ // Map through each word, capitalize the first letter of each word except the first word
95
+ const camelCaseString = words
96
+ .map((word, index) => {
97
+ // Lowercase the word to handle cases like uppercase letters in input
98
+ const lowerWord = word.toLowerCase();
99
+ // Capitalize the first letter of each word except the first one
100
+ if (index > 0 && lowerWord && lowerWord[0]) {
101
+ return lowerWord[0].toUpperCase() + lowerWord.slice(1);
102
+ }
103
+ return lowerWord;
104
+ })
105
+ .join('');
106
+ return camelCaseString;
107
+ }
108
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../prompts/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAGL,SAAS,EAMV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAWrC,MAAM,OAAO,OAAO;IAGV,OAAO,CAAqB;IAE5B,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,YAAY,CAAU;IACtB,IAAI,CAAa;IAEzB,YACE,EAAe,EACf,EACE,IAAI,EACJ,WAAW,EACX,SAAS,EACT,MAAM,EACN,SAAS,EAOT,EACF,OAAkC;QAElC,MAAM,KAAK,GAAiB;YAC1B,GAAG,CAAC,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,WAAW;YACvC,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,YAAY,IAAI,MAAM;SACjD,CAAC;QAEF,OAAO,MAAM,OAAO,EAAE,MAAM,CAAC,eAAe,CAC1C,OAAO,EACP;YACE,IAAI,EAAE,UAAU,CAAC,MAAM;YACvB,UAAU;SACX,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACxD,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,GAAG,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,SAAS,WAAW,CAAC,WAAmB;IACtC,8FAA8F;IAC9F,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAEhD,wFAAwF;IACxF,MAAM,eAAe,GAAG,KAAK;SAC1B,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnB,qEAAqE;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAErC,gEAAgE;QAChE,IAAI,KAAK,GAAG,CAAC,IAAI,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { AxAIService } from '../ai/types.js';
2
+ import { AxGenerate, type AxGenerateOptions } from '../dsp/generate.js';
3
+ import type { AxGenIn, AxGenOut } from '../dsp/program.js';
4
+ import { AxSignature } from '../dsp/sig.js';
5
+ export declare class AxChainOfThought<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxGenerate<IN, OUT & {
6
+ reason: string;
7
+ }> {
8
+ constructor(ai: AxAIService, signature: Readonly<AxSignature | string>, options?: Readonly<AxGenerateOptions>);
9
+ }
package/prompts/cot.js ADDED
@@ -0,0 +1,17 @@
1
+ import { AxGenerate } from '../dsp/generate.js';
2
+ import { AxSignature } from '../dsp/sig.js';
3
+ export class AxChainOfThought extends AxGenerate {
4
+ constructor(ai, signature, options) {
5
+ const sig = new AxSignature(signature);
6
+ const description = `Let's work this out in a step by step way in order to ensure we have the right answer.`;
7
+ sig.setOutputFields([
8
+ {
9
+ name: 'reason',
10
+ description
11
+ },
12
+ ...sig.getOutputFields()
13
+ ]);
14
+ super(ai, sig, options);
15
+ }
16
+ }
17
+ //# sourceMappingURL=cot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cot.js","sourceRoot":"","sources":["../../prompts/cot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA0B,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,OAAO,gBAGX,SAAQ,UAAwC;IAChD,YACE,EAAe,EACf,SAAyC,EACzC,OAAqC;QAErC,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,wFAAwF,CAAC;QAE7G,GAAG,CAAC,eAAe,CAAC;YAClB;gBACE,IAAI,EAAE,QAAQ;gBACd,WAAW;aACZ;YACD,GAAG,GAAG,CAAC,eAAe,EAAE;SACzB,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export * from './cot.js';
2
+ export * from './react.js';
3
+ export * from './rag.js';
4
+ export * from './agent.js';
@@ -0,0 +1,5 @@
1
+ export * from './cot.js';
2
+ export * from './react.js';
3
+ export * from './rag.js';
4
+ export * from './agent.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../prompts/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { AxAIService } from '../ai/types.js';
2
+ import { type AxGenerateOptions } from '../dsp/index.js';
3
+ import { type AxProgramForwardOptions } from '../dsp/program.js';
4
+ import { AxChainOfThought } from './cot.js';
5
+ export declare class AxRAG extends AxChainOfThought<{
6
+ context: string[];
7
+ question: string;
8
+ }, {
9
+ answer: string;
10
+ }> {
11
+ private genQuery;
12
+ private queryFn;
13
+ private maxHops;
14
+ constructor(ai: AxAIService, queryFn: (query: string) => Promise<string>, options: Readonly<AxGenerateOptions & {
15
+ maxHops?: number;
16
+ }>);
17
+ forward({ question }: Readonly<{
18
+ question: string;
19
+ }>, options?: Readonly<AxProgramForwardOptions>): Promise<{
20
+ answer: string;
21
+ reason: string;
22
+ }>;
23
+ }
package/prompts/rag.js ADDED
@@ -0,0 +1,30 @@
1
+ import { AxGenerate, AxSignature, axStringUtil } from '../dsp/index.js';
2
+ import {} from '../dsp/program.js';
3
+ import { AxChainOfThought } from './cot.js';
4
+ export class AxRAG extends AxChainOfThought {
5
+ genQuery;
6
+ queryFn;
7
+ maxHops;
8
+ constructor(ai, queryFn, options) {
9
+ const sig = '"Answer questions with short factoid answers." context:string[] "may contain relevant facts", question -> answer';
10
+ super(ai, sig, options);
11
+ this.maxHops = options?.maxHops ?? 3;
12
+ const qsig = new AxSignature('"Write a simple search query that will help answer a complex question." context?:string[] "may contain relevant facts", question -> query "question to further our understanding"');
13
+ this.genQuery = new AxGenerate(ai, qsig);
14
+ this.queryFn = queryFn;
15
+ this.register(this.genQuery);
16
+ }
17
+ async forward({ question }, options) {
18
+ let context = [];
19
+ for (let i = 0; i < this.maxHops; i++) {
20
+ const { query } = await this.genQuery.forward({
21
+ context,
22
+ question
23
+ }, options);
24
+ const val = await this.queryFn(query);
25
+ context = axStringUtil.dedup([...context, val]);
26
+ }
27
+ return super.forward({ context, question }, options);
28
+ }
29
+ }
30
+ //# sourceMappingURL=rag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag.js","sourceRoot":"","sources":["../../prompts/rag.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAEV,WAAW,EACX,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAgC,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,OAAO,KAAM,SAAQ,gBAG1B;IACS,QAAQ,CAGd;IACM,OAAO,CAAqC;IAC5C,OAAO,CAAS;IAExB,YACE,EAAe,EACf,OAA2C,EAC3C,OAA2D;QAE3D,MAAM,GAAG,GACP,kHAAkH,CAAC;QACrH,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAExB,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC;QAErC,MAAM,IAAI,GAAG,IAAI,WAAW,CAC1B,mLAAmL,CACpL,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,UAAU,CAG5B,EAAE,EAAE,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAEe,KAAK,CAAC,OAAO,CAC3B,EAAE,QAAQ,EAAkC,EAC5C,OAA2C;QAE3C,IAAI,OAAO,GAAa,EAAE,CAAC;QAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC3C;gBACE,OAAO;gBACP,QAAQ;aACT,EACD,OAAO,CACR,CAAC;YACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACtC,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { AxAIService } from '../ai/index.js';
2
+ import type { AxGenerateOptions } from '../dsp/generate.js';
3
+ import type { AxGenIn, AxGenOut } from '../dsp/program.js';
4
+ import { AxSignature } from '../dsp/sig.js';
5
+ import { AxChainOfThought } from './cot.js';
6
+ export declare class AxReAct<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxChainOfThought<IN, OUT> {
7
+ constructor(ai: AxAIService, signature: Readonly<AxSignature | string>, options: Readonly<AxGenerateOptions>);
8
+ }
@@ -0,0 +1,22 @@
1
+ import { AxSignature } from '../dsp/sig.js';
2
+ import { AxChainOfThought } from './cot.js';
3
+ export class AxReAct extends AxChainOfThought {
4
+ constructor(ai, signature, options) {
5
+ if (!options?.functions || options.functions.length === 0) {
6
+ throw new Error('No functions provided');
7
+ }
8
+ const functions = [...options.functions];
9
+ const funcList = functions.map((f) => `'${f.name}'`).join(', ');
10
+ const sig = new AxSignature(signature);
11
+ sig.setDescription(`Use the provided functions ${funcList} to complete the task and return the result if any.`);
12
+ // sig.addInputField({
13
+ // name: 'observation',
14
+ // description: 'Result value from executed function',
15
+ // isOptional: true,
16
+ // type: { name: 'string', isArray: true }
17
+ // });
18
+ sig.setOutputFields(sig.getOutputFields().map((v) => ({ ...v, isOptional: true })));
19
+ super(ai, sig, options);
20
+ }
21
+ }
22
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../prompts/react.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,OAAO,OAGX,SAAQ,gBAAyB;IACjC,YACE,EAAe,EACf,SAAyC,EACzC,OAAoC;QAEpC,IAAI,CAAC,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,SAAS,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEhE,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;QACvC,GAAG,CAAC,cAAc,CAChB,8BAA8B,QAAQ,qDAAqD,CAC5F,CAAC;QAEF,sBAAsB;QACtB,yBAAyB;QACzB,wDAAwD;QACxD,sBAAsB;QACtB,4CAA4C;QAC5C,MAAM;QAEN,GAAG,CAAC,eAAe,CACjB,GAAG,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAC/D,CAAC;QAEF,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,171 @@
1
+ export declare const axSpanAttributes: {
2
+ LLM_SYSTEM: string;
3
+ LLM_REQUEST_MODEL: string;
4
+ LLM_REQUEST_MAX_TOKENS: string;
5
+ LLM_REQUEST_TEMPERATURE: string;
6
+ LLM_REQUEST_TOP_K: string;
7
+ LLM_REQUEST_FREQUENCY_PENALTY: string;
8
+ LLM_REQUEST_PRESENCE_PENALTY: string;
9
+ LLM_REQUEST_STOP_SEQUENCES: string;
10
+ LLM_REQUEST_LLM_IS_STREAMING: string;
11
+ LLM_REQUEST_TOP_P: string;
12
+ LLM_USAGE_PROMPT_TOKENS: string;
13
+ LLM_USAGE_COMPLETION_TOKENS: string;
14
+ DB_SYSTEM: string;
15
+ DB_TABLE: string;
16
+ DB_NAMESPACE: string;
17
+ DB_ID: string;
18
+ DB_QUERY_TEXT: string;
19
+ DB_VECTOR: string;
20
+ DB_OPERATION_NAME: string;
21
+ DB_VECTOR_QUERY_TOP_K: string;
22
+ DB_QUERY_EMBEDDINGS: string;
23
+ DB_QUERY_RESULT: string;
24
+ DB_QUERY_EMBEDDINGS_VECTOR: string;
25
+ DB_QUERY_RESULT_ID: string;
26
+ DB_QUERY_RESULT_SCORE: string;
27
+ DB_QUERY_RESULT_DISTANCE: string;
28
+ DB_QUERY_RESULT_METADATA: string;
29
+ DB_QUERY_RESULT_VECTOR: string;
30
+ DB_QUERY_RESULT_DOCUMENT: string;
31
+ };
32
+ export declare const axSpanEvents: {
33
+ LLM_PROMPT: string;
34
+ };
35
+ export declare enum AxLLMRequestTypeValues {
36
+ COMPLETION = "completion",
37
+ CHAT = "chat",
38
+ RERANK = "rerank",
39
+ UNKNOWN = "unknown"
40
+ }
41
+ export declare enum AxSpanKindValues {
42
+ WORKFLOW = "workflow",
43
+ TASK = "task",
44
+ AGENT = "agent",
45
+ TOOL = "tool",
46
+ UNKNOWN = "unknown"
47
+ }
48
+ export type AxSpanAttributeValue = string | number | boolean | undefined | null;
49
+ export interface AxSpanAttributes {
50
+ [key: string]: AxSpanAttributeValue;
51
+ }
52
+ export interface AxSpanTimeInput {
53
+ timestamp: number;
54
+ }
55
+ export interface AxSpanException {
56
+ message: string;
57
+ name: string;
58
+ stack?: string;
59
+ }
60
+ export interface AxSpanContext {
61
+ traceId: string;
62
+ spanId: string;
63
+ }
64
+ export declare enum AxSpanStatusCode {
65
+ OK = "OK",
66
+ ERROR = "ERROR"
67
+ }
68
+ export interface AxSpanStatus {
69
+ code: AxSpanStatusCode;
70
+ message?: string;
71
+ }
72
+ export interface AxSpanStatus {
73
+ code: AxSpanStatusCode;
74
+ description?: string;
75
+ }
76
+ export interface AxSpan {
77
+ addEvent(name: string, attributesOrStartTime?: Readonly<AxSpanAttributes | AxSpanTimeInput>, startTime?: Readonly<AxSpanTimeInput>): AxSpan;
78
+ end(endTime?: Readonly<AxSpanTimeInput>): void;
79
+ isRecording(): boolean;
80
+ recordAxSpanException(exception: Readonly<AxSpanException>, time?: Readonly<AxSpanTimeInput>): void;
81
+ setAttribute(key: string, value: AxSpanAttributeValue): AxSpan;
82
+ setAttributes(attributes: AxSpanAttributes): AxSpan;
83
+ setStatus(status: Readonly<AxSpanStatus>): AxSpan;
84
+ spanContext(): AxSpanContext;
85
+ updateName(name: string): AxSpan;
86
+ }
87
+ export interface AxContext {
88
+ /**
89
+ * Deletes a value associated with a key from the context.
90
+ * Returns a new context that inherits from the current context but does not contain the value for the specified key.
91
+ * @param key The symbol key for which to clear the value.
92
+ * @returns A new Context instance without the specified key.
93
+ */
94
+ deleteValue(key: symbol): AxContext;
95
+ /**
96
+ * Retrieves a value from the context using a symbol as the key.
97
+ * @param key The symbol key which identifies a context value.
98
+ * @returns The value associated with the key, if any; otherwise, undefined.
99
+ */
100
+ getValue(key: symbol): unknown;
101
+ /**
102
+ * Sets a value in the context for the specified key.
103
+ * Returns a new context that inherits from the current context with the new key-value pair added.
104
+ * @param key The symbol key for which to set the value.
105
+ * @param value The value to set for the given key.
106
+ * @returns A new Context instance with the updated key-value pair.
107
+ */
108
+ setValue(key: symbol, value: unknown): AxContext;
109
+ }
110
+ export declare enum AxSpanKind {
111
+ INTERNAL = "INTERNAL",
112
+ SERVER = "SERVER",
113
+ CLIENT = "CLIENT",
114
+ PRODUCER = "PRODUCER",
115
+ CONSUMER = "CONSUMER"
116
+ }
117
+ export interface AxSpanLink {
118
+ context: AxSpanContext;
119
+ attributes?: AxSpanAttributes;
120
+ }
121
+ export interface AxSpanOptions {
122
+ /**
123
+ * Optional attributes that can be attached to the AxSpan.
124
+ * @optional
125
+ */
126
+ attributes?: AxSpanAttributes;
127
+ /**
128
+ * The kind of span, defaults to AxSpanKind.INTERNAL if not specified.
129
+ * @optional
130
+ */
131
+ kind?: AxSpanKind;
132
+ /**
133
+ * AxSpanLinks that associate this new AxSpan with other AxSpans.
134
+ * @optional
135
+ */
136
+ links?: AxSpanLink[];
137
+ /**
138
+ * Indicates whether the span should be a root span, ignoring any parent span from the context.
139
+ * @optional
140
+ */
141
+ root?: boolean;
142
+ /**
143
+ * A manually specified start time for the span, if required.
144
+ * @optional
145
+ */
146
+ startTime?: AxSpanTimeInput;
147
+ }
148
+ export interface AxSpan {
149
+ setStatus(status: Readonly<AxSpanStatus>): void;
150
+ end(): void;
151
+ }
152
+ export interface AxTracer {
153
+ /**
154
+ * Starts a new AxSpan with the specified options and executes the provided function. The span is automatically closed after the function executes.
155
+ * @param name The name of the span.
156
+ * @param options AxSpan options to apply to the span.
157
+ * @param fn The function to execute within the span's context.
158
+ * @returns The return value of the function.
159
+ */
160
+ startActiveSpan<F extends (span: AxSpan) => unknown>(name: string, options: Readonly<AxSpanOptions>, fn: F): ReturnType<F>;
161
+ /**
162
+ * Starts a new AxSpan with the specified options and context, then executes the provided function. The span is automatically closed after the function executes.
163
+ * @param name The name of the span.
164
+ * @param options AxSpan options to apply to the span.
165
+ * @param context Context to be used for the span.
166
+ * @param fn The function to execute within the span's context.
167
+ * @returns The return value of the function.
168
+ */
169
+ startActiveSpan<F extends (span: AxSpan) => unknown>(name: string, options: Readonly<AxSpanOptions>, context: AxContext, fn: F): ReturnType<F>;
170
+ startSpan(name: string, options?: Readonly<AxSpanOptions>, context?: AxContext): AxSpan;
171
+ }
package/trace/index.js ADDED
@@ -0,0 +1,67 @@
1
+ export const axSpanAttributes = {
2
+ // LLM
3
+ LLM_SYSTEM: 'gen_ai.system',
4
+ LLM_REQUEST_MODEL: 'gen_ai.request.model',
5
+ LLM_REQUEST_MAX_TOKENS: 'gen_ai.request.max_tokens',
6
+ LLM_REQUEST_TEMPERATURE: 'gen_ai.request.temperature',
7
+ LLM_REQUEST_TOP_K: 'gen_ai.request.top_k',
8
+ LLM_REQUEST_FREQUENCY_PENALTY: 'gen_ai.request.frequency_penalty',
9
+ LLM_REQUEST_PRESENCE_PENALTY: 'gen_ai.request.presence_penalty',
10
+ LLM_REQUEST_STOP_SEQUENCES: 'gen_ai.request.stop_sequences',
11
+ LLM_REQUEST_LLM_IS_STREAMING: 'gen_ai.request.llm_is_streaming',
12
+ LLM_REQUEST_TOP_P: 'gen_ai.request.top_p',
13
+ LLM_USAGE_PROMPT_TOKENS: 'gen_ai.usage.prompt_tokens',
14
+ LLM_USAGE_COMPLETION_TOKENS: 'gen_ai.usage.completion_tokens',
15
+ // Vector DB
16
+ DB_SYSTEM: 'db.system',
17
+ DB_TABLE: 'db.table',
18
+ DB_NAMESPACE: 'db.namespace',
19
+ DB_ID: 'db.id',
20
+ DB_QUERY_TEXT: 'db.query.text',
21
+ DB_VECTOR: 'db.vector',
22
+ DB_OPERATION_NAME: 'db.operation.name',
23
+ DB_VECTOR_QUERY_TOP_K: 'db.vector.query.top_k',
24
+ DB_QUERY_EMBEDDINGS: 'db.query.embeddings',
25
+ DB_QUERY_RESULT: 'db.query.result',
26
+ // Query Embeddings
27
+ DB_QUERY_EMBEDDINGS_VECTOR: 'db.query.embeddings.vector',
28
+ // Query Result (canonical format)
29
+ DB_QUERY_RESULT_ID: 'db.query.result.id',
30
+ DB_QUERY_RESULT_SCORE: 'db.query.result.score',
31
+ DB_QUERY_RESULT_DISTANCE: 'db.query.result.distance',
32
+ DB_QUERY_RESULT_METADATA: 'db.query.result.metadata',
33
+ DB_QUERY_RESULT_VECTOR: 'db.query.result.vector',
34
+ DB_QUERY_RESULT_DOCUMENT: 'db.query.result.document'
35
+ };
36
+ export const axSpanEvents = {
37
+ LLM_PROMPT: 'gen_ai.prompt'
38
+ };
39
+ export var AxLLMRequestTypeValues;
40
+ (function (AxLLMRequestTypeValues) {
41
+ AxLLMRequestTypeValues["COMPLETION"] = "completion";
42
+ AxLLMRequestTypeValues["CHAT"] = "chat";
43
+ AxLLMRequestTypeValues["RERANK"] = "rerank";
44
+ AxLLMRequestTypeValues["UNKNOWN"] = "unknown";
45
+ })(AxLLMRequestTypeValues || (AxLLMRequestTypeValues = {}));
46
+ export var AxSpanKindValues;
47
+ (function (AxSpanKindValues) {
48
+ AxSpanKindValues["WORKFLOW"] = "workflow";
49
+ AxSpanKindValues["TASK"] = "task";
50
+ AxSpanKindValues["AGENT"] = "agent";
51
+ AxSpanKindValues["TOOL"] = "tool";
52
+ AxSpanKindValues["UNKNOWN"] = "unknown";
53
+ })(AxSpanKindValues || (AxSpanKindValues = {}));
54
+ export var AxSpanStatusCode;
55
+ (function (AxSpanStatusCode) {
56
+ AxSpanStatusCode["OK"] = "OK";
57
+ AxSpanStatusCode["ERROR"] = "ERROR";
58
+ })(AxSpanStatusCode || (AxSpanStatusCode = {}));
59
+ export var AxSpanKind;
60
+ (function (AxSpanKind) {
61
+ AxSpanKind["INTERNAL"] = "INTERNAL";
62
+ AxSpanKind["SERVER"] = "SERVER";
63
+ AxSpanKind["CLIENT"] = "CLIENT";
64
+ AxSpanKind["PRODUCER"] = "PRODUCER";
65
+ AxSpanKind["CONSUMER"] = "CONSUMER";
66
+ })(AxSpanKind || (AxSpanKind = {}));
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../trace/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,UAAU,EAAE,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,uCAAmB,CAAA;AACrB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAuBD,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AA2DD,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;AACvB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB"}
@@ -0,0 +1,18 @@
1
+ import { type ReadableStream } from 'stream/web';
2
+ import type { AxSpan } from '../trace/index.js';
3
+ /**
4
+ * Util: API details
5
+ * @export
6
+ */
7
+ export type API = {
8
+ name?: string;
9
+ headers?: Record<string, string>;
10
+ put?: boolean;
11
+ };
12
+ export declare const apiCall: <TRequest = unknown, TResponse = unknown>(api: Readonly<API & {
13
+ url: string | URL;
14
+ stream?: boolean;
15
+ debug?: boolean;
16
+ fetch?: typeof fetch;
17
+ span?: AxSpan;
18
+ }>, json: TRequest) => Promise<TResponse | ReadableStream<TResponse>>;