modelfusion 0.110.0 → 0.112.0

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 (283) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +41 -65
  3. package/core/FunctionEvent.d.ts +3 -3
  4. package/core/api/ApiFacade.cjs +20 -0
  5. package/core/api/ApiFacade.d.ts +4 -0
  6. package/core/api/ApiFacade.js +4 -0
  7. package/core/api/BaseUrlApiConfiguration.cjs +47 -5
  8. package/core/api/BaseUrlApiConfiguration.d.ts +23 -6
  9. package/core/api/BaseUrlApiConfiguration.js +45 -4
  10. package/core/api/BaseUrlApiConfiguration.test.cjs +11 -0
  11. package/core/api/BaseUrlApiConfiguration.test.js +9 -0
  12. package/core/api/callWithRetryAndThrottle.cjs +3 -3
  13. package/core/api/callWithRetryAndThrottle.js +3 -3
  14. package/core/api/index.cjs +15 -2
  15. package/core/api/index.d.ts +2 -2
  16. package/core/api/index.js +2 -2
  17. package/core/api/postToApi.cjs +28 -5
  18. package/core/api/postToApi.d.ts +5 -4
  19. package/core/api/postToApi.js +26 -4
  20. package/core/api/throttleOff.cjs +8 -0
  21. package/core/api/throttleOff.d.ts +5 -0
  22. package/core/api/throttleOff.js +4 -0
  23. package/internal/index.cjs +2 -8
  24. package/internal/index.d.ts +1 -1
  25. package/internal/index.js +1 -1
  26. package/model-function/ModelCallEvent.d.ts +3 -3
  27. package/model-function/generate-structure/generateStructure.d.ts +1 -1
  28. package/model-function/generate-text/PromptTemplateFullTextModel.cjs +2 -2
  29. package/model-function/generate-text/PromptTemplateFullTextModel.d.ts +3 -3
  30. package/model-function/generate-text/PromptTemplateFullTextModel.js +2 -2
  31. package/model-function/generate-text/PromptTemplateTextGenerationModel.cjs +2 -2
  32. package/model-function/generate-text/PromptTemplateTextGenerationModel.d.ts +3 -3
  33. package/model-function/generate-text/PromptTemplateTextGenerationModel.js +2 -2
  34. package/model-provider/anthropic/AnthropicApiConfiguration.cjs +14 -6
  35. package/model-provider/anthropic/AnthropicApiConfiguration.d.ts +7 -8
  36. package/model-provider/anthropic/AnthropicApiConfiguration.js +15 -7
  37. package/model-provider/anthropic/AnthropicError.cjs +7 -27
  38. package/model-provider/anthropic/AnthropicError.d.ts +21 -16
  39. package/model-provider/anthropic/AnthropicError.js +7 -25
  40. package/model-provider/anthropic/AnthropicFacade.cjs +10 -1
  41. package/model-provider/anthropic/AnthropicFacade.d.ts +9 -0
  42. package/model-provider/anthropic/AnthropicFacade.js +8 -0
  43. package/model-provider/anthropic/AnthropicTextGenerationModel.cjs +22 -24
  44. package/model-provider/anthropic/AnthropicTextGenerationModel.js +23 -25
  45. package/model-provider/anthropic/index.cjs +1 -4
  46. package/model-provider/anthropic/index.d.ts +1 -1
  47. package/model-provider/anthropic/index.js +0 -1
  48. package/model-provider/automatic1111/Automatic1111ApiConfiguration.cjs +12 -4
  49. package/model-provider/automatic1111/Automatic1111ApiConfiguration.d.ts +3 -3
  50. package/model-provider/automatic1111/Automatic1111ApiConfiguration.js +12 -4
  51. package/model-provider/automatic1111/Automatic1111Error.cjs +3 -3
  52. package/model-provider/automatic1111/Automatic1111Error.d.ts +13 -3
  53. package/model-provider/automatic1111/Automatic1111Error.js +4 -4
  54. package/model-provider/automatic1111/Automatic1111Facade.cjs +9 -9
  55. package/model-provider/automatic1111/Automatic1111Facade.d.ts +6 -6
  56. package/model-provider/automatic1111/Automatic1111Facade.js +7 -7
  57. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +11 -7
  58. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +11 -7
  59. package/model-provider/cohere/CohereApiConfiguration.cjs +14 -6
  60. package/model-provider/cohere/CohereApiConfiguration.d.ts +7 -8
  61. package/model-provider/cohere/CohereApiConfiguration.js +15 -7
  62. package/model-provider/cohere/CohereError.cjs +8 -43
  63. package/model-provider/cohere/CohereError.d.ts +9 -16
  64. package/model-provider/cohere/CohereError.js +8 -41
  65. package/model-provider/cohere/CohereFacade.cjs +12 -3
  66. package/model-provider/cohere/CohereFacade.d.ts +11 -2
  67. package/model-provider/cohere/CohereFacade.js +10 -2
  68. package/model-provider/cohere/CohereTextEmbeddingModel.cjs +18 -22
  69. package/model-provider/cohere/CohereTextEmbeddingModel.js +18 -22
  70. package/model-provider/cohere/CohereTextGenerationModel.cjs +31 -39
  71. package/model-provider/cohere/CohereTextGenerationModel.d.ts +110 -8
  72. package/model-provider/cohere/CohereTextGenerationModel.js +31 -39
  73. package/model-provider/cohere/CohereTokenizer.cjs +32 -41
  74. package/model-provider/cohere/CohereTokenizer.d.ts +2 -2
  75. package/model-provider/cohere/CohereTokenizer.js +32 -41
  76. package/model-provider/cohere/index.cjs +1 -3
  77. package/model-provider/cohere/index.d.ts +1 -1
  78. package/model-provider/cohere/index.js +0 -1
  79. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.cjs +14 -6
  80. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.d.ts +7 -8
  81. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.js +15 -7
  82. package/model-provider/elevenlabs/ElevenLabsFacade.cjs +10 -1
  83. package/model-provider/elevenlabs/ElevenLabsFacade.d.ts +9 -0
  84. package/model-provider/elevenlabs/ElevenLabsFacade.js +8 -0
  85. package/model-provider/elevenlabs/ElevenLabsSpeechModel.cjs +42 -53
  86. package/model-provider/elevenlabs/ElevenLabsSpeechModel.js +44 -55
  87. package/model-provider/huggingface/HuggingFaceApiConfiguration.cjs +14 -6
  88. package/model-provider/huggingface/HuggingFaceApiConfiguration.d.ts +7 -8
  89. package/model-provider/huggingface/HuggingFaceApiConfiguration.js +15 -7
  90. package/model-provider/huggingface/HuggingFaceError.cjs +7 -29
  91. package/model-provider/huggingface/HuggingFaceError.d.ts +9 -16
  92. package/model-provider/huggingface/HuggingFaceError.js +7 -27
  93. package/model-provider/huggingface/HuggingFaceFacade.cjs +10 -1
  94. package/model-provider/huggingface/HuggingFaceFacade.d.ts +9 -0
  95. package/model-provider/huggingface/HuggingFaceFacade.js +8 -0
  96. package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +17 -27
  97. package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +17 -27
  98. package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +22 -23
  99. package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +22 -23
  100. package/model-provider/huggingface/index.cjs +1 -3
  101. package/model-provider/huggingface/index.d.ts +1 -1
  102. package/model-provider/huggingface/index.js +0 -1
  103. package/model-provider/llamacpp/LlamaCppApiConfiguration.cjs +13 -6
  104. package/model-provider/llamacpp/LlamaCppApiConfiguration.d.ts +7 -9
  105. package/model-provider/llamacpp/LlamaCppApiConfiguration.js +14 -7
  106. package/model-provider/llamacpp/LlamaCppCompletionModel.cjs +4 -4
  107. package/model-provider/llamacpp/LlamaCppCompletionModel.d.ts +173 -5
  108. package/model-provider/llamacpp/LlamaCppCompletionModel.js +4 -4
  109. package/model-provider/llamacpp/LlamaCppError.cjs +7 -27
  110. package/model-provider/llamacpp/LlamaCppError.d.ts +9 -16
  111. package/model-provider/llamacpp/LlamaCppError.js +7 -25
  112. package/model-provider/llamacpp/LlamaCppFacade.cjs +10 -2
  113. package/model-provider/llamacpp/LlamaCppFacade.d.ts +8 -1
  114. package/model-provider/llamacpp/LlamaCppFacade.js +8 -1
  115. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +10 -14
  116. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +10 -14
  117. package/model-provider/llamacpp/LlamaCppTokenizer.cjs +14 -18
  118. package/model-provider/llamacpp/LlamaCppTokenizer.js +14 -18
  119. package/model-provider/llamacpp/index.cjs +1 -3
  120. package/model-provider/llamacpp/index.d.ts +1 -1
  121. package/model-provider/llamacpp/index.js +0 -1
  122. package/model-provider/lmnt/LmntApiConfiguration.cjs +14 -6
  123. package/model-provider/lmnt/LmntApiConfiguration.d.ts +7 -8
  124. package/model-provider/lmnt/LmntApiConfiguration.js +15 -7
  125. package/model-provider/lmnt/LmntFacade.cjs +11 -2
  126. package/model-provider/lmnt/LmntFacade.d.ts +10 -1
  127. package/model-provider/lmnt/LmntFacade.js +9 -1
  128. package/model-provider/lmnt/LmntSpeechModel.cjs +53 -41
  129. package/model-provider/lmnt/LmntSpeechModel.d.ts +51 -3
  130. package/model-provider/lmnt/LmntSpeechModel.js +54 -42
  131. package/model-provider/mistral/MistralApiConfiguration.cjs +14 -6
  132. package/model-provider/mistral/MistralApiConfiguration.d.ts +9 -11
  133. package/model-provider/mistral/MistralApiConfiguration.js +15 -7
  134. package/model-provider/mistral/MistralChatModel.cjs +4 -4
  135. package/model-provider/mistral/MistralChatModel.d.ts +52 -7
  136. package/model-provider/mistral/MistralChatModel.js +5 -5
  137. package/model-provider/mistral/MistralError.cjs +3 -3
  138. package/model-provider/mistral/MistralError.d.ts +15 -3
  139. package/model-provider/mistral/MistralError.js +4 -4
  140. package/model-provider/mistral/MistralFacade.cjs +5 -1
  141. package/model-provider/mistral/MistralFacade.d.ts +10 -3
  142. package/model-provider/mistral/MistralFacade.js +6 -2
  143. package/model-provider/mistral/MistralTextEmbeddingModel.cjs +2 -1
  144. package/model-provider/mistral/MistralTextEmbeddingModel.d.ts +3 -3
  145. package/model-provider/mistral/MistralTextEmbeddingModel.js +2 -1
  146. package/model-provider/ollama/OllamaApiConfiguration.cjs +13 -6
  147. package/model-provider/ollama/OllamaApiConfiguration.d.ts +7 -10
  148. package/model-provider/ollama/OllamaApiConfiguration.js +14 -7
  149. package/model-provider/ollama/OllamaChatModel.cjs +6 -6
  150. package/model-provider/ollama/OllamaChatModel.d.ts +49 -8
  151. package/model-provider/ollama/OllamaChatModel.js +7 -7
  152. package/model-provider/ollama/OllamaCompletionModel.cjs +6 -6
  153. package/model-provider/ollama/OllamaCompletionModel.d.ts +43 -8
  154. package/model-provider/ollama/OllamaCompletionModel.js +7 -7
  155. package/model-provider/ollama/OllamaError.cjs +3 -3
  156. package/model-provider/ollama/OllamaError.d.ts +7 -3
  157. package/model-provider/ollama/OllamaError.js +4 -4
  158. package/model-provider/ollama/OllamaFacade.cjs +6 -2
  159. package/model-provider/ollama/OllamaFacade.d.ts +8 -3
  160. package/model-provider/ollama/OllamaFacade.js +6 -2
  161. package/model-provider/ollama/OllamaTextEmbeddingModel.cjs +15 -16
  162. package/model-provider/ollama/OllamaTextEmbeddingModel.js +15 -16
  163. package/model-provider/openai/AbstractOpenAIChatModel.cjs +5 -5
  164. package/model-provider/openai/AbstractOpenAIChatModel.d.ts +155 -9
  165. package/model-provider/openai/AbstractOpenAIChatModel.js +5 -5
  166. package/model-provider/openai/AbstractOpenAICompletionModel.cjs +30 -32
  167. package/model-provider/openai/AbstractOpenAICompletionModel.d.ts +4 -4
  168. package/model-provider/openai/AbstractOpenAICompletionModel.js +30 -32
  169. package/model-provider/openai/AzureOpenAIApiConfiguration.d.ts +9 -8
  170. package/model-provider/openai/OpenAIApiConfiguration.cjs +14 -6
  171. package/model-provider/openai/OpenAIApiConfiguration.d.ts +7 -8
  172. package/model-provider/openai/OpenAIApiConfiguration.js +15 -7
  173. package/model-provider/openai/OpenAIChatFunctionCallStructureGenerationModel.d.ts +1 -1
  174. package/model-provider/openai/OpenAIChatModel.d.ts +2 -2
  175. package/model-provider/openai/OpenAIError.cjs +8 -8
  176. package/model-provider/openai/OpenAIError.d.ts +27 -3
  177. package/model-provider/openai/OpenAIError.js +9 -9
  178. package/model-provider/openai/OpenAIFacade.cjs +23 -2
  179. package/model-provider/openai/OpenAIFacade.d.ts +20 -2
  180. package/model-provider/openai/OpenAIFacade.js +20 -1
  181. package/model-provider/openai/OpenAIImageGenerationModel.cjs +20 -21
  182. package/model-provider/openai/OpenAIImageGenerationModel.js +20 -21
  183. package/model-provider/openai/OpenAISpeechModel.cjs +17 -22
  184. package/model-provider/openai/OpenAISpeechModel.js +17 -22
  185. package/model-provider/openai/OpenAITextEmbeddingModel.cjs +18 -23
  186. package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +3 -3
  187. package/model-provider/openai/OpenAITextEmbeddingModel.js +18 -23
  188. package/model-provider/openai/OpenAITranscriptionModel.cjs +42 -48
  189. package/model-provider/openai/OpenAITranscriptionModel.d.ts +14 -10
  190. package/model-provider/openai/OpenAITranscriptionModel.js +42 -48
  191. package/model-provider/openai-compatible/FireworksAIApiConfiguration.cjs +11 -7
  192. package/model-provider/openai-compatible/FireworksAIApiConfiguration.d.ts +4 -9
  193. package/model-provider/openai-compatible/FireworksAIApiConfiguration.js +12 -8
  194. package/model-provider/openai-compatible/OpenAICompatibleChatModel.d.ts +2 -2
  195. package/model-provider/openai-compatible/OpenAICompatibleFacade.cjs +25 -1
  196. package/model-provider/openai-compatible/OpenAICompatibleFacade.d.ts +23 -0
  197. package/model-provider/openai-compatible/OpenAICompatibleFacade.js +22 -0
  198. package/model-provider/openai-compatible/TogetherAIApiConfiguration.cjs +11 -7
  199. package/model-provider/openai-compatible/TogetherAIApiConfiguration.d.ts +4 -9
  200. package/model-provider/openai-compatible/TogetherAIApiConfiguration.js +12 -8
  201. package/model-provider/stability/StabilityApiConfiguration.cjs +13 -12
  202. package/model-provider/stability/StabilityApiConfiguration.d.ts +4 -4
  203. package/model-provider/stability/StabilityApiConfiguration.js +13 -12
  204. package/model-provider/stability/StabilityError.cjs +3 -3
  205. package/model-provider/stability/StabilityError.d.ts +7 -3
  206. package/model-provider/stability/StabilityError.js +4 -4
  207. package/model-provider/stability/StabilityFacade.cjs +9 -9
  208. package/model-provider/stability/StabilityFacade.d.ts +8 -8
  209. package/model-provider/stability/StabilityFacade.js +7 -7
  210. package/model-provider/stability/StabilityImageGenerationModel.cjs +2 -1
  211. package/model-provider/stability/StabilityImageGenerationModel.js +2 -1
  212. package/model-provider/whispercpp/WhisperCppApiConfiguration.cjs +13 -6
  213. package/model-provider/whispercpp/WhisperCppApiConfiguration.d.ts +7 -10
  214. package/model-provider/whispercpp/WhisperCppApiConfiguration.js +14 -7
  215. package/model-provider/whispercpp/WhisperCppFacade.cjs +9 -5
  216. package/model-provider/whispercpp/WhisperCppFacade.d.ts +7 -2
  217. package/model-provider/whispercpp/WhisperCppFacade.js +8 -4
  218. package/model-provider/whispercpp/WhisperCppTranscriptionModel.cjs +5 -2
  219. package/model-provider/whispercpp/WhisperCppTranscriptionModel.js +6 -3
  220. package/package.json +1 -1
  221. package/tool/Tool.cjs +0 -10
  222. package/tool/Tool.d.ts +0 -1
  223. package/tool/Tool.js +0 -10
  224. package/tool/WebSearchTool.cjs +2 -2
  225. package/tool/WebSearchTool.d.ts +1 -2
  226. package/tool/WebSearchTool.js +3 -3
  227. package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.cjs → generate-tool-calls/TextGenerationToolCallsModel.cjs} +7 -7
  228. package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.d.ts → generate-tool-calls/TextGenerationToolCallsModel.d.ts} +6 -6
  229. package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.js → generate-tool-calls/TextGenerationToolCallsModel.js} +5 -5
  230. package/tool/generate-tool-calls/ToolCallsGenerationEvent.d.ts +23 -0
  231. package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.d.ts → generate-tool-calls/ToolCallsGenerationModel.d.ts} +3 -3
  232. package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.cjs → generate-tool-calls/ToolCallsParseError.cjs} +5 -5
  233. package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.d.ts → generate-tool-calls/ToolCallsParseError.d.ts} +1 -1
  234. package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.js → generate-tool-calls/ToolCallsParseError.js} +3 -3
  235. package/tool/{generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.d.ts → generate-tool-calls/ToolCallsPromptTemplate.d.ts} +1 -1
  236. package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.cjs → generate-tool-calls/generateToolCalls.cjs} +5 -5
  237. package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.d.ts → generate-tool-calls/generateToolCalls.d.ts} +3 -3
  238. package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.js → generate-tool-calls/generateToolCalls.js} +3 -3
  239. package/tool/{generate-tool-calls-or-text → generate-tool-calls}/index.cjs +6 -6
  240. package/tool/generate-tool-calls/index.d.ts +6 -0
  241. package/tool/generate-tool-calls/index.js +6 -0
  242. package/tool/index.cjs +2 -3
  243. package/tool/index.d.ts +2 -3
  244. package/tool/index.js +2 -3
  245. package/tool/use-tools/UseToolsEvent.d.ts +7 -0
  246. package/tool/use-tools/UseToolsEvent.js +1 -0
  247. package/tool/{use-tools-or-generate-text → use-tools}/index.cjs +2 -2
  248. package/tool/use-tools/index.d.ts +2 -0
  249. package/tool/use-tools/index.js +2 -0
  250. package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.cjs → use-tools/useTools.cjs} +6 -6
  251. package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.d.ts → use-tools/useTools.d.ts} +2 -2
  252. package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.js → use-tools/useTools.js} +4 -4
  253. package/vector-index/memory/MemoryVectorIndex.cjs +2 -2
  254. package/vector-index/memory/MemoryVectorIndex.js +3 -3
  255. package/core/api/BaseUrlPartsApiConfiguration.cjs +0 -53
  256. package/core/api/BaseUrlPartsApiConfiguration.d.ts +0 -26
  257. package/core/api/BaseUrlPartsApiConfiguration.js +0 -49
  258. package/core/api/throttleUnlimitedConcurrency.cjs +0 -8
  259. package/core/api/throttleUnlimitedConcurrency.d.ts +0 -5
  260. package/core/api/throttleUnlimitedConcurrency.js +0 -4
  261. package/model-provider/elevenlabs/ElevenLabsError.cjs +0 -30
  262. package/model-provider/elevenlabs/ElevenLabsError.d.ts +0 -3
  263. package/model-provider/elevenlabs/ElevenLabsError.js +0 -26
  264. package/model-provider/lmnt/LmntError.cjs +0 -30
  265. package/model-provider/lmnt/LmntError.d.ts +0 -3
  266. package/model-provider/lmnt/LmntError.js +0 -26
  267. package/tool/InvalidToolNameError.cjs +0 -17
  268. package/tool/InvalidToolNameError.d.ts +0 -7
  269. package/tool/InvalidToolNameError.js +0 -13
  270. package/tool/generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.d.ts +0 -23
  271. package/tool/generate-tool-calls-or-text/index.d.ts +0 -6
  272. package/tool/generate-tool-calls-or-text/index.js +0 -6
  273. package/tool/use-tools-or-generate-text/UseToolsOrGenerateTextEvent.d.ts +0 -7
  274. package/tool/use-tools-or-generate-text/index.d.ts +0 -2
  275. package/tool/use-tools-or-generate-text/index.js +0 -2
  276. /package/{tool/generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.js → core/api/BaseUrlApiConfiguration.test.d.ts} +0 -0
  277. /package/tool/{generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.cjs → generate-tool-calls/ToolCallsGenerationEvent.cjs} +0 -0
  278. /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.js → generate-tool-calls/ToolCallsGenerationEvent.js} +0 -0
  279. /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.cjs → generate-tool-calls/ToolCallsGenerationModel.cjs} +0 -0
  280. /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.js → generate-tool-calls/ToolCallsGenerationModel.js} +0 -0
  281. /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.cjs → generate-tool-calls/ToolCallsPromptTemplate.cjs} +0 -0
  282. /package/tool/{use-tools-or-generate-text/UseToolsOrGenerateTextEvent.js → generate-tool-calls/ToolCallsPromptTemplate.js} +0 -0
  283. /package/tool/{use-tools-or-generate-text/UseToolsOrGenerateTextEvent.cjs → use-tools/UseToolsEvent.cjs} +0 -0
@@ -1,28 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StabilityApiConfiguration = void 0;
4
- const BaseUrlPartsApiConfiguration_js_1 = require("../../core/api/BaseUrlPartsApiConfiguration.cjs");
4
+ const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
5
5
  const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
6
6
  /**
7
7
  * Creates an API configuration for the Stability AI API.
8
- * It calls the API at https://api.stability.ai/v1 by default.
8
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
9
9
  */
10
- class StabilityApiConfiguration extends BaseUrlPartsApiConfiguration_js_1.BaseUrlPartsApiConfiguration {
11
- constructor({ protocol = "https", host = "api.stability.ai", port = "443", path = "/v1", apiKey, headers, retry, throttle, } = {}) {
10
+ class StabilityApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfigurationWithDefaults {
11
+ constructor(settings = {}) {
12
12
  super({
13
- protocol,
14
- host,
15
- port,
16
- path,
17
- headers: headers ?? {
13
+ ...settings,
14
+ headers: settings.headers ?? {
18
15
  Authorization: `Bearer ${(0, loadApiKey_js_1.loadApiKey)({
19
- apiKey,
16
+ apiKey: settings.apiKey,
20
17
  environmentVariableName: "STABILITY_API_KEY",
21
18
  description: "Stability",
22
19
  })}`,
23
20
  },
24
- retry,
25
- throttle,
21
+ baseUrlDefaults: {
22
+ protocol: "https",
23
+ host: "api.stability.ai",
24
+ port: "443",
25
+ path: "/v1",
26
+ },
26
27
  });
27
28
  }
28
29
  }
@@ -1,10 +1,10 @@
1
- import { BaseUrlPartsApiConfiguration, BaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlPartsApiConfiguration.js";
1
+ import { BaseUrlApiConfigurationWithDefaults, PartialBaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlApiConfiguration.js";
2
2
  /**
3
3
  * Creates an API configuration for the Stability AI API.
4
- * It calls the API at https://api.stability.ai/v1 by default.
4
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
5
5
  */
6
- export declare class StabilityApiConfiguration extends BaseUrlPartsApiConfiguration {
7
- constructor({ protocol, host, port, path, apiKey, headers, retry, throttle, }?: Partial<BaseUrlPartsApiConfigurationOptions> & {
6
+ export declare class StabilityApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
7
+ constructor(settings?: PartialBaseUrlPartsApiConfigurationOptions & {
8
8
  apiKey?: string;
9
9
  });
10
10
  }
@@ -1,25 +1,26 @@
1
- import { BaseUrlPartsApiConfiguration, } from "../../core/api/BaseUrlPartsApiConfiguration.js";
1
+ import { BaseUrlApiConfigurationWithDefaults, } from "../../core/api/BaseUrlApiConfiguration.js";
2
2
  import { loadApiKey } from "../../core/api/loadApiKey.js";
3
3
  /**
4
4
  * Creates an API configuration for the Stability AI API.
5
- * It calls the API at https://api.stability.ai/v1 by default.
5
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
6
6
  */
7
- export class StabilityApiConfiguration extends BaseUrlPartsApiConfiguration {
8
- constructor({ protocol = "https", host = "api.stability.ai", port = "443", path = "/v1", apiKey, headers, retry, throttle, } = {}) {
7
+ export class StabilityApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
8
+ constructor(settings = {}) {
9
9
  super({
10
- protocol,
11
- host,
12
- port,
13
- path,
14
- headers: headers ?? {
10
+ ...settings,
11
+ headers: settings.headers ?? {
15
12
  Authorization: `Bearer ${loadApiKey({
16
- apiKey,
13
+ apiKey: settings.apiKey,
17
14
  environmentVariableName: "STABILITY_API_KEY",
18
15
  description: "Stability",
19
16
  })}`,
20
17
  },
21
- retry,
22
- throttle,
18
+ baseUrlDefaults: {
19
+ protocol: "https",
20
+ host: "api.stability.ai",
21
+ port: "443",
22
+ path: "/v1",
23
+ },
23
24
  });
24
25
  }
25
26
  }
@@ -4,10 +4,10 @@ exports.failedStabilityCallResponseHandler = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const postToApi_js_1 = require("../../core/api/postToApi.cjs");
6
6
  const ZodSchema_js_1 = require("../../core/schema/ZodSchema.cjs");
7
- const stabilityErrorDataSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
7
+ const stabilityErrorDataSchema = zod_1.z.object({
8
8
  message: zod_1.z.string(),
9
- }));
9
+ });
10
10
  exports.failedStabilityCallResponseHandler = (0, postToApi_js_1.createJsonErrorResponseHandler)({
11
- errorSchema: stabilityErrorDataSchema,
11
+ errorSchema: (0, ZodSchema_js_1.zodSchema)(stabilityErrorDataSchema),
12
12
  errorToMessage: (error) => error.message,
13
13
  });
@@ -1,9 +1,13 @@
1
+ import { z } from "zod";
1
2
  import { ApiCallError } from "../../core/api/ApiCallError.js";
2
3
  import { ResponseHandler } from "../../core/api/postToApi.js";
3
- import { ZodSchema } from "../../core/schema/ZodSchema.js";
4
- declare const stabilityErrorDataSchema: ZodSchema<{
4
+ declare const stabilityErrorDataSchema: z.ZodObject<{
5
+ message: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ message: string;
8
+ }, {
5
9
  message: string;
6
10
  }>;
7
- export type StabilityErrorData = (typeof stabilityErrorDataSchema)["_type"];
11
+ export type StabilityErrorData = z.infer<typeof stabilityErrorDataSchema>;
8
12
  export declare const failedStabilityCallResponseHandler: ResponseHandler<ApiCallError>;
9
13
  export {};
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { createJsonErrorResponseHandler, } from "../../core/api/postToApi.js";
3
- import { ZodSchema } from "../../core/schema/ZodSchema.js";
4
- const stabilityErrorDataSchema = new ZodSchema(z.object({
3
+ import { zodSchema } from "../../core/schema/ZodSchema.js";
4
+ const stabilityErrorDataSchema = z.object({
5
5
  message: z.string(),
6
- }));
6
+ });
7
7
  export const failedStabilityCallResponseHandler = createJsonErrorResponseHandler({
8
- errorSchema: stabilityErrorDataSchema,
8
+ errorSchema: zodSchema(stabilityErrorDataSchema),
9
9
  errorToMessage: (error) => error.message,
10
10
  });
@@ -1,8 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Api = exports.ImageGenerator = void 0;
3
+ exports.ImageGenerator = exports.Api = void 0;
4
4
  const StabilityApiConfiguration_js_1 = require("./StabilityApiConfiguration.cjs");
5
5
  const StabilityImageGenerationModel_js_1 = require("./StabilityImageGenerationModel.cjs");
6
+ /**
7
+ * Creates an API configuration for the Stability AI API.
8
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
9
+ */
10
+ function Api(settings) {
11
+ return new StabilityApiConfiguration_js_1.StabilityApiConfiguration(settings);
12
+ }
13
+ exports.Api = Api;
6
14
  /**
7
15
  * Create an image generation model that calls the Stability AI image generation API.
8
16
  *
@@ -30,11 +38,3 @@ function ImageGenerator(settings) {
30
38
  return new StabilityImageGenerationModel_js_1.StabilityImageGenerationModel(settings);
31
39
  }
32
40
  exports.ImageGenerator = ImageGenerator;
33
- /**
34
- * Creates an API configuration for the Stability AI API.
35
- * It calls the API at https://api.stability.ai/v1 by default.
36
- */
37
- function Api(settings) {
38
- return new StabilityApiConfiguration_js_1.StabilityApiConfiguration(settings);
39
- }
40
- exports.Api = Api;
@@ -1,6 +1,13 @@
1
- import { BaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlPartsApiConfiguration.js";
1
+ import { BaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlApiConfiguration.js";
2
2
  import { StabilityApiConfiguration } from "./StabilityApiConfiguration.js";
3
3
  import { StabilityImageGenerationModel, StabilityImageGenerationSettings } from "./StabilityImageGenerationModel.js";
4
+ /**
5
+ * Creates an API configuration for the Stability AI API.
6
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
7
+ */
8
+ export declare function Api(settings: Partial<BaseUrlPartsApiConfigurationOptions> & {
9
+ apiKey?: string;
10
+ }): StabilityApiConfiguration;
4
11
  /**
5
12
  * Create an image generation model that calls the Stability AI image generation API.
6
13
  *
@@ -25,10 +32,3 @@ import { StabilityImageGenerationModel, StabilityImageGenerationSettings } from
25
32
  * @returns A new instance of {@link StabilityImageGenerationModel}.
26
33
  */
27
34
  export declare function ImageGenerator(settings: StabilityImageGenerationSettings): StabilityImageGenerationModel;
28
- /**
29
- * Creates an API configuration for the Stability AI API.
30
- * It calls the API at https://api.stability.ai/v1 by default.
31
- */
32
- export declare function Api(settings: Partial<BaseUrlPartsApiConfigurationOptions> & {
33
- apiKey?: string;
34
- }): StabilityApiConfiguration;
@@ -1,5 +1,12 @@
1
1
  import { StabilityApiConfiguration } from "./StabilityApiConfiguration.js";
2
2
  import { StabilityImageGenerationModel, } from "./StabilityImageGenerationModel.js";
3
+ /**
4
+ * Creates an API configuration for the Stability AI API.
5
+ * It calls the API at https://api.stability.ai/v1 by default and uses the `STABILITY_API_KEY` environment variable.
6
+ */
7
+ export function Api(settings) {
8
+ return new StabilityApiConfiguration(settings);
9
+ }
3
10
  /**
4
11
  * Create an image generation model that calls the Stability AI image generation API.
5
12
  *
@@ -26,10 +33,3 @@ import { StabilityImageGenerationModel, } from "./StabilityImageGenerationModel.
26
33
  export function ImageGenerator(settings) {
27
34
  return new StabilityImageGenerationModel(settings);
28
35
  }
29
- /**
30
- * Creates an API configuration for the Stability AI API.
31
- * It calls the API at https://api.stability.ai/v1 by default.
32
- */
33
- export function Api(settings) {
34
- return new StabilityApiConfiguration(settings);
35
- }
@@ -4,6 +4,7 @@ exports.StabilityImageGenerationModel = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
6
6
  const postToApi_js_1 = require("../../core/api/postToApi.cjs");
7
+ const ZodSchema_js_1 = require("../../core/schema/ZodSchema.cjs");
7
8
  const AbstractModel_js_1 = require("../../model-function/AbstractModel.cjs");
8
9
  const PromptTemplateImageGenerationModel_js_1 = require("../../model-function/generate-image/PromptTemplateImageGenerationModel.cjs");
9
10
  const StabilityApiConfiguration_js_1 = require("./StabilityApiConfiguration.cjs");
@@ -69,7 +70,7 @@ class StabilityImageGenerationModel extends AbstractModel_js_1.AbstractModel {
69
70
  style_preset: this.settings.stylePreset,
70
71
  },
71
72
  failedResponseHandler: StabilityError_js_1.failedStabilityCallResponseHandler,
72
- successfulResponseHandler: (0, postToApi_js_1.createJsonResponseHandler)(stabilityImageGenerationResponseSchema),
73
+ successfulResponseHandler: (0, postToApi_js_1.createJsonResponseHandler)((0, ZodSchema_js_1.zodSchema)(stabilityImageGenerationResponseSchema)),
73
74
  abortSignal,
74
75
  }),
75
76
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
3
3
  import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
4
+ import { zodSchema } from "../../core/schema/ZodSchema.js";
4
5
  import { AbstractModel } from "../../model-function/AbstractModel.js";
5
6
  import { PromptTemplateImageGenerationModel } from "../../model-function/generate-image/PromptTemplateImageGenerationModel.js";
6
7
  import { StabilityApiConfiguration } from "./StabilityApiConfiguration.js";
@@ -66,7 +67,7 @@ export class StabilityImageGenerationModel extends AbstractModel {
66
67
  style_preset: this.settings.stylePreset,
67
68
  },
68
69
  failedResponseHandler: failedStabilityCallResponseHandler,
69
- successfulResponseHandler: createJsonResponseHandler(stabilityImageGenerationResponseSchema),
70
+ successfulResponseHandler: createJsonResponseHandler(zodSchema(stabilityImageGenerationResponseSchema)),
70
71
  abortSignal,
71
72
  }),
72
73
  });
@@ -2,13 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhisperCppApiConfiguration = void 0;
4
4
  const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
5
- class WhisperCppApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfiguration {
6
- constructor({ baseUrl = "http://127.0.0.1:8080", retry, throttle, } = {}) {
5
+ /**
6
+ * Creates an API configuration for the Whisper.cpp server.
7
+ * It calls the API at http://127.0.0.1:8080 by default.
8
+ */
9
+ class WhisperCppApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfigurationWithDefaults {
10
+ constructor(settings = {}) {
7
11
  super({
8
- baseUrl,
9
- headers: {},
10
- retry,
11
- throttle,
12
+ ...settings,
13
+ baseUrlDefaults: {
14
+ protocol: "http",
15
+ host: "127.0.0.1",
16
+ port: "8080",
17
+ path: "",
18
+ },
12
19
  });
13
20
  }
14
21
  }
@@ -1,11 +1,8 @@
1
- import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
- import { RetryFunction } from "../../core/api/RetryFunction.js";
3
- import { ThrottleFunction } from "../../core/api/ThrottleFunction.js";
4
- export type WhisperCppApiConfigurationSettings = {
5
- baseUrl?: string;
6
- retry?: RetryFunction;
7
- throttle?: ThrottleFunction;
8
- };
9
- export declare class WhisperCppApiConfiguration extends BaseUrlApiConfiguration {
10
- constructor({ baseUrl, retry, throttle, }?: WhisperCppApiConfigurationSettings);
1
+ import { BaseUrlApiConfigurationWithDefaults, PartialBaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ /**
3
+ * Creates an API configuration for the Whisper.cpp server.
4
+ * It calls the API at http://127.0.0.1:8080 by default.
5
+ */
6
+ export declare class WhisperCppApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
7
+ constructor(settings?: PartialBaseUrlPartsApiConfigurationOptions);
11
8
  }
@@ -1,11 +1,18 @@
1
- import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
- export class WhisperCppApiConfiguration extends BaseUrlApiConfiguration {
3
- constructor({ baseUrl = "http://127.0.0.1:8080", retry, throttle, } = {}) {
1
+ import { BaseUrlApiConfigurationWithDefaults, } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ /**
3
+ * Creates an API configuration for the Whisper.cpp server.
4
+ * It calls the API at http://127.0.0.1:8080 by default.
5
+ */
6
+ export class WhisperCppApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
7
+ constructor(settings = {}) {
4
8
  super({
5
- baseUrl,
6
- headers: {},
7
- retry,
8
- throttle,
9
+ ...settings,
10
+ baseUrlDefaults: {
11
+ protocol: "http",
12
+ host: "127.0.0.1",
13
+ port: "8080",
14
+ path: "",
15
+ },
9
16
  });
10
17
  }
11
18
  }
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Api = exports.Transcriber = void 0;
3
+ exports.Transcriber = exports.Api = void 0;
4
4
  const WhisperCppApiConfiguration_js_1 = require("./WhisperCppApiConfiguration.cjs");
5
5
  const WhisperCppTranscriptionModel_js_1 = require("./WhisperCppTranscriptionModel.cjs");
6
- function Transcriber(settings = {}) {
7
- return new WhisperCppTranscriptionModel_js_1.WhisperCppTranscriptionModel(settings);
8
- }
9
- exports.Transcriber = Transcriber;
6
+ /**
7
+ * Creates an API configuration for the Whisper.cpp server.
8
+ * It calls the API at http://127.0.0.1:8080 by default.
9
+ */
10
10
  function Api(settings) {
11
11
  return new WhisperCppApiConfiguration_js_1.WhisperCppApiConfiguration(settings);
12
12
  }
13
13
  exports.Api = Api;
14
+ function Transcriber(settings = {}) {
15
+ return new WhisperCppTranscriptionModel_js_1.WhisperCppTranscriptionModel(settings);
16
+ }
17
+ exports.Transcriber = Transcriber;
@@ -1,4 +1,9 @@
1
- import { WhisperCppApiConfiguration, WhisperCppApiConfigurationSettings } from "./WhisperCppApiConfiguration.js";
1
+ import { PartialBaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ import { WhisperCppApiConfiguration } from "./WhisperCppApiConfiguration.js";
2
3
  import { WhisperCppTranscriptionModel, WhisperCppTranscriptionModelSettings } from "./WhisperCppTranscriptionModel.js";
4
+ /**
5
+ * Creates an API configuration for the Whisper.cpp server.
6
+ * It calls the API at http://127.0.0.1:8080 by default.
7
+ */
8
+ export declare function Api(settings: PartialBaseUrlPartsApiConfigurationOptions): WhisperCppApiConfiguration;
3
9
  export declare function Transcriber(settings?: WhisperCppTranscriptionModelSettings): WhisperCppTranscriptionModel;
4
- export declare function Api(settings: WhisperCppApiConfigurationSettings): WhisperCppApiConfiguration;
@@ -1,8 +1,12 @@
1
- import { WhisperCppApiConfiguration, } from "./WhisperCppApiConfiguration.js";
1
+ import { WhisperCppApiConfiguration } from "./WhisperCppApiConfiguration.js";
2
2
  import { WhisperCppTranscriptionModel, } from "./WhisperCppTranscriptionModel.js";
3
- export function Transcriber(settings = {}) {
4
- return new WhisperCppTranscriptionModel(settings);
5
- }
3
+ /**
4
+ * Creates an API configuration for the Whisper.cpp server.
5
+ * It calls the API at http://127.0.0.1:8080 by default.
6
+ */
6
7
  export function Api(settings) {
7
8
  return new WhisperCppApiConfiguration(settings);
8
9
  }
10
+ export function Transcriber(settings = {}) {
11
+ return new WhisperCppTranscriptionModel(settings);
12
+ }
@@ -73,12 +73,15 @@ class WhisperCppTranscriptionModel extends AbstractModel_js_1.AbstractModel {
73
73
  }
74
74
  }
75
75
  exports.WhisperCppTranscriptionModel = WhisperCppTranscriptionModel;
76
- const whisperCppTranscriptionJsonSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.union([zod_1.z.object({ text: zod_1.z.string() }), zod_1.z.object({ error: zod_1.z.string() })]));
76
+ const whisperCppTranscriptionJsonSchema = zod_1.z.union([
77
+ zod_1.z.object({ text: zod_1.z.string() }),
78
+ zod_1.z.object({ error: zod_1.z.string() }),
79
+ ]);
77
80
  const successfulResponseHandler = async ({ response, url, requestBodyValues }) => {
78
81
  const responseBody = await response.text();
79
82
  const parsedResult = (0, parseJSON_js_1.safeParseJSON)({
80
83
  text: responseBody,
81
- schema: whisperCppTranscriptionJsonSchema,
84
+ schema: (0, ZodSchema_js_1.zodSchema)(whisperCppTranscriptionJsonSchema),
82
85
  });
83
86
  if (!parsedResult.success) {
84
87
  throw new ApiCallError_js_1.ApiCallError({
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { ApiCallError } from "../../core/api/ApiCallError.js";
3
3
  import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
4
4
  import { postToApi } from "../../core/api/postToApi.js";
5
- import { ZodSchema } from "../../core/schema/ZodSchema.js";
5
+ import { zodSchema } from "../../core/schema/ZodSchema.js";
6
6
  import { safeParseJSON } from "../../core/schema/parseJSON.js";
7
7
  import { AbstractModel } from "../../model-function/AbstractModel.js";
8
8
  import { WhisperCppApiConfiguration } from "./WhisperCppApiConfiguration.js";
@@ -69,12 +69,15 @@ export class WhisperCppTranscriptionModel extends AbstractModel {
69
69
  return new WhisperCppTranscriptionModel(Object.assign({}, this.settings, additionalSettings));
70
70
  }
71
71
  }
72
- const whisperCppTranscriptionJsonSchema = new ZodSchema(z.union([z.object({ text: z.string() }), z.object({ error: z.string() })]));
72
+ const whisperCppTranscriptionJsonSchema = z.union([
73
+ z.object({ text: z.string() }),
74
+ z.object({ error: z.string() }),
75
+ ]);
73
76
  const successfulResponseHandler = async ({ response, url, requestBodyValues }) => {
74
77
  const responseBody = await response.text();
75
78
  const parsedResult = safeParseJSON({
76
79
  text: responseBody,
77
- schema: whisperCppTranscriptionJsonSchema,
80
+ schema: zodSchema(whisperCppTranscriptionJsonSchema),
78
81
  });
79
82
  if (!parsedResult.success) {
80
83
  throw new ApiCallError({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "The TypeScript library for building multi-modal AI applications.",
4
- "version": "0.110.0",
4
+ "version": "0.112.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [
package/tool/Tool.cjs CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tool = void 0;
4
- const InvalidToolNameError_js_1 = require("./InvalidToolNameError.cjs");
5
- const namePattern = /^[a-zA-Z0-9_-]{1,64}$/;
6
4
  /**
7
5
  * A tool is a function with a name, description and defined inputs that can be used
8
6
  * by agents and chatbots.
@@ -11,7 +9,6 @@ class Tool {
11
9
  constructor({ name, description, parameters, returnType, execute, }) {
12
10
  /**
13
11
  * The name of the tool.
14
- * It has to be a function name that matches the regular expression pattern '^[a-zA-Z0-9_-]{1,64}$'.
15
12
  * Should be understandable for language models and unique among the tools that they know.
16
13
  */
17
14
  Object.defineProperty(this, "name", {
@@ -57,13 +54,6 @@ class Tool {
57
54
  writable: true,
58
55
  value: void 0
59
56
  });
60
- // check that the name is a valid function name:
61
- if (!namePattern.test(name)) {
62
- throw new InvalidToolNameError_js_1.InvalidToolNameError({
63
- toolName: name,
64
- namePattern,
65
- });
66
- }
67
57
  this.name = name;
68
58
  this.description = description;
69
59
  this.parameters = parameters;
package/tool/Tool.d.ts CHANGED
@@ -9,7 +9,6 @@ import { ToolDefinition } from "./ToolDefinition.js";
9
9
  export declare class Tool<NAME extends string, PARAMETERS, RESULT> implements ToolDefinition<NAME, PARAMETERS> {
10
10
  /**
11
11
  * The name of the tool.
12
- * It has to be a function name that matches the regular expression pattern '^[a-zA-Z0-9_-]{1,64}$'.
13
12
  * Should be understandable for language models and unique among the tools that they know.
14
13
  */
15
14
  readonly name: NAME;
package/tool/Tool.js CHANGED
@@ -1,5 +1,3 @@
1
- import { InvalidToolNameError } from "./InvalidToolNameError.js";
2
- const namePattern = /^[a-zA-Z0-9_-]{1,64}$/;
3
1
  /**
4
2
  * A tool is a function with a name, description and defined inputs that can be used
5
3
  * by agents and chatbots.
@@ -8,7 +6,6 @@ export class Tool {
8
6
  constructor({ name, description, parameters, returnType, execute, }) {
9
7
  /**
10
8
  * The name of the tool.
11
- * It has to be a function name that matches the regular expression pattern '^[a-zA-Z0-9_-]{1,64}$'.
12
9
  * Should be understandable for language models and unique among the tools that they know.
13
10
  */
14
11
  Object.defineProperty(this, "name", {
@@ -54,13 +51,6 @@ export class Tool {
54
51
  writable: true,
55
52
  value: void 0
56
53
  });
57
- // check that the name is a valid function name:
58
- if (!namePattern.test(name)) {
59
- throw new InvalidToolNameError({
60
- toolName: name,
61
- namePattern,
62
- });
63
- }
64
54
  this.name = name;
65
55
  this.description = description;
66
56
  this.parameters = parameters;
@@ -4,7 +4,7 @@ exports.WebSearchTool = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ZodSchema_js_1 = require("../core/schema/ZodSchema.cjs");
6
6
  const Tool_js_1 = require("./Tool.cjs");
7
- const RETURN_TYPE_SCHEMA = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
7
+ const RETURN_TYPE_SCHEMA = (0, ZodSchema_js_1.zodSchema)(zod_1.z.object({
8
8
  results: zod_1.z.array(zod_1.z.object({
9
9
  title: zod_1.z.string(),
10
10
  link: zod_1.z.string().url(),
@@ -14,7 +14,7 @@ const RETURN_TYPE_SCHEMA = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
14
14
  // expose the schemas to library consumers:
15
15
  const createParameters = (description) =>
16
16
  // same structure, but with description:
17
- new ZodSchema_js_1.ZodSchema(zod_1.z.object({
17
+ (0, ZodSchema_js_1.zodSchema)(zod_1.z.object({
18
18
  query: zod_1.z.string().describe(description),
19
19
  }));
20
20
  /**
@@ -1,7 +1,6 @@
1
1
  import { FunctionOptions } from "../core/FunctionOptions.js";
2
- import { ZodSchema } from "../core/schema/ZodSchema.js";
3
2
  import { Tool } from "./Tool.js";
4
- declare const RETURN_TYPE_SCHEMA: ZodSchema<{
3
+ declare const RETURN_TYPE_SCHEMA: import("../core/schema/ZodSchema.js").ZodSchema<{
5
4
  results: {
6
5
  link: string;
7
6
  title: string;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
- import { ZodSchema } from "../core/schema/ZodSchema.js";
2
+ import { zodSchema } from "../core/schema/ZodSchema.js";
3
3
  import { Tool } from "./Tool.js";
4
- const RETURN_TYPE_SCHEMA = new ZodSchema(z.object({
4
+ const RETURN_TYPE_SCHEMA = zodSchema(z.object({
5
5
  results: z.array(z.object({
6
6
  title: z.string(),
7
7
  link: z.string().url(),
@@ -11,7 +11,7 @@ const RETURN_TYPE_SCHEMA = new ZodSchema(z.object({
11
11
  // expose the schemas to library consumers:
12
12
  const createParameters = (description) =>
13
13
  // same structure, but with description:
14
- new ZodSchema(z.object({
14
+ zodSchema(z.object({
15
15
  query: z.string().describe(description),
16
16
  }));
17
17
  /**
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextGenerationToolCallsOrGenerateTextModel = void 0;
3
+ exports.TextGenerationToolCallsModel = void 0;
4
4
  const generateText_js_1 = require("../../model-function/generate-text/generateText.cjs");
5
- const ToolCallsOrTextParseError_js_1 = require("./ToolCallsOrTextParseError.cjs");
6
- class TextGenerationToolCallsOrGenerateTextModel {
5
+ const ToolCallsParseError_js_1 = require("./ToolCallsParseError.cjs");
6
+ class TextGenerationToolCallsModel {
7
7
  constructor({ model, template, }) {
8
8
  Object.defineProperty(this, "model", {
9
9
  enumerable: true,
@@ -29,7 +29,7 @@ class TextGenerationToolCallsOrGenerateTextModel {
29
29
  get settingsForEvent() {
30
30
  return this.model.settingsForEvent;
31
31
  }
32
- async doGenerateToolCallsOrText(tools, prompt, options) {
32
+ async doGenerateToolCalls(tools, prompt, options) {
33
33
  const { response, text: generatedText, metadata, } = await (0, generateText_js_1.generateText)(this.model, this.template.createPrompt(prompt, tools), {
34
34
  ...options,
35
35
  fullResponse: true,
@@ -44,17 +44,17 @@ class TextGenerationToolCallsOrGenerateTextModel {
44
44
  };
45
45
  }
46
46
  catch (error) {
47
- throw new ToolCallsOrTextParseError_js_1.ToolCallsOrTextParseError({
47
+ throw new ToolCallsParseError_js_1.ToolCallsParseError({
48
48
  valueText: generatedText,
49
49
  cause: error,
50
50
  });
51
51
  }
52
52
  }
53
53
  withSettings(additionalSettings) {
54
- return new TextGenerationToolCallsOrGenerateTextModel({
54
+ return new TextGenerationToolCallsModel({
55
55
  model: this.model.withSettings(additionalSettings),
56
56
  template: this.template,
57
57
  });
58
58
  }
59
59
  }
60
- exports.TextGenerationToolCallsOrGenerateTextModel = TextGenerationToolCallsOrGenerateTextModel;
60
+ exports.TextGenerationToolCallsModel = TextGenerationToolCallsModel;