@promptbook/cli 0.114.0-33 → 0.114.0-34
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/esm/index.es.js +1254 -318
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/createFreeDiskSpaceGuard.d.ts +25 -0
- package/esm/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
- package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +21 -3
- package/esm/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +77 -0
- package/esm/scripts/run-codex-prompts/prompts/buildPromptRunTracePath.d.ts +10 -0
- package/esm/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +11 -6
- package/esm/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/prompts/writePromptRunTrace.d.ts +19 -0
- package/esm/scripts/run-codex-prompts/runners/common/buildHarnessAuthenticationError.d.ts +20 -0
- package/esm/scripts/run-codex-prompts/runners/common/createAuthenticationAwarePromptRunner.d.ts +11 -0
- package/esm/scripts/run-codex-prompts/runners/common/extractHarnessAuthenticationFailureReason.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +3 -0
- package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
- package/esm/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
- package/esm/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +2 -1
- package/esm/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
- package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
- package/esm/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
- package/esm/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
- package/esm/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
- package/esm/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
- package/esm/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
- package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
- package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
- package/esm/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
- package/esm/src/cli/cli-commands/common/$askForConfirmation.d.ts +4 -2
- package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
- package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
- package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
- package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
- package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
- package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
- package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +2 -1
- package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -2
- package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +26 -0
- package/esm/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +4 -2
- package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +2 -1
- package/esm/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
- package/esm/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
- package/esm/src/cli/common/$deprecateCliCommand.d.ts +3 -0
- package/esm/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
- package/esm/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
- package/esm/src/cli/common/$requireCliSubcommand.d.ts +18 -0
- package/esm/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
- package/esm/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +8 -11
- package/src/book-2.0/book-language-documentation/getSafeCodeBlock.ts +1 -1
- package/src/book-components/Chat/MockedChat/MockedChat.tsx +25 -1
- package/src/cli/cli-commands/agent-folder.ts +2 -6
- package/src/cli/cli-commands/agent.ts +2 -6
- package/src/cli/cli-commands/agents-server.ts +2 -6
- package/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.ts +3 -0
- package/src/cli/cli-commands/coder/add.ts +27 -2
- package/src/cli/cli-commands/coder/agentCliOptions.ts +32 -0
- package/src/cli/cli-commands/coder/boilerplateTemplates.ts +17 -44
- package/src/cli/cli-commands/coder/coderReferencedArtifacts.ts +106 -0
- package/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.ts +4 -2
- package/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.ts +5 -1
- package/src/cli/cli-commands/coder/ensureDirectory.ts +27 -1
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +99 -10
- package/src/cli/cli-commands/coder/init.ts +23 -14
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +18 -27
- package/src/cli/cli-commands/coder/list.ts +15 -3
- package/src/cli/cli-commands/coder/mergeStringRecordJsonFile.ts +31 -7
- package/src/cli/cli-commands/coder/ping.ts +25 -22
- package/src/cli/cli-commands/coder/printCoderRunFailure.ts +14 -0
- package/src/cli/cli-commands/coder/printInitializationSummary.ts +23 -16
- package/src/cli/cli-commands/coder/run.ts +34 -23
- package/src/cli/cli-commands/coder/server.ts +43 -32
- package/src/cli/cli-commands/coder.ts +2 -6
- package/src/cli/cli-commands/common/$askForConfirmation.ts +12 -2
- package/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.ts +35 -0
- package/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.ts +37 -0
- package/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.ts +39 -0
- package/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.ts +26 -0
- package/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.ts +33 -0
- package/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.ts +33 -0
- package/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.ts +21 -0
- package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +17 -5
- package/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.ts +8 -3
- package/src/cli/cli-commands/common/harness/HarnessDefinition.ts +36 -0
- package/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.ts +8 -3
- package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +13 -2
- package/src/cli/cli-commands/common/questionsCliOptions.ts +89 -0
- package/src/cli/cli-commands/run.ts +3 -1
- package/src/cli/common/$deprecateCliCommand.ts +5 -0
- package/src/cli/common/$hideCliCommandFromHelp.ts +27 -0
- package/src/cli/common/$requireCliSubcommand.ts +35 -0
- package/src/cli/promptbookCli.ts +13 -9
- package/src/llm-providers/vercel/VercelExecutionToolsOptions.ts +7 -2
- package/src/llm-providers/vercel/createExecutionToolsFromVercelProvider.ts +18 -17
- package/src/other/templates/getTemplatesPipelineCollection.ts +677 -881
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +1253 -317
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/createFreeDiskSpaceGuard.d.ts +25 -0
- package/umd/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
- package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +21 -3
- package/umd/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +77 -0
- package/umd/scripts/run-codex-prompts/prompts/buildPromptRunTracePath.d.ts +10 -0
- package/umd/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +11 -6
- package/umd/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/prompts/writePromptRunTrace.d.ts +19 -0
- package/umd/scripts/run-codex-prompts/runners/common/buildHarnessAuthenticationError.d.ts +20 -0
- package/umd/scripts/run-codex-prompts/runners/common/createAuthenticationAwarePromptRunner.d.ts +11 -0
- package/umd/scripts/run-codex-prompts/runners/common/extractHarnessAuthenticationFailureReason.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +3 -0
- package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
- package/umd/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
- package/umd/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +2 -1
- package/umd/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
- package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
- package/umd/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
- package/umd/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
- package/umd/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
- package/umd/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
- package/umd/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
- package/umd/src/cli/cli-commands/coder/init.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
- package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
- package/umd/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
- package/umd/src/cli/cli-commands/common/$askForConfirmation.d.ts +4 -2
- package/umd/src/cli/cli-commands/common/$askForConfirmation.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
- package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
- package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
- package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
- package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
- package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
- package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +2 -1
- package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -2
- package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +26 -0
- package/umd/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +4 -2
- package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +2 -1
- package/umd/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
- package/umd/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
- package/umd/src/cli/common/$deprecateCliCommand.d.ts +3 -0
- package/umd/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
- package/umd/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
- package/umd/src/cli/common/$requireCliSubcommand.d.ts +18 -0
- package/umd/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
- package/umd/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
- package/umd/src/version.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +0 -29
- package/src/cli/cli-commands/coder/agentCodingFile.ts +0 -25
- package/src/cli/cli-commands/common/harnessUpdateCliOptions.ts +0 -46
- package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +0 -29
- /package/esm/src/cli/cli-commands/{common/harnessUpdateCliOptions.test.d.ts → coder/init.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts → esm/src/cli/cli-commands/common/$askForConfirmation.test.d.ts} +0 -0
package/src/cli/promptbookCli.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { $initializeStartPipelinesServerCommand } from './cli-commands/start-pip
|
|
|
22
22
|
import { $initializeTestCommand } from './cli-commands/test-command';
|
|
23
23
|
import { $addGlobalOptionsToCommand } from './common/$addGlobalOptionsToCommand';
|
|
24
24
|
import { $deprecateCliCommand } from './common/$deprecateCliCommand';
|
|
25
|
+
import { $reportMissingCliSubcommand } from './common/$requireCliSubcommand';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Shared deprecation text for top-level CLI commands backed by the old pipeline system.
|
|
@@ -97,10 +98,17 @@ export async function promptbookCli(): Promise<void> {
|
|
|
97
98
|
|
|
98
99
|
// Note: These options are valid for all commands
|
|
99
100
|
|
|
101
|
+
// Note: Commands are listed in the help in the order they are registered,
|
|
102
|
+
// `coder` is the most used one so it goes first and the deprecated ones,
|
|
103
|
+
// which `$deprecateTopLevelCommands` hides from the help entirely, go last
|
|
104
|
+
$initializeCoderCommand(program);
|
|
105
|
+
$initializeAgentCommand(program);
|
|
106
|
+
$initializeAgentFolderCommand(program);
|
|
107
|
+
$initializeAgentsServerCommand(program);
|
|
100
108
|
$initializeAboutCommand(program);
|
|
109
|
+
$initializeHelloCommand(program);
|
|
101
110
|
$initializeRunCommand(program);
|
|
102
111
|
$initializeLoginCommand(program);
|
|
103
|
-
$initializeHelloCommand(program);
|
|
104
112
|
$initializeMakeCommand(program);
|
|
105
113
|
$initializePrettifyCommand(program);
|
|
106
114
|
$initializeTestCommand(program);
|
|
@@ -108,19 +116,16 @@ export async function promptbookCli(): Promise<void> {
|
|
|
108
116
|
$initializeListScrapersCommand(program);
|
|
109
117
|
$initializeStartAgentsServerCommand(program);
|
|
110
118
|
$initializeStartPipelinesServerCommand(program);
|
|
111
|
-
$initializeAgentCommand(program);
|
|
112
|
-
$initializeAgentFolderCommand(program);
|
|
113
|
-
$initializeAgentsServerCommand(program);
|
|
114
|
-
$initializeCoderCommand(program);
|
|
115
119
|
|
|
116
120
|
$deprecateTopLevelCommands(program);
|
|
117
121
|
|
|
118
122
|
// TODO: [🧠] Should it be here or not> $addGlobalOptionsToCommand(program);
|
|
119
123
|
program.commands.forEach($addGlobalOptionsToCommand);
|
|
120
124
|
|
|
125
|
+
// Note: There is no default command, so `ptbk` without a subcommand asks for one
|
|
126
|
+
// instead of running the deprecated `ptbk run`
|
|
121
127
|
if (commandLineArguments.length === 0) {
|
|
122
|
-
program
|
|
123
|
-
return process.exit(0);
|
|
128
|
+
return $reportMissingCliSubcommand(program);
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
program.parse(process.argv);
|
|
@@ -138,7 +143,7 @@ function isTopLevelVersionRequested(commandLineArguments: ReadonlyArray<string>)
|
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
/**
|
|
141
|
-
*
|
|
146
|
+
* Marks each configured top-level legacy command as deprecated, which keeps it usable but takes it out of the help.
|
|
142
147
|
*/
|
|
143
148
|
function $deprecateTopLevelCommands(program: commander.Command): void {
|
|
144
149
|
for (const command of program.commands) {
|
|
@@ -151,7 +156,6 @@ function $deprecateTopLevelCommands(program: commander.Command): void {
|
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
// Note: [🟡] Code for CLI program [promptbookCli](src/cli/promptbookCli.ts) should never be published outside of `@promptbook/cli`
|
|
154
|
-
// TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book` -> `ptbk ./foo.book`
|
|
155
159
|
// TODO: [🥠] Do not export, its just for CLI script
|
|
156
160
|
// TODO: [🕌] When more functionalities, rename
|
|
157
161
|
// Note: 11:11
|
|
@@ -24,7 +24,12 @@ export type VercelExecutionToolsOptions = CommonToolsOptions &
|
|
|
24
24
|
// and not to pass it as a separate parameter
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Additional settings for chat models
|
|
27
|
+
* Additional settings for chat models, for example `temperature` or `providerOptions`
|
|
28
|
+
*
|
|
29
|
+
* Note: Since Vercel AI SDK v5 these settings belong to the model call, not to
|
|
30
|
+
* `vercelProvider.chat('model-name')` which takes just the model name
|
|
28
31
|
*/
|
|
29
|
-
readonly additionalChatSettings?: Partial<
|
|
32
|
+
readonly additionalChatSettings?: Partial<
|
|
33
|
+
Omit<Parameters<ReturnType<VercelProvider['chat']>['doGenerate']>[0], 'prompt'>
|
|
34
|
+
>;
|
|
30
35
|
};
|
|
@@ -34,7 +34,9 @@ const VERCEL_PROVIDER_PROFILE: ChatParticipant = {
|
|
|
34
34
|
*/
|
|
35
35
|
export function createExecutionToolsFromVercelProvider(options: VercelExecutionToolsOptions): LlmExecutionTools {
|
|
36
36
|
let { title, description } = options;
|
|
37
|
-
const { vercelProvider, availableModels,
|
|
37
|
+
const { vercelProvider, availableModels, additionalChatSettings = {} } = options;
|
|
38
|
+
// <- Note: `userId` is not forwarded, because Vercel AI SDK moved provider-specific settings like `user` from
|
|
39
|
+
// `vercelProvider.chat(modelName, settings)` into `providerOptions` which are keyed by the provider
|
|
38
40
|
|
|
39
41
|
if (!/Vercel/i.test(title)) {
|
|
40
42
|
title = `${title} (through Vercel)`;
|
|
@@ -89,10 +91,7 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
|
|
|
89
91
|
);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
const model = await vercelProvider.chat(modelName
|
|
93
|
-
user: userId?.toString() || undefined,
|
|
94
|
-
...additionalChatSettings,
|
|
95
|
-
});
|
|
94
|
+
const model = await vercelProvider.chat(modelName);
|
|
96
95
|
|
|
97
96
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
98
97
|
|
|
@@ -132,14 +131,9 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
|
|
|
132
131
|
|
|
133
132
|
const rawRequest: Parameters<typeof model.doGenerate>[0] = {
|
|
134
133
|
// <- TODO: [☂]
|
|
135
|
-
inputFormat: 'messages',
|
|
136
|
-
mode: {
|
|
137
|
-
type: 'regular',
|
|
138
|
-
tools: [
|
|
139
|
-
/* <- TODO: Pass the tools */
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
134
|
prompt: promptMessages,
|
|
135
|
+
// <- TODO: Pass the tools via `tools`
|
|
136
|
+
...additionalChatSettings,
|
|
143
137
|
};
|
|
144
138
|
|
|
145
139
|
const start: string_date_iso8601 = $getCurrentDate();
|
|
@@ -161,10 +155,17 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
|
|
|
161
155
|
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
162
156
|
}
|
|
163
157
|
|
|
164
|
-
|
|
158
|
+
// Note: Vercel AI SDK returns ordered content parts, the chat message is made only of the text parts
|
|
159
|
+
const responseTextParts = rawResponse.content.flatMap((contentPart) =>
|
|
160
|
+
contentPart.type === 'text' ? [contentPart.text] : [],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (responseTextParts.length === 0) {
|
|
165
164
|
throw new PipelineExecutionError('No response message');
|
|
166
165
|
}
|
|
167
166
|
|
|
167
|
+
const responseText = responseTextParts.join('');
|
|
168
|
+
|
|
168
169
|
const complete: string_date_iso8601 = $getCurrentDate();
|
|
169
170
|
|
|
170
171
|
const duration = uncertainNumber((new Date(complete).getTime() - new Date(start).getTime()) / 1000);
|
|
@@ -173,15 +174,15 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
|
|
|
173
174
|
price: UNCERTAIN_ZERO_VALUE, // <- TODO: [🕘] Price count
|
|
174
175
|
duration,
|
|
175
176
|
input: {
|
|
176
|
-
tokensCount: uncertainNumber(rawResponse.usage.
|
|
177
|
+
tokensCount: uncertainNumber(rawResponse.usage.inputTokens),
|
|
177
178
|
...computeUsageCounts(
|
|
178
179
|
rawPromptContent,
|
|
179
180
|
// <- TODO: [🕘][🙀] What about system message
|
|
180
181
|
),
|
|
181
182
|
},
|
|
182
183
|
output: {
|
|
183
|
-
tokensCount: uncertainNumber(rawResponse.usage.
|
|
184
|
-
...computeUsageCounts(
|
|
184
|
+
tokensCount: uncertainNumber(rawResponse.usage.outputTokens),
|
|
185
|
+
...computeUsageCounts(responseText),
|
|
185
186
|
},
|
|
186
187
|
};
|
|
187
188
|
|
|
@@ -189,7 +190,7 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
|
|
|
189
190
|
name: 'promptResult',
|
|
190
191
|
message: `Result of \`createExecutionToolsFromVercelProvider.callChatModel\``,
|
|
191
192
|
value: {
|
|
192
|
-
content:
|
|
193
|
+
content: responseText,
|
|
193
194
|
modelName,
|
|
194
195
|
timing: {
|
|
195
196
|
start,
|