@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,141 +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 { embeddingVectorToString } from '../../../execution/embeddingVectorToString';
|
|
9
|
-
import { usageToHuman } from '../../../execution/utils/usageToHuman';
|
|
10
|
-
import { $provideScriptingForNode } from '../../../scrapers/_common/register/$provideScriptingForNode';
|
|
11
|
-
import type { Prompt } from '../../../types/Prompt';
|
|
12
|
-
import { keepUnused } from '../../../utils/organization/keepUnused';
|
|
13
|
-
import { AnthropicClaudeExecutionTools } from '../../anthropic-claude/AnthropicClaudeExecutionTools';
|
|
14
|
-
import { AzureOpenAiExecutionTools } from '../../azure-openai/AzureOpenAiExecutionTools';
|
|
15
|
-
import { OpenAiExecutionTools } from '../../openai/OpenAiExecutionTools';
|
|
16
|
-
import { joinLlmExecutionTools } from '../joinLlmExecutionTools';
|
|
17
|
-
|
|
18
|
-
playground()
|
|
19
|
-
.catch((error) => {
|
|
20
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
21
|
-
console.error(error);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
})
|
|
24
|
-
.then(() => {
|
|
25
|
-
process.exit(0);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Handles playground.
|
|
30
|
-
*/
|
|
31
|
-
async function playground() {
|
|
32
|
-
console.info(`🧸 Multiple LLMs Playground`);
|
|
33
|
-
|
|
34
|
-
// Do here stuff you want to test
|
|
35
|
-
//========================================>
|
|
36
|
-
|
|
37
|
-
const tools = {
|
|
38
|
-
llm: [
|
|
39
|
-
new OpenAiExecutionTools(
|
|
40
|
-
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
41
|
-
{
|
|
42
|
-
isVerbose: true,
|
|
43
|
-
userId: 'playground',
|
|
44
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
45
|
-
},
|
|
46
|
-
),
|
|
47
|
-
new AnthropicClaudeExecutionTools(
|
|
48
|
-
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
49
|
-
{
|
|
50
|
-
isVerbose: true,
|
|
51
|
-
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY!,
|
|
52
|
-
},
|
|
53
|
-
),
|
|
54
|
-
new AzureOpenAiExecutionTools(
|
|
55
|
-
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
56
|
-
{
|
|
57
|
-
isVerbose: true,
|
|
58
|
-
userId: 'playground',
|
|
59
|
-
resourceName: process.env.AZUREOPENAI_RESOURCE_NAME!,
|
|
60
|
-
deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME!,
|
|
61
|
-
apiKey: process.env.AZUREOPENAI_API_KEY!,
|
|
62
|
-
},
|
|
63
|
-
),
|
|
64
|
-
// TODO: [🦻] Add langtail
|
|
65
|
-
],
|
|
66
|
-
script: await $provideScriptingForNode({}),
|
|
67
|
-
};
|
|
68
|
-
const llmTools = joinLlmExecutionTools('Playground tools', ...tools.llm);
|
|
69
|
-
|
|
70
|
-
keepUnused(llmTools);
|
|
71
|
-
keepUnused(embeddingVectorToString);
|
|
72
|
-
keepUnused(usageToHuman);
|
|
73
|
-
keepUnused<Prompt>();
|
|
74
|
-
|
|
75
|
-
/*/
|
|
76
|
-
const models = await llmTools.listModels();
|
|
77
|
-
console.info(llmTools.title, llmTools.description);
|
|
78
|
-
console.info({ models });
|
|
79
|
-
/**/
|
|
80
|
-
|
|
81
|
-
/*/
|
|
82
|
-
const chatPrompt = {
|
|
83
|
-
title: 'Hello',
|
|
84
|
-
parameters: {},
|
|
85
|
-
content: `Hello, my name is Alice.`,
|
|
86
|
-
modelRequirements: {
|
|
87
|
-
// modelName: 'foo',
|
|
88
|
-
modelVariant: 'CHAT',
|
|
89
|
-
},
|
|
90
|
-
} as const satisfies Prompt;
|
|
91
|
-
const chatPromptResult = await llmTools.callChatModel(chatPrompt);
|
|
92
|
-
console.info({ chatPromptResult });
|
|
93
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
94
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(chatPrompt.content));
|
|
95
|
-
console.info(colors.bgGreen(' Completion: ') + colors.green(chatPromptResult.content));
|
|
96
|
-
/**/
|
|
97
|
-
|
|
98
|
-
/*/
|
|
99
|
-
const completionPrompt = {
|
|
100
|
-
title: 'Hello',
|
|
101
|
-
parameters: {},
|
|
102
|
-
content: `Hello, my name is Alice.`,
|
|
103
|
-
modelRequirements: {
|
|
104
|
-
modelVariant: 'COMPLETION',
|
|
105
|
-
},
|
|
106
|
-
} as const satisfies Prompt;
|
|
107
|
-
const completionPromptResult = await llmTools.callCompletionModel(completionPrompt);
|
|
108
|
-
console.info({ completionPromptResult });
|
|
109
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
110
|
-
console.info(colors.green(completionPrompt.content + completionPromptResult.content));
|
|
111
|
-
/**/
|
|
112
|
-
|
|
113
|
-
/*/
|
|
114
|
-
// TODO: Test Translations in playground
|
|
115
|
-
/**/
|
|
116
|
-
|
|
117
|
-
/*/
|
|
118
|
-
const prompt = {
|
|
119
|
-
title: 'Embedding Prompt',
|
|
120
|
-
parameters: {},
|
|
121
|
-
content: `Hello, my name is Alice.`,
|
|
122
|
-
modelRequirements: {
|
|
123
|
-
modelVariant: 'EMBEDDING',
|
|
124
|
-
// modelName: 'text-embedding-ada-002',
|
|
125
|
-
},
|
|
126
|
-
} as const satisfies Prompt;
|
|
127
|
-
const promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
128
|
-
console.info({ promptResult });
|
|
129
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
130
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(prompt.content));
|
|
131
|
-
console.info(colors.bgGreen(' Embedding: ') + colors.green(embeddingVectorToString(promptResult.content)));
|
|
132
|
-
/**/
|
|
133
|
-
|
|
134
|
-
/*/
|
|
135
|
-
// <- Note: [🤖] Test here new model variant if needed
|
|
136
|
-
/**/
|
|
137
|
-
|
|
138
|
-
//========================================/
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Note: [⚫] Code for playground [_multiple playground](src/llm-providers/_multiple/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,190 +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
|
-
import * as $registrations from '../../../_packages/cli.index';
|
|
10
|
-
import { getAllCommitmentsToolFunctionsForNode } from '../../../commitments/_common/getAllCommitmentsToolFunctionsForNode';
|
|
11
|
-
import { DEFAULT_EXECUTION_CACHE_DIRNAME } from '../../../config';
|
|
12
|
-
import { usageToHuman } from '../../../execution/utils/usageToHuman';
|
|
13
|
-
import { book } from '../../../pipeline/book-notation';
|
|
14
|
-
import { $provideFilesystemForNode } from '../../../scrapers/_common/register/$provideFilesystemForNode';
|
|
15
|
-
import { JavascriptExecutionTools } from '../../../scripting/javascript/JavascriptExecutionTools';
|
|
16
|
-
import { FileCacheStorage } from '../../../storage/file-cache-storage/FileCacheStorage';
|
|
17
|
-
import type { ChatPrompt } from '../../../types/Prompt';
|
|
18
|
-
import { $sideEffect } from '../../../utils/organization/$sideEffect';
|
|
19
|
-
import { just } from '../../../utils/organization/just';
|
|
20
|
-
import { keepImported } from '../../../utils/organization/keepImported';
|
|
21
|
-
import { cacheLlmTools } from '../../_common/utils/cache/cacheLlmTools';
|
|
22
|
-
import { OpenAiAgentKitExecutionTools } from '../../openai/OpenAiAgentKitExecutionTools';
|
|
23
|
-
import { createAgentLlmExecutionTools } from '../createAgentLlmExecutionTools';
|
|
24
|
-
|
|
25
|
-
$sideEffect($registrations); // <- Note: LLM Providers are registered by importing their registration files
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Main function demonstrating AgentLlmExecutionTools usage
|
|
29
|
-
*/
|
|
30
|
-
playground()
|
|
31
|
-
.catch((error) => {
|
|
32
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
33
|
-
console.error(error);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
})
|
|
36
|
-
.then(() => {
|
|
37
|
-
process.exit(0);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Demo AgentLlmExecutionTools in a chat scenario
|
|
42
|
-
*/
|
|
43
|
-
async function playground() {
|
|
44
|
-
// Create underlying OpenAI tools
|
|
45
|
-
|
|
46
|
-
const nonce = '(1)';
|
|
47
|
-
const isVerbose = true;
|
|
48
|
-
|
|
49
|
-
/*/
|
|
50
|
-
const llmTools = await $provideLlmToolsFromEnv({
|
|
51
|
-
title: 'LLM Tools for Agent Playground',
|
|
52
|
-
});
|
|
53
|
-
/**/
|
|
54
|
-
|
|
55
|
-
/**/
|
|
56
|
-
const llmTools = new OpenAiAgentKitExecutionTools({
|
|
57
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
58
|
-
executionTools: {
|
|
59
|
-
script: new JavascriptExecutionTools({
|
|
60
|
-
isVerbose,
|
|
61
|
-
functions: getAllCommitmentsToolFunctionsForNode(),
|
|
62
|
-
}),
|
|
63
|
-
},
|
|
64
|
-
isVerbose,
|
|
65
|
-
});
|
|
66
|
-
/**/
|
|
67
|
-
|
|
68
|
-
/*/
|
|
69
|
-
console.info(colors.bgBlue(`🤖 LLM Tools:`));
|
|
70
|
-
console.info(colors.bgCyan(llmTools.title));
|
|
71
|
-
console.info(colors.cyan(llmTools.description));
|
|
72
|
-
/**/
|
|
73
|
-
|
|
74
|
-
/*/
|
|
75
|
-
// Test configuration
|
|
76
|
-
console.info(colors.bgBlue(`🔧 Checking configuration of LLM tools...`));
|
|
77
|
-
await llmTools.checkConfiguration();
|
|
78
|
-
/**/
|
|
79
|
-
|
|
80
|
-
/*/
|
|
81
|
-
// List available models
|
|
82
|
-
console.info(colors.bgBlue(`🔍 Listing available models of LLM tools...`));
|
|
83
|
-
const llmToolsModels = await llmTools.listModels();
|
|
84
|
-
console.info(`📊 Found ${colors.yellow(llmToolsModels.length.toString())} available models`);
|
|
85
|
-
console.info(llmToolsModels.map((model) => ` - ${model.modelTitle}`).join('\n'));
|
|
86
|
-
/**/
|
|
87
|
-
|
|
88
|
-
// Create agent tools wrapping the OpenAI tools
|
|
89
|
-
let agentTools = createAgentLlmExecutionTools({
|
|
90
|
-
llmTools,
|
|
91
|
-
agentSource: book`
|
|
92
|
-
Testing time from agent playground
|
|
93
|
-
|
|
94
|
-
FROM VOID
|
|
95
|
-
PERSONA You are an assistant that can determine the current date and time. ${nonce}
|
|
96
|
-
RULE Reply in language and date and time format as per the user's locale and language.
|
|
97
|
-
RULE Prefer words instead of digits when expressing time, for example, say "half past three" instead of "3:30".
|
|
98
|
-
USE TIME
|
|
99
|
-
|
|
100
|
-
`,
|
|
101
|
-
// agentSource: book`
|
|
102
|
-
// Paul
|
|
103
|
-
//
|
|
104
|
-
// FROM VOID
|
|
105
|
-
// RULE You are writing about news in AI and technology.
|
|
106
|
-
// USE SEARCH
|
|
107
|
-
//
|
|
108
|
-
// `,
|
|
109
|
-
// <- TODO: !!!! Test `USE BROWSER`
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
agentTools = just(agentTools);
|
|
113
|
-
keepImported(cacheLlmTools, FileCacheStorage, $provideFilesystemForNode, join, DEFAULT_EXECUTION_CACHE_DIRNAME);
|
|
114
|
-
|
|
115
|
-
/**/
|
|
116
|
-
agentTools = cacheLlmTools(agentTools, {
|
|
117
|
-
storage: new FileCacheStorage(
|
|
118
|
-
{ fs: $provideFilesystemForNode() },
|
|
119
|
-
{
|
|
120
|
-
rootFolderPath: join(
|
|
121
|
-
process.cwd(),
|
|
122
|
-
DEFAULT_EXECUTION_CACHE_DIRNAME,
|
|
123
|
-
// <- TODO: [🦒] Allow to override (pass different value into the function)
|
|
124
|
-
),
|
|
125
|
-
},
|
|
126
|
-
),
|
|
127
|
-
// isCacheReloaded: isCacheReloaded,
|
|
128
|
-
});
|
|
129
|
-
/**/
|
|
130
|
-
|
|
131
|
-
console.info(colors.bgBlue(`🧔 Agent Tools:`));
|
|
132
|
-
console.info(colors.bgCyan(agentTools.title));
|
|
133
|
-
console.info(colors.cyan(agentTools.description));
|
|
134
|
-
|
|
135
|
-
// Test configuration
|
|
136
|
-
console.info(colors.bgBlue(`🔧 Checking configuration of agent tools...`));
|
|
137
|
-
await agentTools.checkConfiguration();
|
|
138
|
-
|
|
139
|
-
// List available models
|
|
140
|
-
console.info(colors.bgBlue(`🔍 Listing available models of agent tools...`));
|
|
141
|
-
const models = await agentTools.listModels();
|
|
142
|
-
console.info(`📊 Found ${colors.yellow(models.length.toString())} available models`);
|
|
143
|
-
console.info(models.map((model) => ` - ${model.modelTitle}`).join('\n'));
|
|
144
|
-
|
|
145
|
-
// Show the model requirements
|
|
146
|
-
console.info(colors.bgBlue(`🔣 Model Requirements:`));
|
|
147
|
-
const modelRequirements = await agentTools.getModelRequirements();
|
|
148
|
-
console.info(modelRequirements);
|
|
149
|
-
|
|
150
|
-
// Test chat interaction
|
|
151
|
-
console.info(colors.bgBlue(`💬 Chatting with agent...`));
|
|
152
|
-
|
|
153
|
-
const chatPrompt = {
|
|
154
|
-
title: 'Test Chat',
|
|
155
|
-
/*
|
|
156
|
-
thread: [
|
|
157
|
-
// <- TODO: !!! Maybe rename to `previousMessages`
|
|
158
|
-
{
|
|
159
|
-
// channel: 'PROMPTBOOK_CHAT',
|
|
160
|
-
// id: 'msg1',
|
|
161
|
-
sender: 'user', // <- TODO: [👥] Standardize to `role: 'USER' | 'ASSISTANT'
|
|
162
|
-
content: 'Hello! Can you tell me a fun fact about TypeScript?',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
// channel: 'PROMPTBOOK_CHAT',
|
|
166
|
-
// id: 'msg2',
|
|
167
|
-
sender: 'assistant',
|
|
168
|
-
content: 'TypeScript is a superset of JavaScript that adds static types.',
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
*/
|
|
172
|
-
content: 'Kolik je hodin?' + nonce,
|
|
173
|
-
parameters: {},
|
|
174
|
-
modelRequirements: {
|
|
175
|
-
modelVariant: 'CHAT',
|
|
176
|
-
},
|
|
177
|
-
} satisfies ChatPrompt;
|
|
178
|
-
|
|
179
|
-
const result = await agentTools.callChatModel(chatPrompt);
|
|
180
|
-
|
|
181
|
-
console.info({ result });
|
|
182
|
-
console.info(colors.cyan(usageToHuman(result.usage)));
|
|
183
|
-
console.info(colors.bgBlue(' User: ') + '\n' + colors.blue(chatPrompt.content));
|
|
184
|
-
console.info(colors.bgCyan(` ${agentTools.title}: `) + '\n' + colors.green(result.content));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Note: [⚫] Code for playground [agent playground](src/llm-providers/agent/playground/playground.ts) should never be published in any package
|
|
188
|
-
// TODO: [🧠] Add more complex agent scenarios
|
|
189
|
-
// TODO: [🧠] Add parameter substitution demo
|
|
190
|
-
// TODO: [🧠] Add multi-turn conversation demo
|
|
@@ -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,99 +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 type { Usage } from '../../../execution/Usage';
|
|
9
|
-
import { usageToHuman } from '../../../execution/utils/usageToHuman';
|
|
10
|
-
import type { Prompt } from '../../../types/Prompt';
|
|
11
|
-
import { keepUnused } from '../../../utils/organization/keepUnused';
|
|
12
|
-
import { countUsage } from '../../_common/utils/count-total-usage/countUsage';
|
|
13
|
-
import { createAnthropicClaudeExecutionTools } from '../createAnthropicClaudeExecutionTools';
|
|
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
|
-
/**
|
|
26
|
-
* Handles playground.
|
|
27
|
-
*/
|
|
28
|
-
async function playground() {
|
|
29
|
-
console.info(`🧸 Anthropic Claude Playground`);
|
|
30
|
-
|
|
31
|
-
// Do here stuff you want to test
|
|
32
|
-
//========================================>
|
|
33
|
-
|
|
34
|
-
const anthropicClaudeExecutionTools = createAnthropicClaudeExecutionTools({
|
|
35
|
-
// isProxied: true,
|
|
36
|
-
// remoteServerUrl: DEFAULT_REMOTE_URL,
|
|
37
|
-
// path: DEFAULT_REMOTE_URL_PATH, // <- [🧜♂️]
|
|
38
|
-
isVerbose: true,
|
|
39
|
-
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY!,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const toolsWithUsage = countUsage(anthropicClaudeExecutionTools);
|
|
43
|
-
|
|
44
|
-
toolsWithUsage.spending().subscribe((usage: Usage) => {
|
|
45
|
-
const wordCount = (usage?.input?.wordsCount?.value || 0) + (usage?.output?.wordsCount?.value || 0);
|
|
46
|
-
console.log(`[💸] Spending ${wordCount} words`);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
keepUnused(toolsWithUsage);
|
|
50
|
-
keepUnused(anthropicClaudeExecutionTools);
|
|
51
|
-
keepUnused(usageToHuman);
|
|
52
|
-
keepUnused<Prompt>();
|
|
53
|
-
|
|
54
|
-
/*/
|
|
55
|
-
const models = await anthropicClaudeExecutionTools.listModels();
|
|
56
|
-
console.info({ models });
|
|
57
|
-
/**/
|
|
58
|
-
|
|
59
|
-
/**/
|
|
60
|
-
const chatPrompt = {
|
|
61
|
-
title: 'Poem about Prague',
|
|
62
|
-
parameters: {},
|
|
63
|
-
content: `Write me something about Prague`,
|
|
64
|
-
modelRequirements: {
|
|
65
|
-
modelVariant: 'CHAT',
|
|
66
|
-
// modelName: 'claude-3-5-sonnet-latest',
|
|
67
|
-
// modelName: 'claude-3-7-sonnet-latest',
|
|
68
|
-
modelName: 'claude-4-sonnet-20250514',
|
|
69
|
-
// modelName: 'claude-4-opus-20250514',
|
|
70
|
-
systemMessage: 'You are an assistant who only speaks in rhymes.',
|
|
71
|
-
temperature: 1,
|
|
72
|
-
},
|
|
73
|
-
format: 'JSON',
|
|
74
|
-
} as const satisfies Prompt;
|
|
75
|
-
const chatPromptResult = await toolsWithUsage.callChatModel!(chatPrompt);
|
|
76
|
-
console.info({ chatPromptResult });
|
|
77
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
78
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(chatPrompt.content));
|
|
79
|
-
console.info(colors.bgGreen(' Chat: ') + colors.green(chatPromptResult.content));
|
|
80
|
-
/**/
|
|
81
|
-
|
|
82
|
-
/*/
|
|
83
|
-
// TODO: Test Translations in playground
|
|
84
|
-
/**/
|
|
85
|
-
|
|
86
|
-
/*/
|
|
87
|
-
// TODO: Test Embeddings in playground
|
|
88
|
-
/**/
|
|
89
|
-
|
|
90
|
-
/*/
|
|
91
|
-
// <- Note: [🤖] Test here new model variant if needed
|
|
92
|
-
/**/
|
|
93
|
-
|
|
94
|
-
//========================================/
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Note: [⚫] Code for playground [anthropic-claude playground](src/llm-providers/anthropic-claude/playground/playground.ts) should never be published in any package
|
|
98
|
-
// TODO: [main] !!3 Playground with WebGPT / Promptbook.studio anonymous server
|
|
99
|
-
// 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,101 +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 { usageToHuman } from '../../../execution/utils/usageToHuman';
|
|
9
|
-
import type { Prompt } from '../../../types/Prompt';
|
|
10
|
-
import { keepUnused } from '../../../utils/organization/keepUnused';
|
|
11
|
-
import { AzureOpenAiExecutionTools } from '../AzureOpenAiExecutionTools';
|
|
12
|
-
|
|
13
|
-
playground()
|
|
14
|
-
.catch((error) => {
|
|
15
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
16
|
-
console.error(error);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
})
|
|
19
|
-
.then(() => {
|
|
20
|
-
process.exit(0);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Handles playground.
|
|
25
|
-
*/
|
|
26
|
-
async function playground() {
|
|
27
|
-
console.info(`🧸 Azure OpenAI Playground`);
|
|
28
|
-
|
|
29
|
-
// Do here stuff you want to test
|
|
30
|
-
//========================================>
|
|
31
|
-
|
|
32
|
-
const azureOpenAiExecutionTools = new AzureOpenAiExecutionTools(
|
|
33
|
-
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
34
|
-
{
|
|
35
|
-
isVerbose: true,
|
|
36
|
-
userId: 'playground',
|
|
37
|
-
resourceName: process.env.AZUREOPENAI_RESOURCE_NAME!,
|
|
38
|
-
deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME!,
|
|
39
|
-
apiKey: process.env.AZUREOPENAI_API_KEY!,
|
|
40
|
-
},
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
keepUnused(azureOpenAiExecutionTools);
|
|
44
|
-
keepUnused(usageToHuman);
|
|
45
|
-
keepUnused<Prompt>();
|
|
46
|
-
|
|
47
|
-
/*/
|
|
48
|
-
const models = await azureOpenAiExecutionTools.listModels();
|
|
49
|
-
console.info({ models });
|
|
50
|
-
/**/
|
|
51
|
-
|
|
52
|
-
/**/
|
|
53
|
-
const chatPrompt = {
|
|
54
|
-
title: 'Poem about Prague',
|
|
55
|
-
parameters: {},
|
|
56
|
-
content: `Write me something about Prague`,
|
|
57
|
-
modelRequirements: {
|
|
58
|
-
modelVariant: 'CHAT',
|
|
59
|
-
systemMessage: 'You are an assistant who only speaks in rhymes.',
|
|
60
|
-
temperature: 1.5,
|
|
61
|
-
},
|
|
62
|
-
} as const satisfies Prompt;
|
|
63
|
-
const chatPromptResult = await azureOpenAiExecutionTools.callChatModel(chatPrompt);
|
|
64
|
-
console.info({ chatPromptResult });
|
|
65
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
66
|
-
console.info(colors.bgBlue(' User: ') + colors.blue(chatPrompt.content));
|
|
67
|
-
console.info(colors.bgGreen(' Chat: ') + colors.green(chatPromptResult.content));
|
|
68
|
-
/**/
|
|
69
|
-
|
|
70
|
-
/*/
|
|
71
|
-
const completionPrompt = {
|
|
72
|
-
title: 'Hello',
|
|
73
|
-
parameters: {},
|
|
74
|
-
content: `Hello, my name is Alice.`,
|
|
75
|
-
modelRequirements: {
|
|
76
|
-
modelVariant: 'COMPLETION',
|
|
77
|
-
},
|
|
78
|
-
} as const satisfies Prompt;
|
|
79
|
-
const completionPromptResult = await azureOpenAiExecutionTools.callCompletionModel(completionPrompt);
|
|
80
|
-
console.info({ completionPromptResult });
|
|
81
|
-
console.info(colors.cyan(usageToHuman(chatPromptResult.usage)));
|
|
82
|
-
console.info(colors.green(completionPrompt.content + completionPromptResult.content));
|
|
83
|
-
/**/
|
|
84
|
-
|
|
85
|
-
/*/
|
|
86
|
-
// TODO: Test Translations in playground
|
|
87
|
-
/**/
|
|
88
|
-
|
|
89
|
-
/*/
|
|
90
|
-
// TODO: Test Embeddings in playground
|
|
91
|
-
/**/
|
|
92
|
-
|
|
93
|
-
/*/
|
|
94
|
-
// <- Note: [🤖] Test here new model variant if needed
|
|
95
|
-
/**/
|
|
96
|
-
|
|
97
|
-
//========================================/
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Note: [⚫] Code for playground [azure-openai playground](src/llm-providers/azure-openai/playground/playground.ts) should never be published in any package
|
|
101
|
-
// TODO: 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
|
-
}
|