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.
- package/CHANGELOG.md +26 -0
- package/README.md +41 -65
- package/core/FunctionEvent.d.ts +3 -3
- package/core/api/ApiFacade.cjs +20 -0
- package/core/api/ApiFacade.d.ts +4 -0
- package/core/api/ApiFacade.js +4 -0
- package/core/api/BaseUrlApiConfiguration.cjs +47 -5
- package/core/api/BaseUrlApiConfiguration.d.ts +23 -6
- package/core/api/BaseUrlApiConfiguration.js +45 -4
- package/core/api/BaseUrlApiConfiguration.test.cjs +11 -0
- package/core/api/BaseUrlApiConfiguration.test.js +9 -0
- package/core/api/callWithRetryAndThrottle.cjs +3 -3
- package/core/api/callWithRetryAndThrottle.js +3 -3
- package/core/api/index.cjs +15 -2
- package/core/api/index.d.ts +2 -2
- package/core/api/index.js +2 -2
- package/core/api/postToApi.cjs +28 -5
- package/core/api/postToApi.d.ts +5 -4
- package/core/api/postToApi.js +26 -4
- package/core/api/throttleOff.cjs +8 -0
- package/core/api/throttleOff.d.ts +5 -0
- package/core/api/throttleOff.js +4 -0
- package/internal/index.cjs +2 -8
- package/internal/index.d.ts +1 -1
- package/internal/index.js +1 -1
- package/model-function/ModelCallEvent.d.ts +3 -3
- package/model-function/generate-structure/generateStructure.d.ts +1 -1
- package/model-function/generate-text/PromptTemplateFullTextModel.cjs +2 -2
- package/model-function/generate-text/PromptTemplateFullTextModel.d.ts +3 -3
- package/model-function/generate-text/PromptTemplateFullTextModel.js +2 -2
- package/model-function/generate-text/PromptTemplateTextGenerationModel.cjs +2 -2
- package/model-function/generate-text/PromptTemplateTextGenerationModel.d.ts +3 -3
- package/model-function/generate-text/PromptTemplateTextGenerationModel.js +2 -2
- package/model-provider/anthropic/AnthropicApiConfiguration.cjs +14 -6
- package/model-provider/anthropic/AnthropicApiConfiguration.d.ts +7 -8
- package/model-provider/anthropic/AnthropicApiConfiguration.js +15 -7
- package/model-provider/anthropic/AnthropicError.cjs +7 -27
- package/model-provider/anthropic/AnthropicError.d.ts +21 -16
- package/model-provider/anthropic/AnthropicError.js +7 -25
- package/model-provider/anthropic/AnthropicFacade.cjs +10 -1
- package/model-provider/anthropic/AnthropicFacade.d.ts +9 -0
- package/model-provider/anthropic/AnthropicFacade.js +8 -0
- package/model-provider/anthropic/AnthropicTextGenerationModel.cjs +22 -24
- package/model-provider/anthropic/AnthropicTextGenerationModel.js +23 -25
- package/model-provider/anthropic/index.cjs +1 -4
- package/model-provider/anthropic/index.d.ts +1 -1
- package/model-provider/anthropic/index.js +0 -1
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.cjs +12 -4
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.d.ts +3 -3
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.js +12 -4
- package/model-provider/automatic1111/Automatic1111Error.cjs +3 -3
- package/model-provider/automatic1111/Automatic1111Error.d.ts +13 -3
- package/model-provider/automatic1111/Automatic1111Error.js +4 -4
- package/model-provider/automatic1111/Automatic1111Facade.cjs +9 -9
- package/model-provider/automatic1111/Automatic1111Facade.d.ts +6 -6
- package/model-provider/automatic1111/Automatic1111Facade.js +7 -7
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +11 -7
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +11 -7
- package/model-provider/cohere/CohereApiConfiguration.cjs +14 -6
- package/model-provider/cohere/CohereApiConfiguration.d.ts +7 -8
- package/model-provider/cohere/CohereApiConfiguration.js +15 -7
- package/model-provider/cohere/CohereError.cjs +8 -43
- package/model-provider/cohere/CohereError.d.ts +9 -16
- package/model-provider/cohere/CohereError.js +8 -41
- package/model-provider/cohere/CohereFacade.cjs +12 -3
- package/model-provider/cohere/CohereFacade.d.ts +11 -2
- package/model-provider/cohere/CohereFacade.js +10 -2
- package/model-provider/cohere/CohereTextEmbeddingModel.cjs +18 -22
- package/model-provider/cohere/CohereTextEmbeddingModel.js +18 -22
- package/model-provider/cohere/CohereTextGenerationModel.cjs +31 -39
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +110 -8
- package/model-provider/cohere/CohereTextGenerationModel.js +31 -39
- package/model-provider/cohere/CohereTokenizer.cjs +32 -41
- package/model-provider/cohere/CohereTokenizer.d.ts +2 -2
- package/model-provider/cohere/CohereTokenizer.js +32 -41
- package/model-provider/cohere/index.cjs +1 -3
- package/model-provider/cohere/index.d.ts +1 -1
- package/model-provider/cohere/index.js +0 -1
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.cjs +14 -6
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.d.ts +7 -8
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.js +15 -7
- package/model-provider/elevenlabs/ElevenLabsFacade.cjs +10 -1
- package/model-provider/elevenlabs/ElevenLabsFacade.d.ts +9 -0
- package/model-provider/elevenlabs/ElevenLabsFacade.js +8 -0
- package/model-provider/elevenlabs/ElevenLabsSpeechModel.cjs +42 -53
- package/model-provider/elevenlabs/ElevenLabsSpeechModel.js +44 -55
- package/model-provider/huggingface/HuggingFaceApiConfiguration.cjs +14 -6
- package/model-provider/huggingface/HuggingFaceApiConfiguration.d.ts +7 -8
- package/model-provider/huggingface/HuggingFaceApiConfiguration.js +15 -7
- package/model-provider/huggingface/HuggingFaceError.cjs +7 -29
- package/model-provider/huggingface/HuggingFaceError.d.ts +9 -16
- package/model-provider/huggingface/HuggingFaceError.js +7 -27
- package/model-provider/huggingface/HuggingFaceFacade.cjs +10 -1
- package/model-provider/huggingface/HuggingFaceFacade.d.ts +9 -0
- package/model-provider/huggingface/HuggingFaceFacade.js +8 -0
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +17 -27
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +17 -27
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +22 -23
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +22 -23
- package/model-provider/huggingface/index.cjs +1 -3
- package/model-provider/huggingface/index.d.ts +1 -1
- package/model-provider/huggingface/index.js +0 -1
- package/model-provider/llamacpp/LlamaCppApiConfiguration.cjs +13 -6
- package/model-provider/llamacpp/LlamaCppApiConfiguration.d.ts +7 -9
- package/model-provider/llamacpp/LlamaCppApiConfiguration.js +14 -7
- package/model-provider/llamacpp/LlamaCppCompletionModel.cjs +4 -4
- package/model-provider/llamacpp/LlamaCppCompletionModel.d.ts +173 -5
- package/model-provider/llamacpp/LlamaCppCompletionModel.js +4 -4
- package/model-provider/llamacpp/LlamaCppError.cjs +7 -27
- package/model-provider/llamacpp/LlamaCppError.d.ts +9 -16
- package/model-provider/llamacpp/LlamaCppError.js +7 -25
- package/model-provider/llamacpp/LlamaCppFacade.cjs +10 -2
- package/model-provider/llamacpp/LlamaCppFacade.d.ts +8 -1
- package/model-provider/llamacpp/LlamaCppFacade.js +8 -1
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +10 -14
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +10 -14
- package/model-provider/llamacpp/LlamaCppTokenizer.cjs +14 -18
- package/model-provider/llamacpp/LlamaCppTokenizer.js +14 -18
- package/model-provider/llamacpp/index.cjs +1 -3
- package/model-provider/llamacpp/index.d.ts +1 -1
- package/model-provider/llamacpp/index.js +0 -1
- package/model-provider/lmnt/LmntApiConfiguration.cjs +14 -6
- package/model-provider/lmnt/LmntApiConfiguration.d.ts +7 -8
- package/model-provider/lmnt/LmntApiConfiguration.js +15 -7
- package/model-provider/lmnt/LmntFacade.cjs +11 -2
- package/model-provider/lmnt/LmntFacade.d.ts +10 -1
- package/model-provider/lmnt/LmntFacade.js +9 -1
- package/model-provider/lmnt/LmntSpeechModel.cjs +53 -41
- package/model-provider/lmnt/LmntSpeechModel.d.ts +51 -3
- package/model-provider/lmnt/LmntSpeechModel.js +54 -42
- package/model-provider/mistral/MistralApiConfiguration.cjs +14 -6
- package/model-provider/mistral/MistralApiConfiguration.d.ts +9 -11
- package/model-provider/mistral/MistralApiConfiguration.js +15 -7
- package/model-provider/mistral/MistralChatModel.cjs +4 -4
- package/model-provider/mistral/MistralChatModel.d.ts +52 -7
- package/model-provider/mistral/MistralChatModel.js +5 -5
- package/model-provider/mistral/MistralError.cjs +3 -3
- package/model-provider/mistral/MistralError.d.ts +15 -3
- package/model-provider/mistral/MistralError.js +4 -4
- package/model-provider/mistral/MistralFacade.cjs +5 -1
- package/model-provider/mistral/MistralFacade.d.ts +10 -3
- package/model-provider/mistral/MistralFacade.js +6 -2
- package/model-provider/mistral/MistralTextEmbeddingModel.cjs +2 -1
- package/model-provider/mistral/MistralTextEmbeddingModel.d.ts +3 -3
- package/model-provider/mistral/MistralTextEmbeddingModel.js +2 -1
- package/model-provider/ollama/OllamaApiConfiguration.cjs +13 -6
- package/model-provider/ollama/OllamaApiConfiguration.d.ts +7 -10
- package/model-provider/ollama/OllamaApiConfiguration.js +14 -7
- package/model-provider/ollama/OllamaChatModel.cjs +6 -6
- package/model-provider/ollama/OllamaChatModel.d.ts +49 -8
- package/model-provider/ollama/OllamaChatModel.js +7 -7
- package/model-provider/ollama/OllamaCompletionModel.cjs +6 -6
- package/model-provider/ollama/OllamaCompletionModel.d.ts +43 -8
- package/model-provider/ollama/OllamaCompletionModel.js +7 -7
- package/model-provider/ollama/OllamaError.cjs +3 -3
- package/model-provider/ollama/OllamaError.d.ts +7 -3
- package/model-provider/ollama/OllamaError.js +4 -4
- package/model-provider/ollama/OllamaFacade.cjs +6 -2
- package/model-provider/ollama/OllamaFacade.d.ts +8 -3
- package/model-provider/ollama/OllamaFacade.js +6 -2
- package/model-provider/ollama/OllamaTextEmbeddingModel.cjs +15 -16
- package/model-provider/ollama/OllamaTextEmbeddingModel.js +15 -16
- package/model-provider/openai/AbstractOpenAIChatModel.cjs +5 -5
- package/model-provider/openai/AbstractOpenAIChatModel.d.ts +155 -9
- package/model-provider/openai/AbstractOpenAIChatModel.js +5 -5
- package/model-provider/openai/AbstractOpenAICompletionModel.cjs +30 -32
- package/model-provider/openai/AbstractOpenAICompletionModel.d.ts +4 -4
- package/model-provider/openai/AbstractOpenAICompletionModel.js +30 -32
- package/model-provider/openai/AzureOpenAIApiConfiguration.d.ts +9 -8
- package/model-provider/openai/OpenAIApiConfiguration.cjs +14 -6
- package/model-provider/openai/OpenAIApiConfiguration.d.ts +7 -8
- package/model-provider/openai/OpenAIApiConfiguration.js +15 -7
- package/model-provider/openai/OpenAIChatFunctionCallStructureGenerationModel.d.ts +1 -1
- package/model-provider/openai/OpenAIChatModel.d.ts +2 -2
- package/model-provider/openai/OpenAIError.cjs +8 -8
- package/model-provider/openai/OpenAIError.d.ts +27 -3
- package/model-provider/openai/OpenAIError.js +9 -9
- package/model-provider/openai/OpenAIFacade.cjs +23 -2
- package/model-provider/openai/OpenAIFacade.d.ts +20 -2
- package/model-provider/openai/OpenAIFacade.js +20 -1
- package/model-provider/openai/OpenAIImageGenerationModel.cjs +20 -21
- package/model-provider/openai/OpenAIImageGenerationModel.js +20 -21
- package/model-provider/openai/OpenAISpeechModel.cjs +17 -22
- package/model-provider/openai/OpenAISpeechModel.js +17 -22
- package/model-provider/openai/OpenAITextEmbeddingModel.cjs +18 -23
- package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +3 -3
- package/model-provider/openai/OpenAITextEmbeddingModel.js +18 -23
- package/model-provider/openai/OpenAITranscriptionModel.cjs +42 -48
- package/model-provider/openai/OpenAITranscriptionModel.d.ts +14 -10
- package/model-provider/openai/OpenAITranscriptionModel.js +42 -48
- package/model-provider/openai-compatible/FireworksAIApiConfiguration.cjs +11 -7
- package/model-provider/openai-compatible/FireworksAIApiConfiguration.d.ts +4 -9
- package/model-provider/openai-compatible/FireworksAIApiConfiguration.js +12 -8
- package/model-provider/openai-compatible/OpenAICompatibleChatModel.d.ts +2 -2
- package/model-provider/openai-compatible/OpenAICompatibleFacade.cjs +25 -1
- package/model-provider/openai-compatible/OpenAICompatibleFacade.d.ts +23 -0
- package/model-provider/openai-compatible/OpenAICompatibleFacade.js +22 -0
- package/model-provider/openai-compatible/TogetherAIApiConfiguration.cjs +11 -7
- package/model-provider/openai-compatible/TogetherAIApiConfiguration.d.ts +4 -9
- package/model-provider/openai-compatible/TogetherAIApiConfiguration.js +12 -8
- package/model-provider/stability/StabilityApiConfiguration.cjs +13 -12
- package/model-provider/stability/StabilityApiConfiguration.d.ts +4 -4
- package/model-provider/stability/StabilityApiConfiguration.js +13 -12
- package/model-provider/stability/StabilityError.cjs +3 -3
- package/model-provider/stability/StabilityError.d.ts +7 -3
- package/model-provider/stability/StabilityError.js +4 -4
- package/model-provider/stability/StabilityFacade.cjs +9 -9
- package/model-provider/stability/StabilityFacade.d.ts +8 -8
- package/model-provider/stability/StabilityFacade.js +7 -7
- package/model-provider/stability/StabilityImageGenerationModel.cjs +2 -1
- package/model-provider/stability/StabilityImageGenerationModel.js +2 -1
- package/model-provider/whispercpp/WhisperCppApiConfiguration.cjs +13 -6
- package/model-provider/whispercpp/WhisperCppApiConfiguration.d.ts +7 -10
- package/model-provider/whispercpp/WhisperCppApiConfiguration.js +14 -7
- package/model-provider/whispercpp/WhisperCppFacade.cjs +9 -5
- package/model-provider/whispercpp/WhisperCppFacade.d.ts +7 -2
- package/model-provider/whispercpp/WhisperCppFacade.js +8 -4
- package/model-provider/whispercpp/WhisperCppTranscriptionModel.cjs +5 -2
- package/model-provider/whispercpp/WhisperCppTranscriptionModel.js +6 -3
- package/package.json +1 -1
- package/tool/Tool.cjs +0 -10
- package/tool/Tool.d.ts +0 -1
- package/tool/Tool.js +0 -10
- package/tool/WebSearchTool.cjs +2 -2
- package/tool/WebSearchTool.d.ts +1 -2
- package/tool/WebSearchTool.js +3 -3
- package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.cjs → generate-tool-calls/TextGenerationToolCallsModel.cjs} +7 -7
- package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.d.ts → generate-tool-calls/TextGenerationToolCallsModel.d.ts} +6 -6
- package/tool/{generate-tool-calls-or-text/TextGenerationToolCallsOrGenerateTextModel.js → generate-tool-calls/TextGenerationToolCallsModel.js} +5 -5
- package/tool/generate-tool-calls/ToolCallsGenerationEvent.d.ts +23 -0
- package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.d.ts → generate-tool-calls/ToolCallsGenerationModel.d.ts} +3 -3
- package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.cjs → generate-tool-calls/ToolCallsParseError.cjs} +5 -5
- package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.d.ts → generate-tool-calls/ToolCallsParseError.d.ts} +1 -1
- package/tool/{generate-tool-calls-or-text/ToolCallsOrTextParseError.js → generate-tool-calls/ToolCallsParseError.js} +3 -3
- package/tool/{generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.d.ts → generate-tool-calls/ToolCallsPromptTemplate.d.ts} +1 -1
- package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.cjs → generate-tool-calls/generateToolCalls.cjs} +5 -5
- package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.d.ts → generate-tool-calls/generateToolCalls.d.ts} +3 -3
- package/tool/{generate-tool-calls-or-text/generateToolCallsOrText.js → generate-tool-calls/generateToolCalls.js} +3 -3
- package/tool/{generate-tool-calls-or-text → generate-tool-calls}/index.cjs +6 -6
- package/tool/generate-tool-calls/index.d.ts +6 -0
- package/tool/generate-tool-calls/index.js +6 -0
- package/tool/index.cjs +2 -3
- package/tool/index.d.ts +2 -3
- package/tool/index.js +2 -3
- package/tool/use-tools/UseToolsEvent.d.ts +7 -0
- package/tool/use-tools/UseToolsEvent.js +1 -0
- package/tool/{use-tools-or-generate-text → use-tools}/index.cjs +2 -2
- package/tool/use-tools/index.d.ts +2 -0
- package/tool/use-tools/index.js +2 -0
- package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.cjs → use-tools/useTools.cjs} +6 -6
- package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.d.ts → use-tools/useTools.d.ts} +2 -2
- package/tool/{use-tools-or-generate-text/useToolsOrGenerateText.js → use-tools/useTools.js} +4 -4
- package/vector-index/memory/MemoryVectorIndex.cjs +2 -2
- package/vector-index/memory/MemoryVectorIndex.js +3 -3
- package/core/api/BaseUrlPartsApiConfiguration.cjs +0 -53
- package/core/api/BaseUrlPartsApiConfiguration.d.ts +0 -26
- package/core/api/BaseUrlPartsApiConfiguration.js +0 -49
- package/core/api/throttleUnlimitedConcurrency.cjs +0 -8
- package/core/api/throttleUnlimitedConcurrency.d.ts +0 -5
- package/core/api/throttleUnlimitedConcurrency.js +0 -4
- package/model-provider/elevenlabs/ElevenLabsError.cjs +0 -30
- package/model-provider/elevenlabs/ElevenLabsError.d.ts +0 -3
- package/model-provider/elevenlabs/ElevenLabsError.js +0 -26
- package/model-provider/lmnt/LmntError.cjs +0 -30
- package/model-provider/lmnt/LmntError.d.ts +0 -3
- package/model-provider/lmnt/LmntError.js +0 -26
- package/tool/InvalidToolNameError.cjs +0 -17
- package/tool/InvalidToolNameError.d.ts +0 -7
- package/tool/InvalidToolNameError.js +0 -13
- package/tool/generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.d.ts +0 -23
- package/tool/generate-tool-calls-or-text/index.d.ts +0 -6
- package/tool/generate-tool-calls-or-text/index.js +0 -6
- package/tool/use-tools-or-generate-text/UseToolsOrGenerateTextEvent.d.ts +0 -7
- package/tool/use-tools-or-generate-text/index.d.ts +0 -2
- package/tool/use-tools-or-generate-text/index.js +0 -2
- /package/{tool/generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.js → core/api/BaseUrlApiConfiguration.test.d.ts} +0 -0
- /package/tool/{generate-tool-calls-or-text/ToolCallsOrGenerateTextPromptTemplate.cjs → generate-tool-calls/ToolCallsGenerationEvent.cjs} +0 -0
- /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.js → generate-tool-calls/ToolCallsGenerationEvent.js} +0 -0
- /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationEvent.cjs → generate-tool-calls/ToolCallsGenerationModel.cjs} +0 -0
- /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.js → generate-tool-calls/ToolCallsGenerationModel.js} +0 -0
- /package/tool/{generate-tool-calls-or-text/ToolCallsOrTextGenerationModel.cjs → generate-tool-calls/ToolCallsPromptTemplate.cjs} +0 -0
- /package/tool/{use-tools-or-generate-text/UseToolsOrGenerateTextEvent.js → generate-tool-calls/ToolCallsPromptTemplate.js} +0 -0
- /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
|
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
|
11
|
-
constructor(
|
10
|
+
class StabilityApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfigurationWithDefaults {
|
11
|
+
constructor(settings = {}) {
|
12
12
|
super({
|
13
|
-
|
14
|
-
|
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
|
-
|
25
|
-
|
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 {
|
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
|
7
|
-
constructor(
|
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 {
|
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
|
8
|
-
constructor(
|
7
|
+
export class StabilityApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
|
8
|
+
constructor(settings = {}) {
|
9
9
|
super({
|
10
|
-
|
11
|
-
|
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
|
-
|
22
|
-
|
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 =
|
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
|
-
|
4
|
-
|
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 =
|
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 {
|
4
|
-
const stabilityErrorDataSchema =
|
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.
|
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/
|
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
|
-
|
6
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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 {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 {
|
2
|
-
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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.
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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 {
|
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
|
1
|
+
import { WhisperCppApiConfiguration } from "./WhisperCppApiConfiguration.js";
|
2
2
|
import { WhisperCppTranscriptionModel, } from "./WhisperCppTranscriptionModel.js";
|
3
|
-
|
4
|
-
|
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 =
|
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 {
|
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 =
|
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
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;
|
package/tool/WebSearchTool.cjs
CHANGED
@@ -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 =
|
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
|
-
|
17
|
+
(0, ZodSchema_js_1.zodSchema)(zod_1.z.object({
|
18
18
|
query: zod_1.z.string().describe(description),
|
19
19
|
}));
|
20
20
|
/**
|
package/tool/WebSearchTool.d.ts
CHANGED
@@ -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;
|
package/tool/WebSearchTool.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { z } from "zod";
|
2
|
-
import {
|
2
|
+
import { zodSchema } from "../core/schema/ZodSchema.js";
|
3
3
|
import { Tool } from "./Tool.js";
|
4
|
-
const RETURN_TYPE_SCHEMA =
|
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
|
-
|
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.
|
3
|
+
exports.TextGenerationToolCallsModel = void 0;
|
4
4
|
const generateText_js_1 = require("../../model-function/generate-text/generateText.cjs");
|
5
|
-
const
|
6
|
-
class
|
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
|
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
|
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
|
54
|
+
return new TextGenerationToolCallsModel({
|
55
55
|
model: this.model.withSettings(additionalSettings),
|
56
56
|
template: this.template,
|
57
57
|
});
|
58
58
|
}
|
59
59
|
}
|
60
|
-
exports.
|
60
|
+
exports.TextGenerationToolCallsModel = TextGenerationToolCallsModel;
|