modelfusion 0.124.0 → 0.126.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 +34 -1
- package/README.md +17 -30
- package/core/FunctionEvent.d.ts +3 -3
- package/model-function/generate-text/PromptTemplateFullTextModel.cjs +0 -11
- package/model-function/generate-text/PromptTemplateFullTextModel.d.ts +0 -1
- package/model-function/generate-text/PromptTemplateFullTextModel.js +0 -11
- package/model-function/generate-text/PromptTemplateTextGenerationModel.cjs +0 -11
- package/model-function/generate-text/PromptTemplateTextGenerationModel.d.ts +0 -1
- package/model-function/generate-text/PromptTemplateTextGenerationModel.js +0 -11
- package/model-function/generate-text/PromptTemplateTextStreamingModel.cjs +0 -11
- package/model-function/generate-text/PromptTemplateTextStreamingModel.d.ts +0 -1
- package/model-function/generate-text/PromptTemplateTextStreamingModel.js +0 -11
- package/model-function/generate-text/TextGenerationModel.d.ts +31 -1
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +3 -3
- package/model-provider/cohere/CohereTextGenerationModel.cjs +6 -9
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +4 -9
- package/model-provider/cohere/CohereTextGenerationModel.js +7 -10
- package/model-provider/cohere/CohereTokenizer.d.ts +3 -3
- package/model-provider/llamacpp/LlamaCppCompletionModel.d.ts +2 -2
- package/model-provider/mistral/MistralChatModel.cjs +0 -9
- package/model-provider/mistral/MistralChatModel.d.ts +2 -11
- package/model-provider/mistral/MistralChatModel.js +0 -9
- package/model-provider/mistral/index.cjs +1 -2
- package/model-provider/mistral/index.d.ts +0 -1
- package/model-provider/mistral/index.js +0 -1
- package/model-provider/ollama/OllamaChatModel.cjs +0 -9
- package/model-provider/ollama/OllamaChatModel.d.ts +2 -11
- package/model-provider/ollama/OllamaChatModel.js +0 -9
- package/model-provider/ollama/OllamaCompletionModel.d.ts +2 -2
- package/model-provider/ollama/index.cjs +0 -1
- package/model-provider/ollama/index.d.ts +0 -1
- package/model-provider/ollama/index.js +0 -1
- package/model-provider/openai/AbstractOpenAIChatModel.cjs +5 -3
- package/model-provider/openai/AbstractOpenAIChatModel.d.ts +5 -5
- package/model-provider/openai/AbstractOpenAIChatModel.js +5 -3
- package/model-provider/openai/OpenAIChatFunctionCallStructureGenerationModel.d.ts +1 -1
- package/model-provider/openai/OpenAIChatModel.cjs +0 -9
- package/model-provider/openai/OpenAIChatModel.d.ts +2 -11
- package/model-provider/openai/OpenAIChatModel.js +0 -9
- package/model-provider/openai/OpenAICompletionModel.cjs +3 -6
- package/model-provider/openai/OpenAICompletionModel.d.ts +3 -8
- package/model-provider/openai/OpenAICompletionModel.js +4 -7
- package/model-provider/openai/index.cjs +1 -2
- package/model-provider/openai/index.d.ts +0 -1
- package/model-provider/openai/index.js +0 -1
- package/model-provider/openai-compatible/OpenAICompatibleChatModel.cjs +0 -9
- package/model-provider/openai-compatible/OpenAICompatibleChatModel.d.ts +2 -11
- package/model-provider/openai-compatible/OpenAICompatibleChatModel.js +0 -9
- package/model-provider/openai-compatible/OpenAICompatibleCompletionModel.cjs +10 -0
- package/model-provider/openai-compatible/OpenAICompatibleCompletionModel.d.ts +8 -2
- package/model-provider/openai-compatible/OpenAICompatibleCompletionModel.js +10 -0
- package/model-provider/openai-compatible/OpenAICompatibleFacade.cjs +13 -1
- package/model-provider/openai-compatible/OpenAICompatibleFacade.d.ts +11 -0
- package/model-provider/openai-compatible/OpenAICompatibleFacade.js +11 -0
- package/model-provider/openai-compatible/PerplexityApiConfiguration.cjs +33 -0
- package/model-provider/openai-compatible/PerplexityApiConfiguration.d.ts +13 -0
- package/model-provider/openai-compatible/PerplexityApiConfiguration.js +29 -0
- package/model-provider/openai-compatible/index.cjs +2 -1
- package/model-provider/openai-compatible/index.d.ts +2 -1
- package/model-provider/openai-compatible/index.js +2 -1
- package/package.json +1 -1
- package/tool/index.cjs +2 -2
- package/tool/index.d.ts +2 -2
- package/tool/index.js +2 -2
- package/tool/run-tool/RunToolEvent.d.ts +7 -0
- package/tool/{use-tool → run-tool}/index.cjs +2 -2
- package/tool/run-tool/index.d.ts +2 -0
- package/tool/run-tool/index.js +2 -0
- package/tool/{use-tool/useTool.cjs → run-tool/runTool.cjs} +5 -5
- package/tool/{use-tool/useTool.d.ts → run-tool/runTool.d.ts} +2 -2
- package/tool/{use-tool/useTool.js → run-tool/runTool.js} +3 -3
- package/tool/run-tools/RunToolsEvent.d.ts +7 -0
- package/tool/{use-tools → run-tools}/index.cjs +2 -2
- package/tool/run-tools/index.d.ts +2 -0
- package/tool/run-tools/index.js +2 -0
- package/tool/{use-tools/useTools.cjs → run-tools/runTools.cjs} +4 -4
- package/tool/{use-tools/useTools.d.ts → run-tools/runTools.d.ts} +1 -1
- package/tool/{use-tools/useTools.js → run-tools/runTools.js} +2 -2
- package/tool/use-tool/UseToolEvent.d.ts +0 -7
- package/tool/use-tool/index.d.ts +0 -2
- package/tool/use-tool/index.js +0 -2
- package/tool/use-tools/UseToolsEvent.d.ts +0 -7
- package/tool/use-tools/index.d.ts +0 -2
- package/tool/use-tools/index.js +0 -2
- /package/tool/{use-tool/UseToolEvent.cjs → run-tool/RunToolEvent.cjs} +0 -0
- /package/tool/{use-tool/UseToolEvent.js → run-tool/RunToolEvent.js} +0 -0
- /package/tool/{use-tools/UseToolsEvent.cjs → run-tools/RunToolsEvent.cjs} +0 -0
- /package/tool/{use-tools/UseToolsEvent.js → run-tools/RunToolsEvent.js} +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import { PromptTemplateTextStreamingModel } from "../../model-function/generate-text/PromptTemplateTextStreamingModel.js";
|
2
2
|
import { textGenerationModelProperties, } from "../../model-function/generate-text/TextGenerationModel.js";
|
3
|
+
import { chat, instruction, text, } from "../../model-function/generate-text/prompt-template/TextPromptTemplate.js";
|
3
4
|
import { AbstractOpenAICompletionModel, } from "../openai/AbstractOpenAICompletionModel.js";
|
4
5
|
/**
|
5
6
|
* Create a text generation model that calls an API that is compatible with OpenAI's completion API.
|
@@ -53,6 +54,15 @@ export class OpenAICompatibleCompletionModel extends AbstractOpenAICompletionMod
|
|
53
54
|
];
|
54
55
|
return Object.fromEntries(Object.entries(this.settings).filter(([key]) => eventSettingProperties.includes(key)));
|
55
56
|
}
|
57
|
+
withTextPrompt() {
|
58
|
+
return this.withPromptTemplate(text());
|
59
|
+
}
|
60
|
+
withInstructionPrompt() {
|
61
|
+
return this.withPromptTemplate(instruction());
|
62
|
+
}
|
63
|
+
withChatPrompt(options) {
|
64
|
+
return this.withPromptTemplate(chat(options));
|
65
|
+
}
|
56
66
|
withPromptTemplate(promptTemplate) {
|
57
67
|
return new PromptTemplateTextStreamingModel({
|
58
68
|
model: this.withSettings({
|
@@ -1,10 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.TextEmbedder = exports.ChatTextGenerator = exports.CompletionTextGenerator = exports.TogetherAIApi = exports.FireworksAIApi = void 0;
|
3
|
+
exports.TextEmbedder = exports.ChatTextGenerator = exports.CompletionTextGenerator = exports.TogetherAIApi = exports.PerplexityApi = exports.FireworksAIApi = void 0;
|
4
4
|
const FireworksAIApiConfiguration_js_1 = require("./FireworksAIApiConfiguration.cjs");
|
5
5
|
const OpenAICompatibleChatModel_js_1 = require("./OpenAICompatibleChatModel.cjs");
|
6
6
|
const OpenAICompatibleCompletionModel_js_1 = require("./OpenAICompatibleCompletionModel.cjs");
|
7
7
|
const OpenAICompatibleTextEmbeddingModel_js_1 = require("./OpenAICompatibleTextEmbeddingModel.cjs");
|
8
|
+
const PerplexityApiConfiguration_js_1 = require("./PerplexityApiConfiguration.cjs");
|
8
9
|
const TogetherAIApiConfiguration_js_1 = require("./TogetherAIApiConfiguration.cjs");
|
9
10
|
/**
|
10
11
|
* Configuration for the Fireworks.ai API.
|
@@ -17,6 +18,17 @@ function FireworksAIApi(settings = {}) {
|
|
17
18
|
return new FireworksAIApiConfiguration_js_1.FireworksAIApiConfiguration(settings);
|
18
19
|
}
|
19
20
|
exports.FireworksAIApi = FireworksAIApi;
|
21
|
+
/**
|
22
|
+
* Configuration for the Perplexity API.
|
23
|
+
*
|
24
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
25
|
+
*
|
26
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
27
|
+
*/
|
28
|
+
function PerplexityApi(settings = {}) {
|
29
|
+
return new PerplexityApiConfiguration_js_1.PerplexityApiConfiguration(settings);
|
30
|
+
}
|
31
|
+
exports.PerplexityApi = PerplexityApi;
|
20
32
|
/**
|
21
33
|
* Configuration for the Together.ai API.
|
22
34
|
*
|
@@ -3,6 +3,7 @@ import { FireworksAIApiConfiguration } from "./FireworksAIApiConfiguration.js";
|
|
3
3
|
import { OpenAICompatibleChatModel, OpenAICompatibleChatSettings } from "./OpenAICompatibleChatModel.js";
|
4
4
|
import { OpenAICompatibleCompletionModel } from "./OpenAICompatibleCompletionModel.js";
|
5
5
|
import { OpenAICompatibleTextEmbeddingModel, OpenAICompatibleTextEmbeddingModelSettings } from "./OpenAICompatibleTextEmbeddingModel.js";
|
6
|
+
import { PerplexityApiConfiguration } from "./PerplexityApiConfiguration.js";
|
6
7
|
import { TogetherAIApiConfiguration } from "./TogetherAIApiConfiguration.js";
|
7
8
|
/**
|
8
9
|
* Configuration for the Fireworks.ai API.
|
@@ -14,6 +15,16 @@ import { TogetherAIApiConfiguration } from "./TogetherAIApiConfiguration.js";
|
|
14
15
|
export declare function FireworksAIApi(settings?: PartialBaseUrlPartsApiConfigurationOptions & {
|
15
16
|
apiKey?: string;
|
16
17
|
}): FireworksAIApiConfiguration;
|
18
|
+
/**
|
19
|
+
* Configuration for the Perplexity API.
|
20
|
+
*
|
21
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
22
|
+
*
|
23
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
24
|
+
*/
|
25
|
+
export declare function PerplexityApi(settings?: PartialBaseUrlPartsApiConfigurationOptions & {
|
26
|
+
apiKey?: string;
|
27
|
+
}): PerplexityApiConfiguration;
|
17
28
|
/**
|
18
29
|
* Configuration for the Together.ai API.
|
19
30
|
*
|
@@ -2,6 +2,7 @@ import { FireworksAIApiConfiguration } from "./FireworksAIApiConfiguration.js";
|
|
2
2
|
import { OpenAICompatibleChatModel, } from "./OpenAICompatibleChatModel.js";
|
3
3
|
import { OpenAICompatibleCompletionModel } from "./OpenAICompatibleCompletionModel.js";
|
4
4
|
import { OpenAICompatibleTextEmbeddingModel, } from "./OpenAICompatibleTextEmbeddingModel.js";
|
5
|
+
import { PerplexityApiConfiguration } from "./PerplexityApiConfiguration.js";
|
5
6
|
import { TogetherAIApiConfiguration } from "./TogetherAIApiConfiguration.js";
|
6
7
|
/**
|
7
8
|
* Configuration for the Fireworks.ai API.
|
@@ -13,6 +14,16 @@ import { TogetherAIApiConfiguration } from "./TogetherAIApiConfiguration.js";
|
|
13
14
|
export function FireworksAIApi(settings = {}) {
|
14
15
|
return new FireworksAIApiConfiguration(settings);
|
15
16
|
}
|
17
|
+
/**
|
18
|
+
* Configuration for the Perplexity API.
|
19
|
+
*
|
20
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
21
|
+
*
|
22
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
23
|
+
*/
|
24
|
+
export function PerplexityApi(settings = {}) {
|
25
|
+
return new PerplexityApiConfiguration(settings);
|
26
|
+
}
|
16
27
|
/**
|
17
28
|
* Configuration for the Together.ai API.
|
18
29
|
*
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PerplexityApiConfiguration = void 0;
|
4
|
+
const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
|
5
|
+
const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
|
6
|
+
/**
|
7
|
+
* Configuration for the Perplexity API.
|
8
|
+
*
|
9
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
10
|
+
*
|
11
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
12
|
+
*/
|
13
|
+
class PerplexityApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfigurationWithDefaults {
|
14
|
+
constructor(settings = {}) {
|
15
|
+
super({
|
16
|
+
...settings,
|
17
|
+
headers: {
|
18
|
+
Authorization: `Bearer ${(0, loadApiKey_js_1.loadApiKey)({
|
19
|
+
apiKey: settings.apiKey,
|
20
|
+
environmentVariableName: "PERPLEXITY_API_KEY",
|
21
|
+
description: "Perplexity",
|
22
|
+
})}`,
|
23
|
+
},
|
24
|
+
baseUrlDefaults: {
|
25
|
+
protocol: "https",
|
26
|
+
host: "api.perplexity.ai",
|
27
|
+
port: "443",
|
28
|
+
path: "",
|
29
|
+
},
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}
|
33
|
+
exports.PerplexityApiConfiguration = PerplexityApiConfiguration;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { BaseUrlApiConfigurationWithDefaults, PartialBaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlApiConfiguration.js";
|
2
|
+
/**
|
3
|
+
* Configuration for the Perplexity API.
|
4
|
+
*
|
5
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
6
|
+
*
|
7
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
8
|
+
*/
|
9
|
+
export declare class PerplexityApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
|
10
|
+
constructor(settings?: PartialBaseUrlPartsApiConfigurationOptions & {
|
11
|
+
apiKey?: string;
|
12
|
+
});
|
13
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { BaseUrlApiConfigurationWithDefaults, } from "../../core/api/BaseUrlApiConfiguration.js";
|
2
|
+
import { loadApiKey } from "../../core/api/loadApiKey.js";
|
3
|
+
/**
|
4
|
+
* Configuration for the Perplexity API.
|
5
|
+
*
|
6
|
+
* It calls the API at https://api.perplexity.ai/ and uses the `PERPLEXITY_API_KEY` api key environment variable.
|
7
|
+
*
|
8
|
+
* @see https://docs.perplexity.ai/reference/post_chat_completions
|
9
|
+
*/
|
10
|
+
export class PerplexityApiConfiguration extends BaseUrlApiConfigurationWithDefaults {
|
11
|
+
constructor(settings = {}) {
|
12
|
+
super({
|
13
|
+
...settings,
|
14
|
+
headers: {
|
15
|
+
Authorization: `Bearer ${loadApiKey({
|
16
|
+
apiKey: settings.apiKey,
|
17
|
+
environmentVariableName: "PERPLEXITY_API_KEY",
|
18
|
+
description: "Perplexity",
|
19
|
+
})}`,
|
20
|
+
},
|
21
|
+
baseUrlDefaults: {
|
22
|
+
protocol: "https",
|
23
|
+
host: "api.perplexity.ai",
|
24
|
+
port: "443",
|
25
|
+
path: "",
|
26
|
+
},
|
27
|
+
});
|
28
|
+
}
|
29
|
+
}
|
@@ -30,7 +30,8 @@ exports.openaicompatible = void 0;
|
|
30
30
|
__exportStar(require("./FireworksAIApiConfiguration.cjs"), exports);
|
31
31
|
__exportStar(require("./OpenAICompatibleChatModel.cjs"), exports);
|
32
32
|
__exportStar(require("./OpenAICompatibleCompletionModel.cjs"), exports);
|
33
|
-
__exportStar(require("./OpenAICompatibleTextEmbeddingModel.cjs"), exports);
|
34
33
|
exports.openaicompatible = __importStar(require("./OpenAICompatibleFacade.cjs"));
|
35
34
|
__exportStar(require("./OpenAICompatibleProviderName.cjs"), exports);
|
35
|
+
__exportStar(require("./OpenAICompatibleTextEmbeddingModel.cjs"), exports);
|
36
|
+
__exportStar(require("./PerplexityApiConfiguration.cjs"), exports);
|
36
37
|
__exportStar(require("./TogetherAIApiConfiguration.cjs"), exports);
|
@@ -1,7 +1,8 @@
|
|
1
1
|
export * from "./FireworksAIApiConfiguration.js";
|
2
2
|
export * from "./OpenAICompatibleChatModel.js";
|
3
3
|
export * from "./OpenAICompatibleCompletionModel.js";
|
4
|
-
export * from "./OpenAICompatibleTextEmbeddingModel.js";
|
5
4
|
export * as openaicompatible from "./OpenAICompatibleFacade.js";
|
6
5
|
export * from "./OpenAICompatibleProviderName.js";
|
6
|
+
export * from "./OpenAICompatibleTextEmbeddingModel.js";
|
7
|
+
export * from "./PerplexityApiConfiguration.js";
|
7
8
|
export * from "./TogetherAIApiConfiguration.js";
|
@@ -1,7 +1,8 @@
|
|
1
1
|
export * from "./FireworksAIApiConfiguration.js";
|
2
2
|
export * from "./OpenAICompatibleChatModel.js";
|
3
3
|
export * from "./OpenAICompatibleCompletionModel.js";
|
4
|
-
export * from "./OpenAICompatibleTextEmbeddingModel.js";
|
5
4
|
export * as openaicompatible from "./OpenAICompatibleFacade.js";
|
6
5
|
export * from "./OpenAICompatibleProviderName.js";
|
6
|
+
export * from "./OpenAICompatibleTextEmbeddingModel.js";
|
7
|
+
export * from "./PerplexityApiConfiguration.js";
|
7
8
|
export * from "./TogetherAIApiConfiguration.js";
|
package/package.json
CHANGED
package/tool/index.cjs
CHANGED
@@ -27,5 +27,5 @@ __exportStar(require("./WebSearchTool.cjs"), exports);
|
|
27
27
|
__exportStar(require("./execute-tool/index.cjs"), exports);
|
28
28
|
__exportStar(require("./generate-tool-call/index.cjs"), exports);
|
29
29
|
__exportStar(require("./generate-tool-calls/index.cjs"), exports);
|
30
|
-
__exportStar(require("./
|
31
|
-
__exportStar(require("./
|
30
|
+
__exportStar(require("./run-tool/index.cjs"), exports);
|
31
|
+
__exportStar(require("./run-tools/index.cjs"), exports);
|
package/tool/index.d.ts
CHANGED
@@ -11,5 +11,5 @@ export * from "./WebSearchTool.js";
|
|
11
11
|
export * from "./execute-tool/index.js";
|
12
12
|
export * from "./generate-tool-call/index.js";
|
13
13
|
export * from "./generate-tool-calls/index.js";
|
14
|
-
export * from "./
|
15
|
-
export * from "./
|
14
|
+
export * from "./run-tool/index.js";
|
15
|
+
export * from "./run-tools/index.js";
|
package/tool/index.js
CHANGED
@@ -11,5 +11,5 @@ export * from "./WebSearchTool.js";
|
|
11
11
|
export * from "./execute-tool/index.js";
|
12
12
|
export * from "./generate-tool-call/index.js";
|
13
13
|
export * from "./generate-tool-calls/index.js";
|
14
|
-
export * from "./
|
15
|
-
export * from "./
|
14
|
+
export * from "./run-tool/index.js";
|
15
|
+
export * from "./run-tools/index.js";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { BaseFunctionFinishedEvent, BaseFunctionStartedEvent } from "../../core/FunctionEvent.js";
|
2
|
+
export interface runToolStartedEvent extends BaseFunctionStartedEvent {
|
3
|
+
functionType: "run-tool";
|
4
|
+
}
|
5
|
+
export interface runToolFinishedEvent extends BaseFunctionFinishedEvent {
|
6
|
+
functionType: "run-tool";
|
7
|
+
}
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./
|
18
|
-
__exportStar(require("./
|
17
|
+
__exportStar(require("./RunToolEvent.cjs"), exports);
|
18
|
+
__exportStar(require("./runTool.cjs"), exports);
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.runTool = void 0;
|
4
4
|
const executeFunctionCall_js_1 = require("../../core/executeFunctionCall.cjs");
|
5
5
|
const safeExecuteToolCall_js_1 = require("../execute-tool/safeExecuteToolCall.cjs");
|
6
6
|
const generateToolCall_js_1 = require("../generate-tool-call/generateToolCall.cjs");
|
7
7
|
/**
|
8
|
-
* `
|
8
|
+
* `runTool` uses `generateToolCall` to generate parameters for a tool and
|
9
9
|
* then executes the tool with the parameters using `executeTool`.
|
10
10
|
*
|
11
11
|
* @returns The result contains the name of the tool (`tool` property),
|
@@ -15,7 +15,7 @@ const generateToolCall_js_1 = require("../generate-tool-call/generateToolCall.cj
|
|
15
15
|
* @see {@link generateToolCall}
|
16
16
|
* @see {@link executeTool}
|
17
17
|
*/
|
18
|
-
async function
|
18
|
+
async function runTool({ model, tool, prompt, ...options }) {
|
19
19
|
// Note: PROMPT must not be a function.
|
20
20
|
const expandedPrompt = typeof prompt === "function"
|
21
21
|
? prompt(tool)
|
@@ -23,8 +23,8 @@ async function useTool({ model, tool, prompt, ...options }) {
|
|
23
23
|
return (0, executeFunctionCall_js_1.executeFunctionCall)({
|
24
24
|
options,
|
25
25
|
input: expandedPrompt,
|
26
|
-
functionType: "
|
26
|
+
functionType: "run-tool",
|
27
27
|
execute: async (options) => (0, safeExecuteToolCall_js_1.safeExecuteToolCall)(tool, await (0, generateToolCall_js_1.generateToolCall)({ model, tool, prompt: expandedPrompt, ...options }), options),
|
28
28
|
});
|
29
29
|
}
|
30
|
-
exports.
|
30
|
+
exports.runTool = runTool;
|
@@ -3,7 +3,7 @@ import { Tool } from "../Tool.js";
|
|
3
3
|
import { ToolCallResult } from "../ToolCallResult.js";
|
4
4
|
import { ToolCallGenerationModel, ToolCallGenerationModelSettings } from "../generate-tool-call/ToolCallGenerationModel.js";
|
5
5
|
/**
|
6
|
-
* `
|
6
|
+
* `runTool` uses `generateToolCall` to generate parameters for a tool and
|
7
7
|
* then executes the tool with the parameters using `executeTool`.
|
8
8
|
*
|
9
9
|
* @returns The result contains the name of the tool (`tool` property),
|
@@ -13,7 +13,7 @@ import { ToolCallGenerationModel, ToolCallGenerationModelSettings } from "../gen
|
|
13
13
|
* @see {@link generateToolCall}
|
14
14
|
* @see {@link executeTool}
|
15
15
|
*/
|
16
|
-
export declare function
|
16
|
+
export declare function runTool<PROMPT, TOOL extends Tool<string, any, any>>({ model, tool, prompt, ...options }: {
|
17
17
|
model: ToolCallGenerationModel<PROMPT, ToolCallGenerationModelSettings>;
|
18
18
|
tool: TOOL;
|
19
19
|
prompt: PROMPT | ((tool: TOOL) => PROMPT);
|
@@ -2,7 +2,7 @@ import { executeFunctionCall } from "../../core/executeFunctionCall.js";
|
|
2
2
|
import { safeExecuteToolCall } from "../execute-tool/safeExecuteToolCall.js";
|
3
3
|
import { generateToolCall } from "../generate-tool-call/generateToolCall.js";
|
4
4
|
/**
|
5
|
-
* `
|
5
|
+
* `runTool` uses `generateToolCall` to generate parameters for a tool and
|
6
6
|
* then executes the tool with the parameters using `executeTool`.
|
7
7
|
*
|
8
8
|
* @returns The result contains the name of the tool (`tool` property),
|
@@ -12,7 +12,7 @@ import { generateToolCall } from "../generate-tool-call/generateToolCall.js";
|
|
12
12
|
* @see {@link generateToolCall}
|
13
13
|
* @see {@link executeTool}
|
14
14
|
*/
|
15
|
-
export async function
|
15
|
+
export async function runTool({ model, tool, prompt, ...options }) {
|
16
16
|
// Note: PROMPT must not be a function.
|
17
17
|
const expandedPrompt = typeof prompt === "function"
|
18
18
|
? prompt(tool)
|
@@ -20,7 +20,7 @@ export async function useTool({ model, tool, prompt, ...options }) {
|
|
20
20
|
return executeFunctionCall({
|
21
21
|
options,
|
22
22
|
input: expandedPrompt,
|
23
|
-
functionType: "
|
23
|
+
functionType: "run-tool",
|
24
24
|
execute: async (options) => safeExecuteToolCall(tool, await generateToolCall({ model, tool, prompt: expandedPrompt, ...options }), options),
|
25
25
|
});
|
26
26
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { BaseFunctionFinishedEvent, BaseFunctionStartedEvent } from "../../core/FunctionEvent.js";
|
2
|
+
export interface runToolsStartedEvent extends BaseFunctionStartedEvent {
|
3
|
+
functionType: "run-tools";
|
4
|
+
}
|
5
|
+
export interface runToolsFinishedEvent extends BaseFunctionFinishedEvent {
|
6
|
+
functionType: "run-tools";
|
7
|
+
}
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./
|
18
|
-
__exportStar(require("./
|
17
|
+
__exportStar(require("./RunToolsEvent.cjs"), exports);
|
18
|
+
__exportStar(require("./runTools.cjs"), exports);
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.runTools = void 0;
|
4
4
|
const executeFunctionCall_js_1 = require("../../core/executeFunctionCall.cjs");
|
5
5
|
const ToolCallError_js_1 = require("../ToolCallError.cjs");
|
6
6
|
const safeExecuteToolCall_js_1 = require("../execute-tool/safeExecuteToolCall.cjs");
|
7
7
|
const generateToolCalls_js_1 = require("../generate-tool-calls/generateToolCalls.cjs");
|
8
|
-
async function
|
8
|
+
async function runTools({ model, tools, prompt, ...options }) {
|
9
9
|
// Note: PROMPT must not be a function.
|
10
10
|
const expandedPrompt = typeof prompt === "function"
|
11
11
|
? prompt(tools)
|
@@ -13,7 +13,7 @@ async function useTools({ model, tools, prompt, ...options }) {
|
|
13
13
|
return (0, executeFunctionCall_js_1.executeFunctionCall)({
|
14
14
|
options,
|
15
15
|
input: expandedPrompt,
|
16
|
-
functionType: "
|
16
|
+
functionType: "run-tools",
|
17
17
|
execute: async (options) => {
|
18
18
|
const modelResponse = await (0, generateToolCalls_js_1.generateToolCalls)({
|
19
19
|
model,
|
@@ -51,4 +51,4 @@ async function useTools({ model, tools, prompt, ...options }) {
|
|
51
51
|
},
|
52
52
|
});
|
53
53
|
}
|
54
|
-
exports.
|
54
|
+
exports.runTools = runTools;
|
@@ -11,7 +11,7 @@ type ToToolCallUnion<T> = {
|
|
11
11
|
[KEY in StringKeys<T>]: T[KEY] extends Tool<any, infer PARAMETERS, infer OUTPUT> ? ToolCallResult<KEY, PARAMETERS, OUTPUT> : never;
|
12
12
|
}[StringKeys<T>];
|
13
13
|
type ToOutputValue<TOOLS extends ToolArray<Tool<any, any, any>[]>> = ToToolCallUnion<ToToolMap<TOOLS>>;
|
14
|
-
export declare function
|
14
|
+
export declare function runTools<PROMPT, TOOLS extends Array<Tool<any, any, any>>>({ model, tools, prompt, ...options }: {
|
15
15
|
model: ToolCallsGenerationModel<PROMPT, ToolCallsGenerationModelSettings>;
|
16
16
|
tools: TOOLS;
|
17
17
|
prompt: PROMPT | ((tools: TOOLS) => PROMPT);
|
@@ -2,7 +2,7 @@ import { executeFunctionCall } from "../../core/executeFunctionCall.js";
|
|
2
2
|
import { ToolCallError } from "../ToolCallError.js";
|
3
3
|
import { safeExecuteToolCall } from "../execute-tool/safeExecuteToolCall.js";
|
4
4
|
import { generateToolCalls } from "../generate-tool-calls/generateToolCalls.js";
|
5
|
-
export async function
|
5
|
+
export async function runTools({ model, tools, prompt, ...options }) {
|
6
6
|
// Note: PROMPT must not be a function.
|
7
7
|
const expandedPrompt = typeof prompt === "function"
|
8
8
|
? prompt(tools)
|
@@ -10,7 +10,7 @@ export async function useTools({ model, tools, prompt, ...options }) {
|
|
10
10
|
return executeFunctionCall({
|
11
11
|
options,
|
12
12
|
input: expandedPrompt,
|
13
|
-
functionType: "
|
13
|
+
functionType: "run-tools",
|
14
14
|
execute: async (options) => {
|
15
15
|
const modelResponse = await generateToolCalls({
|
16
16
|
model,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { BaseFunctionFinishedEvent, BaseFunctionStartedEvent } from "../../core/FunctionEvent.js";
|
2
|
-
export interface UseToolStartedEvent extends BaseFunctionStartedEvent {
|
3
|
-
functionType: "use-tool";
|
4
|
-
}
|
5
|
-
export interface UseToolFinishedEvent extends BaseFunctionFinishedEvent {
|
6
|
-
functionType: "use-tool";
|
7
|
-
}
|
package/tool/use-tool/index.d.ts
DELETED
package/tool/use-tool/index.js
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import { BaseFunctionFinishedEvent, BaseFunctionStartedEvent } from "../../core/FunctionEvent.js";
|
2
|
-
export interface useToolsStartedEvent extends BaseFunctionStartedEvent {
|
3
|
-
functionType: "use-tools";
|
4
|
-
}
|
5
|
-
export interface useToolsFinishedEvent extends BaseFunctionFinishedEvent {
|
6
|
-
functionType: "use-tools";
|
7
|
-
}
|
package/tool/use-tools/index.js
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|