@promptbook/cli 0.112.0-104 → 0.112.0-106
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/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
- package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
- package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
- package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
- package/apps/agents-server/src/app/api/upload/route.ts +48 -12
- package/apps/agents-server/src/app/layout.tsx +13 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
- package/apps/agents-server/src/constants/serverLimits.ts +22 -2
- package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +72 -8
- package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
- package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
- package/apps/agents-server/src/utils/serverLimits.ts +26 -1
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
- package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
- package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
- package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
- package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/esm/index.es.js +602 -39
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +28 -29
- package/src/book-components/BookEditor/BookEditor.tsx +10 -7
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
- package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +15 -15
- package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
- package/src/other/templates/getTemplatesPipelineCollection.ts +874 -760
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/umd/index.umd.js +602 -39
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
- package/apps/agents-server/src/utils/defaultAgents/defaultAgents.ts +0 -168
- package/apps/agents-server/src/utils/defaultAgents/installDefaultAgents.ts +0 -139
- package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
- package/src/_packages/browser.index.ts +0 -31
- package/src/_packages/browser.readme.md +0 -43
- package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
- package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
- package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
- package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
- package/src/commands/_common/parseCommand.test.ts.todo +0 -48
- package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
- package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
- package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
- package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
- package/src/execution/PromptbookFetch.test-type.ts +0 -14
- package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
- package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
- package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
- package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
- package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
- package/src/llm-providers/_multiple/playground/playground.ts +0 -141
- package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
- package/src/llm-providers/agent/playground/playground.ts +0 -190
- package/src/llm-providers/agent/playground/tsconfig.json +0 -19
- package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
- package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
- package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
- package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/ollama/playground/playground.ts +0 -120
- package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
- package/src/llm-providers/openai/playground/playground.ts +0 -406
- package/src/llm-providers/openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/remote/playground/playground.ts +0 -144
- package/src/llm-providers/remote/playground/tsconfig.json +0 -19
- package/src/llm-providers/vercel/playground/playground.ts +0 -133
- package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
- package/src/personas/preparePersona.test.ts.todo +0 -126
- package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
- package/src/playground/backup/playground-agent-os.txt +0 -62
- package/src/playground/backup/playground-brj-app.ts.txt +0 -302
- package/src/playground/backup/playground-browser-playwright.txt +0 -110
- package/src/playground/backup/playground-claude-mcp.txt +0 -43
- package/src/playground/backup/playground-document-conversion.txt +0 -84
- package/src/playground/backup/playground-glob.ts.txt +0 -42
- package/src/playground/backup/playground-mcp-server.txt +0 -1
- package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
- package/src/playground/backup/playground-openai-function-calling.txt +0 -131
- package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
- package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
- package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
- package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
- package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
- package/src/playground/permanent/_boilerplate.ts +0 -54
- package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
- package/src/playground/permanent/error-handling-playground.ts +0 -103
- package/src/playground/playground.ts +0 -36
- package/src/playground/tsconfig.json +0 -19
- package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
- package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
- package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
- package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
- package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
- package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
- package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
- package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
- package/src/scrapers/document/playground/tsconfig.json +0 -19
- package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
- package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
- package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
- package/src/scrapers/markdown/playground/tsconfig.json +0 -19
- package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
- package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
- package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
- package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
- package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
- package/src/scrapers/pdf/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
- package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
- package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
- package/src/storage/local-storage/getLocalStorage.ts +0 -33
- package/src/storage/local-storage/getSessionStorage.ts +0 -33
- package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
- package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
- package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
- package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
- package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
- package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
- package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
- package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
- package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
- package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
- package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
- package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
import * as dotenv from 'dotenv';
|
|
4
|
-
|
|
5
|
-
dotenv.config({ path: '.env' });
|
|
6
|
-
|
|
7
|
-
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
|
|
8
|
-
import { forEver, forTime } from 'waitasecond';
|
|
9
|
-
import { createPipelineCollectionFromDirectory } from '../../../collection/pipeline-collection/constructors/createPipelineCollectionFromDirectory';
|
|
10
|
-
import { CLI_APP_ID, PLAYGROUND_APP_ID } from '../../../config';
|
|
11
|
-
import { AuthenticationError } from '../../../errors/AuthenticationError';
|
|
12
|
-
import { startRemoteServer } from '../../../remote-server/startRemoteServer';
|
|
13
|
-
import { $provideFilesystemForNode } from '../../../scrapers/_common/register/$provideFilesystemForNode';
|
|
14
|
-
import { keepUnused } from '../../../utils/organization/keepUnused';
|
|
15
|
-
import { OpenAiExecutionTools } from '../../openai/OpenAiExecutionTools';
|
|
16
|
-
import '../../openai/register-constructor';
|
|
17
|
-
import { RemoteLlmExecutionTools } from '../RemoteLlmExecutionTools';
|
|
18
|
-
|
|
19
|
-
playground()
|
|
20
|
-
.catch((error) => {
|
|
21
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
22
|
-
console.error(error);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
})
|
|
25
|
-
.then(() => {
|
|
26
|
-
process.exit(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Handles playground.
|
|
31
|
-
*/
|
|
32
|
-
async function playground() {
|
|
33
|
-
console.info(`🧸 Remote server playground`);
|
|
34
|
-
|
|
35
|
-
// Do here stuff you want to test
|
|
36
|
-
//========================================>
|
|
37
|
-
|
|
38
|
-
console.info(colors.bgCyan('Playground:'), colors.bgWhite(`Starting remote server`));
|
|
39
|
-
startRemoteServer({
|
|
40
|
-
port: 4460,
|
|
41
|
-
isVerbose: true,
|
|
42
|
-
isAnonymousModeAllowed: true,
|
|
43
|
-
isApplicationModeAllowed: true,
|
|
44
|
-
collection: await createPipelineCollectionFromDirectory(
|
|
45
|
-
'./examples/pipelines/',
|
|
46
|
-
{
|
|
47
|
-
fs: $provideFilesystemForNode(),
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
isRecursive: false,
|
|
51
|
-
},
|
|
52
|
-
),
|
|
53
|
-
async login(loginRequest) {
|
|
54
|
-
const { appId, username, password } = loginRequest;
|
|
55
|
-
|
|
56
|
-
const allowedApps = [PLAYGROUND_APP_ID, CLI_APP_ID];
|
|
57
|
-
|
|
58
|
-
if (!allowedApps.includes(appId || '')) {
|
|
59
|
-
throw new AuthenticationError(
|
|
60
|
-
`\`appId\` must be ${allowedApps.map((appId) => `"${appId}"`).join(' or ')} but got "${appId}"`,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
keepUnused(password);
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
isSuccess: true,
|
|
68
|
-
message: `User "${username}" logged in successfully`,
|
|
69
|
-
identification: {
|
|
70
|
-
isAnonymous: false,
|
|
71
|
-
appId,
|
|
72
|
-
userId: 'user-' + username,
|
|
73
|
-
userToken: 'some-secret-token',
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
createLlmExecutionTools(options) {
|
|
78
|
-
const { appId, userId, customOptions } = options;
|
|
79
|
-
|
|
80
|
-
console.info(colors.bgCyan('Playground:'), { appId, userId, customOptions });
|
|
81
|
-
return new OpenAiExecutionTools(
|
|
82
|
-
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
83
|
-
{
|
|
84
|
-
isVerbose: true,
|
|
85
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
86
|
-
userId: userId,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
for (const mode of ['anonymous', 'collection'] as const) {
|
|
93
|
-
await forTime(500);
|
|
94
|
-
console.info(colors.bgCyan('Playground:'), colors.bgWhite(`Creating RemoteLlmExecutionTools (${mode} mode) `));
|
|
95
|
-
|
|
96
|
-
const remoteServerUrl = 'http://localhost:4460';
|
|
97
|
-
|
|
98
|
-
const tools = new RemoteLlmExecutionTools(
|
|
99
|
-
mode === 'anonymous'
|
|
100
|
-
? {
|
|
101
|
-
remoteServerUrl,
|
|
102
|
-
identification: {
|
|
103
|
-
isAnonymous: true,
|
|
104
|
-
userId: 'playground',
|
|
105
|
-
llmToolsConfiguration: [
|
|
106
|
-
{
|
|
107
|
-
title: 'OpenAI',
|
|
108
|
-
packageName: '@promptbook/openai',
|
|
109
|
-
className: 'OpenAiExecutionTools',
|
|
110
|
-
options: {
|
|
111
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
: {
|
|
118
|
-
remoteServerUrl,
|
|
119
|
-
identification: {
|
|
120
|
-
isAnonymous: false,
|
|
121
|
-
appId: PLAYGROUND_APP_ID,
|
|
122
|
-
userId: 'playground',
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
await forTime(500);
|
|
128
|
-
console.info(colors.bgCyan('Playground:'), colors.bgWhite(`Checking configuration...`));
|
|
129
|
-
await tools.checkConfiguration();
|
|
130
|
-
console.info(colors.bgCyan('Playground:'), colors.bgGreen(`Configuration checked!`));
|
|
131
|
-
|
|
132
|
-
await forTime(500);
|
|
133
|
-
console.info(colors.bgCyan('Playground:'), colors.bgWhite(`Listing models...`));
|
|
134
|
-
const models = await tools.listModels();
|
|
135
|
-
console.info({ models });
|
|
136
|
-
console.info(colors.bgCyan('Playground:'), colors.bgGreen(`Models listed!`));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
await forEver();
|
|
140
|
-
|
|
141
|
-
//========================================/
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Note: [⚫] Code for playground [remote playground](src/llm-providers/remote/playground/playground.ts) should never be published in any package
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"downlevelIteration": true,
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noImplicitThis": true,
|
|
11
|
-
"noImplicitAny": true,
|
|
12
|
-
"strictNullChecks": true,
|
|
13
|
-
"experimentalDecorators": true,
|
|
14
|
-
"noUnusedLocals": false,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"esModuleInterop": true
|
|
17
|
-
},
|
|
18
|
-
"exclude": ["node_modules"]
|
|
19
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
import * as dotenv from 'dotenv';
|
|
4
|
-
|
|
5
|
-
dotenv.config({ path: '.env' });
|
|
6
|
-
|
|
7
|
-
import { createOpenAI } from '@ai-sdk/openai';
|
|
8
|
-
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
|
|
9
|
-
import { embeddingVectorToString } from '../../../execution/embeddingVectorToString';
|
|
10
|
-
import type { Usage } from '../../../execution/Usage';
|
|
11
|
-
import { usageToHuman } from '../../../execution/utils/usageToHuman';
|
|
12
|
-
import type { Prompt } from '../../../types/Prompt';
|
|
13
|
-
import { keepUnused } from '../../../utils/organization/keepUnused';
|
|
14
|
-
import { countUsage } from '../../_common/utils/count-total-usage/countUsage';
|
|
15
|
-
import { createExecutionToolsFromVercelProvider } from '../createExecutionToolsFromVercelProvider';
|
|
16
|
-
|
|
17
|
-
playground()
|
|
18
|
-
.catch((error) => {
|
|
19
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
20
|
-
console.error(error);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
})
|
|
23
|
-
.then(() => {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Handles playground.
|
|
29
|
-
*/
|
|
30
|
-
async function playground() {
|
|
31
|
-
console.info(`🧸 Vercel Playground`);
|
|
32
|
-
|
|
33
|
-
// Do here stuff you want to test
|
|
34
|
-
//========================================>
|
|
35
|
-
|
|
36
|
-
const openaiVercelProvider = createOpenAI({
|
|
37
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
38
|
-
// custom settings, e.g.
|
|
39
|
-
compatibility: 'strict', // strict mode, enable when using the OpenAI API
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const openaiPromptbookExecutionTools = createExecutionToolsFromVercelProvider({
|
|
43
|
-
title: 'OpenAI',
|
|
44
|
-
vercelProvider: openaiVercelProvider,
|
|
45
|
-
availableModels: [
|
|
46
|
-
{
|
|
47
|
-
modelName: 'gpt-3.5-turbo',
|
|
48
|
-
modelVariant: 'CHAT',
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const toolsWithUsage = countUsage(openaiPromptbookExecutionTools);
|
|
54
|
-
|
|
55
|
-
toolsWithUsage.spending().subscribe((usage: Usage) => {
|
|
56
|
-
const wordCount = (usage?.input?.wordsCount?.value || 0) + (usage?.output?.wordsCount?.value || 0);
|
|
57
|
-
console.log(`[💸] Spending ${wordCount} words`);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
keepUnused(toolsWithUsage);
|
|
61
|
-
keepUnused(openaiPromptbookExecutionTools);
|
|
62
|
-
keepUnused(embeddingVectorToString);
|
|
63
|
-
keepUnused(usageToHuman);
|
|
64
|
-
keepUnused<Prompt>();
|
|
65
|
-
|
|
66
|
-
/*/
|
|
67
|
-
const models = await openaiPromptbookExecutionTools.listModels();
|
|
68
|
-
console.info({ models });
|
|
69
|
-
/**/
|
|
70
|
-
|
|
71
|
-
/**/
|
|
72
|
-
const chatPrompt = {
|
|
73
|
-
title: 'Promptbook speech',
|
|
74
|
-
parameters: {},
|
|
75
|
-
content: `Write me speech about Promptbook and how it can help me to build the most beautiful chatbot and change the world`,
|
|
76
|
-
modelRequirements: {
|
|
77
|
-
modelVariant: 'CHAT',
|
|
78
|
-
systemMessage: 'You are an assistant who only speaks in rhymes.',
|
|
79
|
-
temperature: 1.5,
|
|
80
|
-
},
|
|
81
|
-
} as const satisfies Prompt;
|
|
82
|
-
const chatPromptResult = await toolsWithUsage.callChatModel!(chatPrompt);
|
|
83
|
-
console.info({ chatPromptResult });
|
|
84
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
85
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(chatPrompt.content));
|
|
86
|
-
console.info(colors.bgGreen(' Chat: ') + colors.green(chatPromptResult.content));
|
|
87
|
-
/**/
|
|
88
|
-
|
|
89
|
-
/*/
|
|
90
|
-
const completionPrompt = {
|
|
91
|
-
title: 'Hello',
|
|
92
|
-
parameters: {},
|
|
93
|
-
content: `Hello, my name is Alice.`,
|
|
94
|
-
modelRequirements: {
|
|
95
|
-
modelVariant: 'COMPLETION',
|
|
96
|
-
},
|
|
97
|
-
} as const satisfies Prompt;
|
|
98
|
-
const completionPromptResult = await openaiPromptbookExecutionTools.callCompletionModel(completionPrompt);
|
|
99
|
-
console.info({ completionPromptResult });
|
|
100
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
101
|
-
console.info(colors.green(completionPrompt.content + completionPromptResult.content));
|
|
102
|
-
/**/
|
|
103
|
-
|
|
104
|
-
/*/
|
|
105
|
-
// TODO: Test Translations in playground
|
|
106
|
-
/**/
|
|
107
|
-
|
|
108
|
-
/*/
|
|
109
|
-
const prompt = {
|
|
110
|
-
title: 'Hello',
|
|
111
|
-
parameters: {},
|
|
112
|
-
content: `Hello, my name is Alice.`,
|
|
113
|
-
modelRequirements: {
|
|
114
|
-
modelVariant: 'EMBEDDING',
|
|
115
|
-
// modelName: 'text-embedding-ada-002',
|
|
116
|
-
},
|
|
117
|
-
} as const satisfies Prompt;
|
|
118
|
-
const promptResult = await openaiPromptbookExecutionTools.callEmbeddingModel(prompt);
|
|
119
|
-
console.info({ promptResult });
|
|
120
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
121
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(prompt.content));
|
|
122
|
-
console.info(colors.bgGreen(' Embedding: ') + colors.green(embeddingVectorToString(promptResult.content)));
|
|
123
|
-
/**/
|
|
124
|
-
|
|
125
|
-
/*/
|
|
126
|
-
// <- Note: [🤖] Test here new model variant if needed
|
|
127
|
-
/**/
|
|
128
|
-
|
|
129
|
-
//========================================/
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Note: [⚫] Code for playground [vercel playground](src/llm-providers/vercel/playground/playground.ts) should never be published in any package
|
|
133
|
-
// TODO: [main] !!3 Test here that `systemMessage`, `temperature` and `seed` are working correctly
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"downlevelIteration": true,
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noImplicitThis": true,
|
|
11
|
-
"noImplicitAny": true,
|
|
12
|
-
"strictNullChecks": true,
|
|
13
|
-
"experimentalDecorators": true,
|
|
14
|
-
"noUnusedLocals": false,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"esModuleInterop": true
|
|
17
|
-
},
|
|
18
|
-
"exclude": ["node_modules"]
|
|
19
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { $provideLlmToolsForTestingAndScriptsAndPlayground } from '../llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground';
|
|
3
|
-
import { preparePersona } from './preparePersona';
|
|
4
|
-
|
|
5
|
-
// Note: Every time there is an update in the model names, the tests need to be updated
|
|
6
|
-
// This is extremely annoying and should be done in better way
|
|
7
|
-
// Until then, this test is temporarily disabled
|
|
8
|
-
|
|
9
|
-
describe('how preparePersona works', () => {
|
|
10
|
-
it('should work with simple persona description', () =>
|
|
11
|
-
await expect(
|
|
12
|
-
preparePersona(`Copywriter`,{ llm: await $provideLlmToolsForTestingAndScriptsAndPlayground() }, {
|
|
13
|
-
|
|
14
|
-
}),
|
|
15
|
-
).resolves.toEqual({
|
|
16
|
-
modelVariant: 'CHAT',
|
|
17
|
-
modelName: 'gpt-4', // <- TODO: [💕] Allow to specify more model names or more general like gpt-4-*, 1234 context window etc.
|
|
18
|
-
|
|
19
|
-
/*/
|
|
20
|
-
systemMessage: 'You are an experienced AI engineer and a helpful assistant.',
|
|
21
|
-
temperature: 0.6,
|
|
22
|
-
/**/
|
|
23
|
-
|
|
24
|
-
/*/
|
|
25
|
-
systemMessage: 'You are a skilled copywriter capable of crafting compelling and high-quality content.',
|
|
26
|
-
temperature: 0.5,
|
|
27
|
-
/**/
|
|
28
|
-
|
|
29
|
-
/**/
|
|
30
|
-
systemMessage: 'You are an experienced AI engineer and helpful assistant.',
|
|
31
|
-
temperature: 0.5,
|
|
32
|
-
/**/
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
TODO: [🎰] Implement tests in such a way that they don't need to be updated every time the model names change
|
|
37
|
-
it('should work with advanced structured persona description', () =>
|
|
38
|
-
await expect(
|
|
39
|
-
preparePersona(
|
|
40
|
-
spaceTrim(`
|
|
41
|
-
Skilled Copywriter with 5 years of experience in the field.
|
|
42
|
-
|
|
43
|
-
- Experience with SEO and SEM
|
|
44
|
-
- Experience with social media
|
|
45
|
-
- Experience with email marketing
|
|
46
|
-
|
|
47
|
-
`),{ llm: await $provideLlmToolsForTestingAndScriptsAndPlayground() },
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
),
|
|
52
|
-
).resolves.toEqual({
|
|
53
|
-
modelVariant: 'CHAT',
|
|
54
|
-
modelName: 'gpt-4-turbo', // <- TODO: [💕]
|
|
55
|
-
systemMessage: 'You are an experienced AI engineer and a helpful assistant.',
|
|
56
|
-
temperature: 0.6,
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
it('should work with creative persona', () =>
|
|
60
|
-
await expect(
|
|
61
|
-
preparePersona(`Poem writer with unconventional style of writing in his own language and style`,{ llm: $provideLlmToolsForTestingAndScriptsAndPlayground() }, {
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
).resolves.toEqual({
|
|
65
|
-
modelVariant: 'CHAT',
|
|
66
|
-
modelName: 'gpt-4', // <- TODO: [💕]
|
|
67
|
-
systemMessage:
|
|
68
|
-
'You are a poem writer with an unconventional style, crafting verses in your unique language and style.',
|
|
69
|
-
temperature: 0.6,
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
it('should work with non-creative persona', () =>
|
|
73
|
-
await expect(
|
|
74
|
-
preparePersona(
|
|
75
|
-
`Technical writer with 5 years of experience in the field. Experience with writing technical documentation, user manuals, and API documentation.`,
|
|
76
|
-
{ llm: await $provideLlmToolsForTestingAndScriptsAndPlayground() },{
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
),
|
|
80
|
-
).resolves.toEqual({
|
|
81
|
-
modelVariant: 'CHAT',
|
|
82
|
-
modelName: 'gpt-4', // <- TODO: [💕]
|
|
83
|
-
systemMessage:
|
|
84
|
-
'You are a technical writer with 5 years of experience, skilled in creating technical documentation, user manuals, and API documentation.',
|
|
85
|
-
temperature: 0.5,
|
|
86
|
-
}));
|
|
87
|
-
|
|
88
|
-
it('should work French native speaker', () =>
|
|
89
|
-
await expect(
|
|
90
|
-
preparePersona(
|
|
91
|
-
`Locuteur natif français, j'aime écrire et je suis passionné par la langue et la culture française.`,
|
|
92
|
-
{ llm: await $provideLlmToolsForTestingAndScriptsAndPlayground() },{
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
),
|
|
96
|
-
).resolves.toEqual({
|
|
97
|
-
modelVariant: 'CHAT',
|
|
98
|
-
modelName: 'gpt-4-turbo', // <- TODO: [💕]
|
|
99
|
-
systemMessage:
|
|
100
|
-
'You are an experienced AI engineer and helpful assistant who is a native French speaker, passionate about writing, language, and French culture.',
|
|
101
|
-
temperature: 0.5,
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
it('should work with weird persona description', () =>
|
|
105
|
-
await expect(
|
|
106
|
-
preparePersona(`Xyzzy with 5 years of experience in the field. Experience with foo and bar.`, { llm: await $provideLlmToolsForTestingAndScriptsAndPlayground() },{
|
|
107
|
-
|
|
108
|
-
}),
|
|
109
|
-
).resolves.toEqual({
|
|
110
|
-
modelVariant: 'CHAT',
|
|
111
|
-
modelName: 'gpt-4', // <- TODO: [💕]
|
|
112
|
-
systemMessage:
|
|
113
|
-
'You are Xyzzy, an experienced AI engineer with 5 years in the field, proficient in technologies such as foo and bar. You assist users with detailed and informed responses.',
|
|
114
|
-
temperature: 0.5,
|
|
115
|
-
}));
|
|
116
|
-
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
Note: Probably no failure cases needed
|
|
121
|
-
> it('should NOT work with bar', () =>
|
|
122
|
-
> expect(
|
|
123
|
-
> preparePersona({...}),
|
|
124
|
-
> ).rejects.toThrowError(/---/));
|
|
125
|
-
*/
|
|
126
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
import * as dotenv from 'dotenv';
|
|
4
|
-
|
|
5
|
-
dotenv.config({ path: '.env' });
|
|
6
|
-
|
|
7
|
-
import colors from 'colors';
|
|
8
|
-
import { join } from 'path';
|
|
9
|
-
|
|
10
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
11
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
playground()
|
|
16
|
-
.catch((error) => {
|
|
17
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
18
|
-
console.error(error);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
})
|
|
21
|
-
.then(() => {
|
|
22
|
-
process.exit(0);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
async function playground() {
|
|
26
|
-
console.info(`🧸 Playground`);
|
|
27
|
-
|
|
28
|
-
// Do here stuff you want to test
|
|
29
|
-
//========================================>
|
|
30
|
-
|
|
31
|
-
//========================================/
|
|
32
|
-
|
|
33
|
-
console.info(`[ Done 🧸 Playground ]`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/** Note: [⚫] Code for archived playground [_playground-boilerplate.ts](src/playground/backup/_playground-boilerplate.ts.txt) should never be published in any package */
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
import { AgentOs } from '@rivet-dev/agent-os-core';
|
|
4
|
-
import * as dotenv from 'dotenv';
|
|
5
|
-
|
|
6
|
-
dotenv.config({ path: '.env' });
|
|
7
|
-
|
|
8
|
-
import colors from 'colors';
|
|
9
|
-
import { join } from 'path';
|
|
10
|
-
import { spaceTrim } from 'spacetrim';
|
|
11
|
-
|
|
12
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
13
|
-
console.error(
|
|
14
|
-
colors.red(
|
|
15
|
-
spaceTrim(`
|
|
16
|
-
CWD must be root of the project
|
|
17
|
-
|
|
18
|
-
Script: playground.ts
|
|
19
|
-
Current CWD: ${process.cwd()}
|
|
20
|
-
Expected CWD: ${join(__dirname, '../..')}
|
|
21
|
-
`),
|
|
22
|
-
),
|
|
23
|
-
);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
playground()
|
|
28
|
-
.catch((error) => {
|
|
29
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
30
|
-
console.error(error);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
})
|
|
33
|
-
.then(() => {
|
|
34
|
-
process.exit(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Handles playground.
|
|
39
|
-
*/
|
|
40
|
-
async function playground() {
|
|
41
|
-
console.info(`🧸 Playground`);
|
|
42
|
-
|
|
43
|
-
// Do here stuff you want to test
|
|
44
|
-
//========================================>
|
|
45
|
-
|
|
46
|
-
const vm = await AgentOs.create();
|
|
47
|
-
|
|
48
|
-
// Create an agent session
|
|
49
|
-
const { sessionId } = await vm.createSession('pi');
|
|
50
|
-
|
|
51
|
-
// Stream events (tool calls, text output, etc.)
|
|
52
|
-
vm.onSessionEvent(sessionId, (event) => console.log(event));
|
|
53
|
-
|
|
54
|
-
// Send a prompt and wait for the response
|
|
55
|
-
await vm.prompt(sessionId, 'Write a Python script that calculates pi');
|
|
56
|
-
|
|
57
|
-
//========================================/
|
|
58
|
-
|
|
59
|
-
console.info(`[ Done 🧸 Playground ]`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Note: [⚫] Code for playground [main playground](src/playground/playground.ts) should never be published in any package
|