modelfusion 0.0.44

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 (405) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +429 -0
  3. package/composed-function/index.cjs +22 -0
  4. package/composed-function/index.d.ts +6 -0
  5. package/composed-function/index.js +6 -0
  6. package/composed-function/summarize/SummarizationFunction.cjs +2 -0
  7. package/composed-function/summarize/SummarizationFunction.d.ts +4 -0
  8. package/composed-function/summarize/SummarizationFunction.js +1 -0
  9. package/composed-function/summarize/summarizeRecursively.cjs +19 -0
  10. package/composed-function/summarize/summarizeRecursively.d.ts +11 -0
  11. package/composed-function/summarize/summarizeRecursively.js +15 -0
  12. package/composed-function/summarize/summarizeRecursivelyWithTextGenerationAndTokenSplitting.cjs +29 -0
  13. package/composed-function/summarize/summarizeRecursivelyWithTextGenerationAndTokenSplitting.d.ts +24 -0
  14. package/composed-function/summarize/summarizeRecursivelyWithTextGenerationAndTokenSplitting.js +25 -0
  15. package/composed-function/use-tool/NoSuchToolError.cjs +17 -0
  16. package/composed-function/use-tool/NoSuchToolError.d.ts +4 -0
  17. package/composed-function/use-tool/NoSuchToolError.js +13 -0
  18. package/composed-function/use-tool/Tool.cjs +43 -0
  19. package/composed-function/use-tool/Tool.d.ts +15 -0
  20. package/composed-function/use-tool/Tool.js +39 -0
  21. package/composed-function/use-tool/useTool.cjs +59 -0
  22. package/composed-function/use-tool/useTool.d.ts +36 -0
  23. package/composed-function/use-tool/useTool.js +54 -0
  24. package/cost/Cost.cjs +38 -0
  25. package/cost/Cost.d.ts +16 -0
  26. package/cost/Cost.js +34 -0
  27. package/cost/CostCalculator.cjs +2 -0
  28. package/cost/CostCalculator.d.ts +8 -0
  29. package/cost/CostCalculator.js +1 -0
  30. package/cost/calculateCost.cjs +28 -0
  31. package/cost/calculateCost.d.ts +7 -0
  32. package/cost/calculateCost.js +24 -0
  33. package/cost/index.cjs +19 -0
  34. package/cost/index.d.ts +3 -0
  35. package/cost/index.js +3 -0
  36. package/index.cjs +25 -0
  37. package/index.d.ts +9 -0
  38. package/index.js +9 -0
  39. package/model-function/AbstractModel.cjs +22 -0
  40. package/model-function/AbstractModel.d.ts +12 -0
  41. package/model-function/AbstractModel.js +18 -0
  42. package/model-function/FunctionOptions.cjs +2 -0
  43. package/model-function/FunctionOptions.d.ts +6 -0
  44. package/model-function/FunctionOptions.js +1 -0
  45. package/model-function/Model.cjs +2 -0
  46. package/model-function/Model.d.ts +23 -0
  47. package/model-function/Model.js +1 -0
  48. package/model-function/ModelCallEvent.cjs +2 -0
  49. package/model-function/ModelCallEvent.d.ts +18 -0
  50. package/model-function/ModelCallEvent.js +1 -0
  51. package/model-function/ModelCallEventSource.cjs +42 -0
  52. package/model-function/ModelCallEventSource.d.ts +13 -0
  53. package/model-function/ModelCallEventSource.js +38 -0
  54. package/model-function/ModelCallObserver.cjs +2 -0
  55. package/model-function/ModelCallObserver.d.ts +5 -0
  56. package/model-function/ModelCallObserver.js +1 -0
  57. package/model-function/ModelInformation.cjs +2 -0
  58. package/model-function/ModelInformation.d.ts +4 -0
  59. package/model-function/ModelInformation.js +1 -0
  60. package/model-function/SuccessfulModelCall.cjs +22 -0
  61. package/model-function/SuccessfulModelCall.d.ts +9 -0
  62. package/model-function/SuccessfulModelCall.js +18 -0
  63. package/model-function/embed-text/TextEmbeddingEvent.cjs +2 -0
  64. package/model-function/embed-text/TextEmbeddingEvent.d.ts +23 -0
  65. package/model-function/embed-text/TextEmbeddingEvent.js +1 -0
  66. package/model-function/embed-text/TextEmbeddingModel.cjs +2 -0
  67. package/model-function/embed-text/TextEmbeddingModel.d.ts +18 -0
  68. package/model-function/embed-text/TextEmbeddingModel.js +1 -0
  69. package/model-function/embed-text/embedText.cjs +90 -0
  70. package/model-function/embed-text/embedText.d.ts +33 -0
  71. package/model-function/embed-text/embedText.js +85 -0
  72. package/model-function/executeCall.cjs +60 -0
  73. package/model-function/executeCall.d.ts +27 -0
  74. package/model-function/executeCall.js +56 -0
  75. package/model-function/generate-image/ImageGenerationEvent.cjs +2 -0
  76. package/model-function/generate-image/ImageGenerationEvent.d.ts +22 -0
  77. package/model-function/generate-image/ImageGenerationEvent.js +1 -0
  78. package/model-function/generate-image/ImageGenerationModel.cjs +2 -0
  79. package/model-function/generate-image/ImageGenerationModel.d.ts +8 -0
  80. package/model-function/generate-image/ImageGenerationModel.js +1 -0
  81. package/model-function/generate-image/generateImage.cjs +63 -0
  82. package/model-function/generate-image/generateImage.d.ts +23 -0
  83. package/model-function/generate-image/generateImage.js +59 -0
  84. package/model-function/generate-json/GenerateJsonModel.cjs +2 -0
  85. package/model-function/generate-json/GenerateJsonModel.d.ts +10 -0
  86. package/model-function/generate-json/GenerateJsonModel.js +1 -0
  87. package/model-function/generate-json/GenerateJsonOrTextModel.cjs +2 -0
  88. package/model-function/generate-json/GenerateJsonOrTextModel.d.ts +18 -0
  89. package/model-function/generate-json/GenerateJsonOrTextModel.js +1 -0
  90. package/model-function/generate-json/JsonGenerationEvent.cjs +2 -0
  91. package/model-function/generate-json/JsonGenerationEvent.d.ts +22 -0
  92. package/model-function/generate-json/JsonGenerationEvent.js +1 -0
  93. package/model-function/generate-json/NoSuchSchemaError.cjs +17 -0
  94. package/model-function/generate-json/NoSuchSchemaError.d.ts +4 -0
  95. package/model-function/generate-json/NoSuchSchemaError.js +13 -0
  96. package/model-function/generate-json/SchemaDefinition.cjs +2 -0
  97. package/model-function/generate-json/SchemaDefinition.d.ts +6 -0
  98. package/model-function/generate-json/SchemaDefinition.js +1 -0
  99. package/model-function/generate-json/SchemaValidationError.cjs +36 -0
  100. package/model-function/generate-json/SchemaValidationError.d.ts +11 -0
  101. package/model-function/generate-json/SchemaValidationError.js +32 -0
  102. package/model-function/generate-json/generateJson.cjs +61 -0
  103. package/model-function/generate-json/generateJson.d.ts +9 -0
  104. package/model-function/generate-json/generateJson.js +57 -0
  105. package/model-function/generate-json/generateJsonOrText.cjs +74 -0
  106. package/model-function/generate-json/generateJsonOrText.d.ts +25 -0
  107. package/model-function/generate-json/generateJsonOrText.js +70 -0
  108. package/model-function/generate-text/AsyncQueue.cjs +66 -0
  109. package/model-function/generate-text/AsyncQueue.d.ts +17 -0
  110. package/model-function/generate-text/AsyncQueue.js +62 -0
  111. package/model-function/generate-text/DeltaEvent.cjs +2 -0
  112. package/model-function/generate-text/DeltaEvent.d.ts +7 -0
  113. package/model-function/generate-text/DeltaEvent.js +1 -0
  114. package/model-function/generate-text/TextDeltaEventSource.cjs +54 -0
  115. package/model-function/generate-text/TextDeltaEventSource.d.ts +5 -0
  116. package/model-function/generate-text/TextDeltaEventSource.js +46 -0
  117. package/model-function/generate-text/TextGenerationEvent.cjs +2 -0
  118. package/model-function/generate-text/TextGenerationEvent.d.ts +22 -0
  119. package/model-function/generate-text/TextGenerationEvent.js +1 -0
  120. package/model-function/generate-text/TextGenerationModel.cjs +2 -0
  121. package/model-function/generate-text/TextGenerationModel.d.ts +42 -0
  122. package/model-function/generate-text/TextGenerationModel.js +1 -0
  123. package/model-function/generate-text/TextStreamingEvent.cjs +2 -0
  124. package/model-function/generate-text/TextStreamingEvent.d.ts +22 -0
  125. package/model-function/generate-text/TextStreamingEvent.js +1 -0
  126. package/model-function/generate-text/extractTextDeltas.cjs +23 -0
  127. package/model-function/generate-text/extractTextDeltas.d.ts +7 -0
  128. package/model-function/generate-text/extractTextDeltas.js +19 -0
  129. package/model-function/generate-text/generateText.cjs +67 -0
  130. package/model-function/generate-text/generateText.d.ts +20 -0
  131. package/model-function/generate-text/generateText.js +63 -0
  132. package/model-function/generate-text/parseEventSourceReadableStream.cjs +30 -0
  133. package/model-function/generate-text/parseEventSourceReadableStream.d.ts +8 -0
  134. package/model-function/generate-text/parseEventSourceReadableStream.js +26 -0
  135. package/model-function/generate-text/streamText.cjs +115 -0
  136. package/model-function/generate-text/streamText.d.ts +11 -0
  137. package/model-function/generate-text/streamText.js +111 -0
  138. package/model-function/index.cjs +47 -0
  139. package/model-function/index.d.ts +31 -0
  140. package/model-function/index.js +31 -0
  141. package/model-function/tokenize-text/Tokenizer.cjs +2 -0
  142. package/model-function/tokenize-text/Tokenizer.d.ts +19 -0
  143. package/model-function/tokenize-text/Tokenizer.js +1 -0
  144. package/model-function/tokenize-text/countTokens.cjs +10 -0
  145. package/model-function/tokenize-text/countTokens.d.ts +5 -0
  146. package/model-function/tokenize-text/countTokens.js +6 -0
  147. package/model-function/transcribe-audio/TranscriptionEvent.cjs +2 -0
  148. package/model-function/transcribe-audio/TranscriptionEvent.d.ts +22 -0
  149. package/model-function/transcribe-audio/TranscriptionEvent.js +1 -0
  150. package/model-function/transcribe-audio/TranscriptionModel.cjs +2 -0
  151. package/model-function/transcribe-audio/TranscriptionModel.d.ts +8 -0
  152. package/model-function/transcribe-audio/TranscriptionModel.js +1 -0
  153. package/model-function/transcribe-audio/transcribe.cjs +62 -0
  154. package/model-function/transcribe-audio/transcribe.d.ts +22 -0
  155. package/model-function/transcribe-audio/transcribe.js +58 -0
  156. package/model-provider/automatic1111/Automatic1111Error.cjs +39 -0
  157. package/model-provider/automatic1111/Automatic1111Error.d.ts +31 -0
  158. package/model-provider/automatic1111/Automatic1111Error.js +31 -0
  159. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +76 -0
  160. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +54 -0
  161. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +72 -0
  162. package/model-provider/automatic1111/index.cjs +20 -0
  163. package/model-provider/automatic1111/index.d.ts +2 -0
  164. package/model-provider/automatic1111/index.js +2 -0
  165. package/model-provider/cohere/CohereError.cjs +36 -0
  166. package/model-provider/cohere/CohereError.d.ts +22 -0
  167. package/model-provider/cohere/CohereError.js +28 -0
  168. package/model-provider/cohere/CohereTextEmbeddingModel.cjs +172 -0
  169. package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +119 -0
  170. package/model-provider/cohere/CohereTextEmbeddingModel.js +165 -0
  171. package/model-provider/cohere/CohereTextGenerationModel.cjs +283 -0
  172. package/model-provider/cohere/CohereTextGenerationModel.d.ts +203 -0
  173. package/model-provider/cohere/CohereTextGenerationModel.js +276 -0
  174. package/model-provider/cohere/CohereTokenizer.cjs +136 -0
  175. package/model-provider/cohere/CohereTokenizer.d.ts +118 -0
  176. package/model-provider/cohere/CohereTokenizer.js +129 -0
  177. package/model-provider/cohere/index.cjs +22 -0
  178. package/model-provider/cohere/index.d.ts +4 -0
  179. package/model-provider/cohere/index.js +4 -0
  180. package/model-provider/huggingface/HuggingFaceError.cjs +52 -0
  181. package/model-provider/huggingface/HuggingFaceError.d.ts +22 -0
  182. package/model-provider/huggingface/HuggingFaceError.js +44 -0
  183. package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +174 -0
  184. package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +75 -0
  185. package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +167 -0
  186. package/model-provider/huggingface/index.cjs +20 -0
  187. package/model-provider/huggingface/index.d.ts +2 -0
  188. package/model-provider/huggingface/index.js +2 -0
  189. package/model-provider/index.cjs +22 -0
  190. package/model-provider/index.d.ts +6 -0
  191. package/model-provider/index.js +6 -0
  192. package/model-provider/llamacpp/LlamaCppError.cjs +52 -0
  193. package/model-provider/llamacpp/LlamaCppError.d.ts +22 -0
  194. package/model-provider/llamacpp/LlamaCppError.js +44 -0
  195. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +96 -0
  196. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +40 -0
  197. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +89 -0
  198. package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +245 -0
  199. package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +399 -0
  200. package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +238 -0
  201. package/model-provider/llamacpp/LlamaCppTokenizer.cjs +64 -0
  202. package/model-provider/llamacpp/LlamaCppTokenizer.d.ts +38 -0
  203. package/model-provider/llamacpp/LlamaCppTokenizer.js +57 -0
  204. package/model-provider/llamacpp/index.cjs +22 -0
  205. package/model-provider/llamacpp/index.d.ts +4 -0
  206. package/model-provider/llamacpp/index.js +4 -0
  207. package/model-provider/openai/OpenAICostCalculator.cjs +71 -0
  208. package/model-provider/openai/OpenAICostCalculator.d.ts +6 -0
  209. package/model-provider/openai/OpenAICostCalculator.js +67 -0
  210. package/model-provider/openai/OpenAIError.cjs +50 -0
  211. package/model-provider/openai/OpenAIError.d.ts +47 -0
  212. package/model-provider/openai/OpenAIError.js +42 -0
  213. package/model-provider/openai/OpenAIImageGenerationModel.cjs +124 -0
  214. package/model-provider/openai/OpenAIImageGenerationModel.d.ts +113 -0
  215. package/model-provider/openai/OpenAIImageGenerationModel.js +119 -0
  216. package/model-provider/openai/OpenAIModelSettings.cjs +2 -0
  217. package/model-provider/openai/OpenAIModelSettings.d.ts +8 -0
  218. package/model-provider/openai/OpenAIModelSettings.js +1 -0
  219. package/model-provider/openai/OpenAITextEmbeddingModel.cjs +171 -0
  220. package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +122 -0
  221. package/model-provider/openai/OpenAITextEmbeddingModel.js +162 -0
  222. package/model-provider/openai/OpenAITextGenerationModel.cjs +326 -0
  223. package/model-provider/openai/OpenAITextGenerationModel.d.ts +254 -0
  224. package/model-provider/openai/OpenAITextGenerationModel.js +317 -0
  225. package/model-provider/openai/OpenAITranscriptionModel.cjs +195 -0
  226. package/model-provider/openai/OpenAITranscriptionModel.d.ts +196 -0
  227. package/model-provider/openai/OpenAITranscriptionModel.js +187 -0
  228. package/model-provider/openai/TikTokenTokenizer.cjs +86 -0
  229. package/model-provider/openai/TikTokenTokenizer.d.ts +35 -0
  230. package/model-provider/openai/TikTokenTokenizer.js +82 -0
  231. package/model-provider/openai/chat/OpenAIChatMessage.cjs +24 -0
  232. package/model-provider/openai/chat/OpenAIChatMessage.d.ts +26 -0
  233. package/model-provider/openai/chat/OpenAIChatMessage.js +21 -0
  234. package/model-provider/openai/chat/OpenAIChatModel.cjs +288 -0
  235. package/model-provider/openai/chat/OpenAIChatModel.d.ts +344 -0
  236. package/model-provider/openai/chat/OpenAIChatModel.js +279 -0
  237. package/model-provider/openai/chat/OpenAIChatPrompt.cjs +143 -0
  238. package/model-provider/openai/chat/OpenAIChatPrompt.d.ts +108 -0
  239. package/model-provider/openai/chat/OpenAIChatPrompt.js +135 -0
  240. package/model-provider/openai/chat/OpenAIChatStreamIterable.cjs +112 -0
  241. package/model-provider/openai/chat/OpenAIChatStreamIterable.d.ts +19 -0
  242. package/model-provider/openai/chat/OpenAIChatStreamIterable.js +105 -0
  243. package/model-provider/openai/chat/countOpenAIChatMessageTokens.cjs +28 -0
  244. package/model-provider/openai/chat/countOpenAIChatMessageTokens.d.ts +20 -0
  245. package/model-provider/openai/chat/countOpenAIChatMessageTokens.js +23 -0
  246. package/model-provider/openai/index.cjs +31 -0
  247. package/model-provider/openai/index.d.ts +13 -0
  248. package/model-provider/openai/index.js +12 -0
  249. package/model-provider/stability/StabilityError.cjs +36 -0
  250. package/model-provider/stability/StabilityError.d.ts +22 -0
  251. package/model-provider/stability/StabilityError.js +28 -0
  252. package/model-provider/stability/StabilityImageGenerationModel.cjs +133 -0
  253. package/model-provider/stability/StabilityImageGenerationModel.d.ts +95 -0
  254. package/model-provider/stability/StabilityImageGenerationModel.js +129 -0
  255. package/model-provider/stability/index.cjs +20 -0
  256. package/model-provider/stability/index.d.ts +2 -0
  257. package/model-provider/stability/index.js +2 -0
  258. package/package.json +87 -0
  259. package/prompt/InstructionPrompt.cjs +2 -0
  260. package/prompt/InstructionPrompt.d.ts +7 -0
  261. package/prompt/InstructionPrompt.js +1 -0
  262. package/prompt/Llama2PromptMapping.cjs +56 -0
  263. package/prompt/Llama2PromptMapping.d.ts +10 -0
  264. package/prompt/Llama2PromptMapping.js +51 -0
  265. package/prompt/OpenAIChatPromptMapping.cjs +62 -0
  266. package/prompt/OpenAIChatPromptMapping.d.ts +6 -0
  267. package/prompt/OpenAIChatPromptMapping.js +57 -0
  268. package/prompt/PromptMapping.cjs +2 -0
  269. package/prompt/PromptMapping.d.ts +7 -0
  270. package/prompt/PromptMapping.js +1 -0
  271. package/prompt/PromptMappingTextGenerationModel.cjs +88 -0
  272. package/prompt/PromptMappingTextGenerationModel.d.ts +26 -0
  273. package/prompt/PromptMappingTextGenerationModel.js +84 -0
  274. package/prompt/TextPromptMapping.cjs +50 -0
  275. package/prompt/TextPromptMapping.d.ts +14 -0
  276. package/prompt/TextPromptMapping.js +45 -0
  277. package/prompt/chat/ChatPrompt.cjs +2 -0
  278. package/prompt/chat/ChatPrompt.d.ts +33 -0
  279. package/prompt/chat/ChatPrompt.js +1 -0
  280. package/prompt/chat/trimChatPrompt.cjs +50 -0
  281. package/prompt/chat/trimChatPrompt.d.ts +19 -0
  282. package/prompt/chat/trimChatPrompt.js +46 -0
  283. package/prompt/chat/validateChatPrompt.cjs +36 -0
  284. package/prompt/chat/validateChatPrompt.d.ts +8 -0
  285. package/prompt/chat/validateChatPrompt.js +31 -0
  286. package/prompt/index.cjs +25 -0
  287. package/prompt/index.d.ts +9 -0
  288. package/prompt/index.js +9 -0
  289. package/run/ConsoleLogger.cjs +12 -0
  290. package/run/ConsoleLogger.d.ts +6 -0
  291. package/run/ConsoleLogger.js +8 -0
  292. package/run/DefaultRun.cjs +78 -0
  293. package/run/DefaultRun.d.ts +24 -0
  294. package/run/DefaultRun.js +74 -0
  295. package/run/IdMetadata.cjs +2 -0
  296. package/run/IdMetadata.d.ts +7 -0
  297. package/run/IdMetadata.js +1 -0
  298. package/run/Run.cjs +2 -0
  299. package/run/Run.d.ts +27 -0
  300. package/run/Run.js +1 -0
  301. package/run/RunFunction.cjs +2 -0
  302. package/run/RunFunction.d.ts +13 -0
  303. package/run/RunFunction.js +1 -0
  304. package/run/Vector.cjs +2 -0
  305. package/run/Vector.d.ts +5 -0
  306. package/run/Vector.js +1 -0
  307. package/run/index.cjs +22 -0
  308. package/run/index.d.ts +6 -0
  309. package/run/index.js +6 -0
  310. package/text-chunk/TextChunk.cjs +2 -0
  311. package/text-chunk/TextChunk.d.ts +3 -0
  312. package/text-chunk/TextChunk.js +1 -0
  313. package/text-chunk/index.cjs +22 -0
  314. package/text-chunk/index.d.ts +6 -0
  315. package/text-chunk/index.js +6 -0
  316. package/text-chunk/retrieve-text-chunks/TextChunkRetriever.cjs +2 -0
  317. package/text-chunk/retrieve-text-chunks/TextChunkRetriever.d.ts +8 -0
  318. package/text-chunk/retrieve-text-chunks/TextChunkRetriever.js +1 -0
  319. package/text-chunk/retrieve-text-chunks/retrieveTextChunks.cjs +10 -0
  320. package/text-chunk/retrieve-text-chunks/retrieveTextChunks.d.ts +6 -0
  321. package/text-chunk/retrieve-text-chunks/retrieveTextChunks.js +6 -0
  322. package/text-chunk/split/SplitFunction.cjs +2 -0
  323. package/text-chunk/split/SplitFunction.d.ts +4 -0
  324. package/text-chunk/split/SplitFunction.js +1 -0
  325. package/text-chunk/split/splitOnSeparator.cjs +12 -0
  326. package/text-chunk/split/splitOnSeparator.d.ts +8 -0
  327. package/text-chunk/split/splitOnSeparator.js +7 -0
  328. package/text-chunk/split/splitRecursively.cjs +41 -0
  329. package/text-chunk/split/splitRecursively.d.ts +22 -0
  330. package/text-chunk/split/splitRecursively.js +33 -0
  331. package/util/DurationMeasurement.cjs +42 -0
  332. package/util/DurationMeasurement.d.ts +5 -0
  333. package/util/DurationMeasurement.js +38 -0
  334. package/util/ErrorHandler.cjs +2 -0
  335. package/util/ErrorHandler.d.ts +1 -0
  336. package/util/ErrorHandler.js +1 -0
  337. package/util/SafeResult.cjs +2 -0
  338. package/util/SafeResult.d.ts +8 -0
  339. package/util/SafeResult.js +1 -0
  340. package/util/api/AbortError.cjs +9 -0
  341. package/util/api/AbortError.d.ts +3 -0
  342. package/util/api/AbortError.js +5 -0
  343. package/util/api/ApiCallError.cjs +45 -0
  344. package/util/api/ApiCallError.d.ts +15 -0
  345. package/util/api/ApiCallError.js +41 -0
  346. package/util/api/RetryError.cjs +24 -0
  347. package/util/api/RetryError.d.ts +10 -0
  348. package/util/api/RetryError.js +20 -0
  349. package/util/api/RetryFunction.cjs +2 -0
  350. package/util/api/RetryFunction.d.ts +1 -0
  351. package/util/api/RetryFunction.js +1 -0
  352. package/util/api/ThrottleFunction.cjs +2 -0
  353. package/util/api/ThrottleFunction.d.ts +1 -0
  354. package/util/api/ThrottleFunction.js +1 -0
  355. package/util/api/callWithRetryAndThrottle.cjs +7 -0
  356. package/util/api/callWithRetryAndThrottle.d.ts +7 -0
  357. package/util/api/callWithRetryAndThrottle.js +3 -0
  358. package/util/api/postToApi.cjs +103 -0
  359. package/util/api/postToApi.d.ts +29 -0
  360. package/util/api/postToApi.js +96 -0
  361. package/util/api/retryNever.cjs +8 -0
  362. package/util/api/retryNever.d.ts +4 -0
  363. package/util/api/retryNever.js +4 -0
  364. package/util/api/retryWithExponentialBackoff.cjs +48 -0
  365. package/util/api/retryWithExponentialBackoff.d.ts +10 -0
  366. package/util/api/retryWithExponentialBackoff.js +44 -0
  367. package/util/api/throttleMaxConcurrency.cjs +65 -0
  368. package/util/api/throttleMaxConcurrency.d.ts +7 -0
  369. package/util/api/throttleMaxConcurrency.js +61 -0
  370. package/util/api/throttleUnlimitedConcurrency.cjs +8 -0
  371. package/util/api/throttleUnlimitedConcurrency.d.ts +5 -0
  372. package/util/api/throttleUnlimitedConcurrency.js +4 -0
  373. package/util/cosineSimilarity.cjs +26 -0
  374. package/util/cosineSimilarity.d.ts +11 -0
  375. package/util/cosineSimilarity.js +22 -0
  376. package/util/index.cjs +26 -0
  377. package/util/index.d.ts +10 -0
  378. package/util/index.js +10 -0
  379. package/util/never.cjs +6 -0
  380. package/util/never.d.ts +1 -0
  381. package/util/never.js +2 -0
  382. package/util/runSafe.cjs +15 -0
  383. package/util/runSafe.d.ts +2 -0
  384. package/util/runSafe.js +11 -0
  385. package/vector-index/VectorIndex.cjs +2 -0
  386. package/vector-index/VectorIndex.d.ts +18 -0
  387. package/vector-index/VectorIndex.js +1 -0
  388. package/vector-index/VectorIndexSimilarTextChunkRetriever.cjs +57 -0
  389. package/vector-index/VectorIndexSimilarTextChunkRetriever.d.ts +20 -0
  390. package/vector-index/VectorIndexSimilarTextChunkRetriever.js +53 -0
  391. package/vector-index/VectorIndexTextChunkStore.cjs +77 -0
  392. package/vector-index/VectorIndexTextChunkStore.d.ts +35 -0
  393. package/vector-index/VectorIndexTextChunkStore.js +73 -0
  394. package/vector-index/index.cjs +22 -0
  395. package/vector-index/index.d.ts +6 -0
  396. package/vector-index/index.js +6 -0
  397. package/vector-index/memory/MemoryVectorIndex.cjs +63 -0
  398. package/vector-index/memory/MemoryVectorIndex.d.ts +31 -0
  399. package/vector-index/memory/MemoryVectorIndex.js +56 -0
  400. package/vector-index/pinecone/PineconeVectorIndex.cjs +66 -0
  401. package/vector-index/pinecone/PineconeVectorIndex.d.ts +29 -0
  402. package/vector-index/pinecone/PineconeVectorIndex.js +62 -0
  403. package/vector-index/upsertTextChunks.cjs +15 -0
  404. package/vector-index/upsertTextChunks.d.ts +11 -0
  405. package/vector-index/upsertTextChunks.js +11 -0
@@ -0,0 +1,13 @@
1
+ export class NoSuchToolError extends Error {
2
+ constructor(toolName) {
3
+ super(`No such tool: ${toolName}`);
4
+ Object.defineProperty(this, "toolName", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: void 0
9
+ });
10
+ this.name = "NoSuchToolError";
11
+ this.toolName = toolName;
12
+ }
13
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tool = void 0;
4
+ class Tool {
5
+ constructor(options) {
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "description", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "inputSchema", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "execute", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ this.name = options.name;
31
+ this.description = options.description;
32
+ this.inputSchema = options.inputSchema;
33
+ this.execute = options.execute;
34
+ }
35
+ get inputSchemaDefinition() {
36
+ return {
37
+ name: this.name,
38
+ description: this.description,
39
+ schema: this.inputSchema,
40
+ };
41
+ }
42
+ }
43
+ exports.Tool = Tool;
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { SchemaDefinition } from "../../model-function/generate-json/SchemaDefinition.js";
3
+ export declare class Tool<NAME extends string, INPUT, OUTPUT> {
4
+ readonly name: NAME;
5
+ readonly description: string;
6
+ readonly inputSchema: z.ZodSchema<INPUT>;
7
+ readonly execute: (input: INPUT) => PromiseLike<OUTPUT>;
8
+ constructor(options: {
9
+ name: NAME;
10
+ description: string;
11
+ inputSchema: z.ZodSchema<INPUT>;
12
+ execute(input: INPUT): Promise<OUTPUT>;
13
+ });
14
+ get inputSchemaDefinition(): SchemaDefinition<NAME, INPUT>;
15
+ }
@@ -0,0 +1,39 @@
1
+ export class Tool {
2
+ constructor(options) {
3
+ Object.defineProperty(this, "name", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "description", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "inputSchema", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ Object.defineProperty(this, "execute", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ this.name = options.name;
28
+ this.description = options.description;
29
+ this.inputSchema = options.inputSchema;
30
+ this.execute = options.execute;
31
+ }
32
+ get inputSchemaDefinition() {
33
+ return {
34
+ name: this.name,
35
+ description: this.description,
36
+ schema: this.inputSchema,
37
+ };
38
+ }
39
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useToolOrGenerateText = exports.useTool = void 0;
4
+ const generateJson_js_1 = require("../../model-function/generate-json/generateJson.cjs");
5
+ const generateJsonOrText_js_1 = require("../../model-function/generate-json/generateJsonOrText.cjs");
6
+ const NoSuchToolError_js_1 = require("./NoSuchToolError.cjs");
7
+ // In this file, using 'any' is required to allow for flexibility in the inputs. The actual types are
8
+ // retrieved through lookups such as TOOL["name"], such that any does not affect any client.
9
+ /* eslint-disable @typescript-eslint/no-explicit-any */
10
+ /**
11
+ * `useTool` uses `generateJson` to generate parameters for a tool and then executes the tool with the parameters.
12
+ *
13
+ * @returns The result contains the name of the tool (`tool` property),
14
+ * the parameters (`parameters` property, typed),
15
+ * and the result of the tool execution (`result` property, typed).
16
+ */
17
+ async function useTool(model, tool, prompt, options) {
18
+ const { value } = await (0, generateJson_js_1.generateJson)(model, {
19
+ name: tool.name,
20
+ description: tool.description,
21
+ schema: tool.inputSchema,
22
+ }, () => prompt(tool), options);
23
+ return {
24
+ tool: tool.name,
25
+ parameters: value,
26
+ result: await tool.execute(value),
27
+ };
28
+ }
29
+ exports.useTool = useTool;
30
+ async function useToolOrGenerateText(model, tools, prompt, options) {
31
+ const expandedPrompt = prompt(tools);
32
+ const modelResponse = await (0, generateJsonOrText_js_1.generateJsonOrText)(model, tools.map((tool) => ({
33
+ name: tool.name,
34
+ description: tool.description,
35
+ schema: tool.inputSchema,
36
+ })), () => expandedPrompt, options);
37
+ const { schema, text } = modelResponse;
38
+ if (schema == null) {
39
+ return {
40
+ tool: null,
41
+ parameters: null,
42
+ result: null,
43
+ text,
44
+ };
45
+ }
46
+ const tool = tools.find((tool) => tool.name === schema);
47
+ if (tool == null) {
48
+ throw new NoSuchToolError_js_1.NoSuchToolError(schema.toString());
49
+ }
50
+ const toolParameters = modelResponse.value;
51
+ const result = await tool.execute(toolParameters);
52
+ return {
53
+ tool: schema,
54
+ result,
55
+ parameters: toolParameters,
56
+ text: text, // string | null is the expected value here
57
+ };
58
+ }
59
+ exports.useToolOrGenerateText = useToolOrGenerateText;
@@ -0,0 +1,36 @@
1
+ import { FunctionOptions } from "../../model-function/FunctionOptions.js";
2
+ import { GenerateJsonModel, GenerateJsonModelSettings, GenerateJsonPrompt } from "../../model-function/generate-json/GenerateJsonModel.js";
3
+ import { GenerateJsonOrTextModel, GenerateJsonOrTextModelSettings, GenerateJsonOrTextPrompt } from "../../model-function/generate-json/GenerateJsonOrTextModel.js";
4
+ import { Tool } from "./Tool.js";
5
+ /**
6
+ * `useTool` uses `generateJson` to generate parameters for a tool and then executes the tool with the parameters.
7
+ *
8
+ * @returns The result contains the name of the tool (`tool` property),
9
+ * the parameters (`parameters` property, typed),
10
+ * and the result of the tool execution (`result` property, typed).
11
+ */
12
+ export declare function useTool<PROMPT, RESPONSE, SETTINGS extends GenerateJsonModelSettings, TOOL extends Tool<any, any, any>>(model: GenerateJsonModel<PROMPT, RESPONSE, SETTINGS>, tool: TOOL, prompt: (tool: TOOL) => PROMPT & GenerateJsonPrompt<RESPONSE>, options?: FunctionOptions<SETTINGS>): Promise<{
13
+ tool: TOOL["name"];
14
+ parameters: TOOL["inputSchema"];
15
+ result: Awaited<ReturnType<TOOL["execute"]>>;
16
+ }>;
17
+ type ToolArray<T extends Tool<any, any, any>[]> = T;
18
+ type ToToolMap<T extends ToolArray<Tool<any, any, any>[]>> = {
19
+ [K in T[number]["name"]]: Extract<T[number], Tool<K, any, any>>;
20
+ };
21
+ type ToToolUnion<T> = {
22
+ [KEY in keyof T]: T[KEY] extends Tool<any, infer INPUT, infer OUTPUT> ? {
23
+ tool: KEY;
24
+ parameters: INPUT;
25
+ result: OUTPUT;
26
+ text: string | null;
27
+ } : never;
28
+ }[keyof T];
29
+ type ToOutputValue<TOOLS extends ToolArray<Tool<any, any, any>[]>> = ToToolUnion<ToToolMap<TOOLS>>;
30
+ export declare function useToolOrGenerateText<PROMPT, RESPONSE, SETTINGS extends GenerateJsonOrTextModelSettings, TOOLS extends Array<Tool<any, any, any>>>(model: GenerateJsonOrTextModel<PROMPT, RESPONSE, SETTINGS>, tools: TOOLS, prompt: (tools: TOOLS) => PROMPT & GenerateJsonOrTextPrompt<RESPONSE>, options?: FunctionOptions<SETTINGS>): Promise<{
31
+ tool: null;
32
+ parameters: null;
33
+ result: null;
34
+ text: string;
35
+ } | ToOutputValue<TOOLS>>;
36
+ export {};
@@ -0,0 +1,54 @@
1
+ import { generateJson } from "../../model-function/generate-json/generateJson.js";
2
+ import { generateJsonOrText } from "../../model-function/generate-json/generateJsonOrText.js";
3
+ import { NoSuchToolError } from "./NoSuchToolError.js";
4
+ // In this file, using 'any' is required to allow for flexibility in the inputs. The actual types are
5
+ // retrieved through lookups such as TOOL["name"], such that any does not affect any client.
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ /**
8
+ * `useTool` uses `generateJson` to generate parameters for a tool and then executes the tool with the parameters.
9
+ *
10
+ * @returns The result contains the name of the tool (`tool` property),
11
+ * the parameters (`parameters` property, typed),
12
+ * and the result of the tool execution (`result` property, typed).
13
+ */
14
+ export async function useTool(model, tool, prompt, options) {
15
+ const { value } = await generateJson(model, {
16
+ name: tool.name,
17
+ description: tool.description,
18
+ schema: tool.inputSchema,
19
+ }, () => prompt(tool), options);
20
+ return {
21
+ tool: tool.name,
22
+ parameters: value,
23
+ result: await tool.execute(value),
24
+ };
25
+ }
26
+ export async function useToolOrGenerateText(model, tools, prompt, options) {
27
+ const expandedPrompt = prompt(tools);
28
+ const modelResponse = await generateJsonOrText(model, tools.map((tool) => ({
29
+ name: tool.name,
30
+ description: tool.description,
31
+ schema: tool.inputSchema,
32
+ })), () => expandedPrompt, options);
33
+ const { schema, text } = modelResponse;
34
+ if (schema == null) {
35
+ return {
36
+ tool: null,
37
+ parameters: null,
38
+ result: null,
39
+ text,
40
+ };
41
+ }
42
+ const tool = tools.find((tool) => tool.name === schema);
43
+ if (tool == null) {
44
+ throw new NoSuchToolError(schema.toString());
45
+ }
46
+ const toolParameters = modelResponse.value;
47
+ const result = await tool.execute(toolParameters);
48
+ return {
49
+ tool: schema,
50
+ result,
51
+ parameters: toolParameters,
52
+ text: text, // string | null is the expected value here
53
+ };
54
+ }
package/cost/Cost.cjs ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cost = void 0;
4
+ class Cost {
5
+ constructor({ costInMillicents, hasUnknownCost, callsWithUnknownCost, }) {
6
+ Object.defineProperty(this, "costInMillicents", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "hasUnknownCost", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "callsWithUnknownCost", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ this.costInMillicents = costInMillicents;
25
+ this.hasUnknownCost = hasUnknownCost;
26
+ this.callsWithUnknownCost = callsWithUnknownCost;
27
+ }
28
+ get costInCent() {
29
+ return this.costInMillicents / 1000;
30
+ }
31
+ get costInDollar() {
32
+ return this.costInCent / 100;
33
+ }
34
+ formatAsDollarAmount({ decimals = 2 } = {}) {
35
+ return `$${this.costInDollar.toFixed(decimals)}`;
36
+ }
37
+ }
38
+ exports.Cost = Cost;
package/cost/Cost.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { SuccessfulModelCall } from "../model-function/SuccessfulModelCall.js";
2
+ export declare class Cost {
3
+ readonly costInMillicents: number;
4
+ readonly hasUnknownCost: boolean;
5
+ readonly callsWithUnknownCost: SuccessfulModelCall[];
6
+ constructor({ costInMillicents, hasUnknownCost, callsWithUnknownCost, }: {
7
+ costInMillicents: number;
8
+ hasUnknownCost: boolean;
9
+ callsWithUnknownCost: SuccessfulModelCall[];
10
+ });
11
+ get costInCent(): number;
12
+ get costInDollar(): number;
13
+ formatAsDollarAmount({ decimals }?: {
14
+ decimals?: number;
15
+ }): string;
16
+ }
package/cost/Cost.js ADDED
@@ -0,0 +1,34 @@
1
+ export class Cost {
2
+ constructor({ costInMillicents, hasUnknownCost, callsWithUnknownCost, }) {
3
+ Object.defineProperty(this, "costInMillicents", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "hasUnknownCost", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "callsWithUnknownCost", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ this.costInMillicents = costInMillicents;
22
+ this.hasUnknownCost = hasUnknownCost;
23
+ this.callsWithUnknownCost = callsWithUnknownCost;
24
+ }
25
+ get costInCent() {
26
+ return this.costInMillicents / 1000;
27
+ }
28
+ get costInDollar() {
29
+ return this.costInCent / 100;
30
+ }
31
+ formatAsDollarAmount({ decimals = 2 } = {}) {
32
+ return `$${this.costInDollar.toFixed(decimals)}`;
33
+ }
34
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { SuccessfulModelCall } from "../model-function/SuccessfulModelCall.js";
2
+ export interface CostCalculator {
3
+ readonly provider: string;
4
+ /**
5
+ * @return null if the cost is unknown, otherwise the cost in Millicents (0 if free)
6
+ */
7
+ calculateCostInMillicents(call: SuccessfulModelCall): PromiseLike<number | null>;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateCost = void 0;
4
+ const Cost_js_1 = require("./Cost.cjs");
5
+ async function calculateCost({ calls, costCalculators, }) {
6
+ let costInMillicents = 0;
7
+ const callsWithUnknownCost = [];
8
+ for (const call of calls) {
9
+ const model = call.model;
10
+ const providerCostCalculator = costCalculators.find((providerCostCalculator) => providerCostCalculator.provider === model.provider);
11
+ if (!providerCostCalculator) {
12
+ callsWithUnknownCost.push(call);
13
+ continue;
14
+ }
15
+ const cost = await providerCostCalculator.calculateCostInMillicents(call);
16
+ if (cost === null) {
17
+ callsWithUnknownCost.push(call);
18
+ continue;
19
+ }
20
+ costInMillicents += cost;
21
+ }
22
+ return new Cost_js_1.Cost({
23
+ costInMillicents,
24
+ hasUnknownCost: callsWithUnknownCost.length > 0,
25
+ callsWithUnknownCost,
26
+ });
27
+ }
28
+ exports.calculateCost = calculateCost;
@@ -0,0 +1,7 @@
1
+ import { Cost } from "./Cost.js";
2
+ import { CostCalculator } from "./CostCalculator.js";
3
+ import { SuccessfulModelCall } from "../model-function/SuccessfulModelCall.js";
4
+ export declare function calculateCost({ calls, costCalculators, }: {
5
+ calls: SuccessfulModelCall[];
6
+ costCalculators: CostCalculator[];
7
+ }): Promise<Cost>;
@@ -0,0 +1,24 @@
1
+ import { Cost } from "./Cost.js";
2
+ export async function calculateCost({ calls, costCalculators, }) {
3
+ let costInMillicents = 0;
4
+ const callsWithUnknownCost = [];
5
+ for (const call of calls) {
6
+ const model = call.model;
7
+ const providerCostCalculator = costCalculators.find((providerCostCalculator) => providerCostCalculator.provider === model.provider);
8
+ if (!providerCostCalculator) {
9
+ callsWithUnknownCost.push(call);
10
+ continue;
11
+ }
12
+ const cost = await providerCostCalculator.calculateCostInMillicents(call);
13
+ if (cost === null) {
14
+ callsWithUnknownCost.push(call);
15
+ continue;
16
+ }
17
+ costInMillicents += cost;
18
+ }
19
+ return new Cost({
20
+ costInMillicents,
21
+ hasUnknownCost: callsWithUnknownCost.length > 0,
22
+ callsWithUnknownCost,
23
+ });
24
+ }
package/cost/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Cost.cjs"), exports);
18
+ __exportStar(require("./calculateCost.cjs"), exports);
19
+ __exportStar(require("./CostCalculator.cjs"), exports);
@@ -0,0 +1,3 @@
1
+ export * from "./Cost.js";
2
+ export * from "./calculateCost.js";
3
+ export * from "./CostCalculator.js";
package/cost/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./Cost.js";
2
+ export * from "./calculateCost.js";
3
+ export * from "./CostCalculator.js";
package/index.cjs ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./composed-function/index.cjs"), exports);
18
+ __exportStar(require("./cost/index.cjs"), exports);
19
+ __exportStar(require("./model-function/index.cjs"), exports);
20
+ __exportStar(require("./model-provider/index.cjs"), exports);
21
+ __exportStar(require("./prompt/index.cjs"), exports);
22
+ __exportStar(require("./run/index.cjs"), exports);
23
+ __exportStar(require("./text-chunk/index.cjs"), exports);
24
+ __exportStar(require("./util/index.cjs"), exports);
25
+ __exportStar(require("./vector-index/index.cjs"), exports);
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./composed-function/index.js";
2
+ export * from "./cost/index.js";
3
+ export * from "./model-function/index.js";
4
+ export * from "./model-provider/index.js";
5
+ export * from "./prompt/index.js";
6
+ export * from "./run/index.js";
7
+ export * from "./text-chunk/index.js";
8
+ export * from "./util/index.js";
9
+ export * from "./vector-index/index.js";
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./composed-function/index.js";
2
+ export * from "./cost/index.js";
3
+ export * from "./model-function/index.js";
4
+ export * from "./model-provider/index.js";
5
+ export * from "./prompt/index.js";
6
+ export * from "./run/index.js";
7
+ export * from "./text-chunk/index.js";
8
+ export * from "./util/index.js";
9
+ export * from "./vector-index/index.js";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractModel = void 0;
4
+ class AbstractModel {
5
+ constructor({ settings }) {
6
+ Object.defineProperty(this, "settings", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ this.settings = settings;
13
+ }
14
+ // implemented as a separate accessor to remove all other properties from the model
15
+ get modelInformation() {
16
+ return {
17
+ provider: this.provider,
18
+ modelName: this.modelName,
19
+ };
20
+ }
21
+ }
22
+ exports.AbstractModel = AbstractModel;
@@ -0,0 +1,12 @@
1
+ import { ModelInformation } from "./ModelInformation.js";
2
+ import { Model, ModelSettings } from "./Model.js";
3
+ export declare abstract class AbstractModel<SETTINGS extends ModelSettings> implements Model<SETTINGS> {
4
+ constructor({ settings }: {
5
+ settings: SETTINGS;
6
+ });
7
+ abstract readonly provider: string;
8
+ abstract readonly modelName: string | null;
9
+ get modelInformation(): ModelInformation;
10
+ readonly settings: SETTINGS;
11
+ abstract withSettings(additionalSettings: Partial<SETTINGS>): this;
12
+ }
@@ -0,0 +1,18 @@
1
+ export class AbstractModel {
2
+ constructor({ settings }) {
3
+ Object.defineProperty(this, "settings", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ this.settings = settings;
10
+ }
11
+ // implemented as a separate accessor to remove all other properties from the model
12
+ get modelInformation() {
13
+ return {
14
+ provider: this.provider,
15
+ modelName: this.modelName,
16
+ };
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { Run } from "../run/Run.js";
2
+ export interface FunctionOptions<SETTINGS> {
3
+ functionId?: string;
4
+ settings?: Partial<SETTINGS>;
5
+ run?: Run;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { ModelInformation } from "./ModelInformation.js";
2
+ import { ModelCallObserver } from "./ModelCallObserver.js";
3
+ export interface ModelSettings {
4
+ observers?: Array<ModelCallObserver>;
5
+ }
6
+ export interface Model<SETTINGS> {
7
+ modelInformation: ModelInformation;
8
+ readonly settings: SETTINGS;
9
+ /**
10
+ * The `withSettings` method creates a new model with the same configuration as the original model, but with the specified settings changed.
11
+ *
12
+ * @example
13
+ * const model = new OpenAITextGenerationModel({
14
+ * model: "text-davinci-003",
15
+ * maxTokens: 500,
16
+ * });
17
+ *
18
+ * const modelWithMoreTokens = model.withSettings({
19
+ * maxTokens: 1000,
20
+ * });
21
+ */
22
+ withSettings(additionalSettings: Partial<SETTINGS>): this;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { IdMetadata } from "../run/IdMetadata.js";
2
+ import { ModelInformation } from "./ModelInformation.js";
3
+ import { TextEmbeddingFinishedEvent, TextEmbeddingStartedEvent } from "./embed-text/TextEmbeddingEvent.js";
4
+ import { ImageGenerationFinishedEvent, ImageGenerationStartedEvent } from "./generate-image/ImageGenerationEvent.js";
5
+ import { JsonGenerationFinishedEvent, JsonGenerationStartedEvent } from "./generate-json/JsonGenerationEvent.js";
6
+ import { TextGenerationFinishedEvent, TextGenerationStartedEvent } from "./generate-text/TextGenerationEvent.js";
7
+ import { TextStreamingFinishedEvent, TextStreamingStartedEvent } from "./generate-text/TextStreamingEvent.js";
8
+ import { TranscriptionFinishedEvent, TranscriptionStartedEvent } from "./transcribe-audio/TranscriptionEvent.js";
9
+ export type ModelCallEvent = ModelCallStartedEvent | ModelCallFinishedEvent;
10
+ export type ModelCallStartedEventMetadata = IdMetadata & {
11
+ model: ModelInformation;
12
+ startEpochSeconds: number;
13
+ };
14
+ export type ModelCallStartedEvent = ImageGenerationStartedEvent | JsonGenerationStartedEvent | TextEmbeddingStartedEvent | TextGenerationStartedEvent | TextStreamingStartedEvent | TranscriptionStartedEvent;
15
+ export type ModelCallFinishedEventMetadata = ModelCallStartedEventMetadata & {
16
+ durationInMs: number;
17
+ };
18
+ export type ModelCallFinishedEvent = ImageGenerationFinishedEvent | JsonGenerationFinishedEvent | TextEmbeddingFinishedEvent | TextGenerationFinishedEvent | TextStreamingFinishedEvent | TranscriptionFinishedEvent;
@@ -0,0 +1 @@
1
+ export {};