@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,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
// Note: [❌] Turning off some global checks for playground file:
|
|
4
|
-
// spell-checker: disable
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
import * as dotenv from 'dotenv';
|
|
8
|
-
|
|
9
|
-
dotenv.config({ path: '.env' });
|
|
10
|
-
|
|
11
|
-
import OpenAI from 'openai';
|
|
12
|
-
import { chromium } from 'playwright';
|
|
13
|
-
import readlineSync from 'readline-sync';
|
|
14
|
-
|
|
15
|
-
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
16
|
-
|
|
17
|
-
// --- 🧠 Funkce, které AI může volat ---
|
|
18
|
-
async function searchWeb(query: string) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function browsePage(url: string) {
|
|
23
|
-
const browser = await chromium.launch({ headless: true });
|
|
24
|
-
const page = await browser.newPage();
|
|
25
|
-
await page.goto(url, { waitUntil: 'domcontentloaded' });
|
|
26
|
-
const text = await page.evaluate(() => document.body.innerText.slice(0, 2000));
|
|
27
|
-
await browser.close();
|
|
28
|
-
return { url, text };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// --- 🗣️ Chat loop ---
|
|
32
|
-
async function main() {
|
|
33
|
-
console.log('🤖 Ahoj! Jsem AI agent s oficiálním function calling API.\n');
|
|
34
|
-
|
|
35
|
-
const messages: OpenAI.Chat.ChatCompletionMessageParam[] = [
|
|
36
|
-
{
|
|
37
|
-
role: 'system',
|
|
38
|
-
content: `Jsi český AI agent, který může používat následující nástroje:
|
|
39
|
-
- search_web(query): pro vyhledávání aktuálních informací
|
|
40
|
-
- browse_page(url): pro otevření webu a čtení obsahu.
|
|
41
|
-
Odpovídej přirozeně a používej funkce jen, pokud je to nutné.`,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
while (true) {
|
|
46
|
-
const input = readlineSync.question('\nTy: ');
|
|
47
|
-
if (input.toLowerCase() === 'exit') break;
|
|
48
|
-
messages.push({ role: 'user', content: input });
|
|
49
|
-
|
|
50
|
-
const response = await client.chat.completions.create({
|
|
51
|
-
model: 'gpt-4.1', // potřebujeme model s podporou function calling
|
|
52
|
-
messages,
|
|
53
|
-
tools: [
|
|
54
|
-
{
|
|
55
|
-
type: 'function',
|
|
56
|
-
function: {
|
|
57
|
-
name: 'search_web',
|
|
58
|
-
description: 'Vyhledá informace na webu podle dotazu',
|
|
59
|
-
parameters: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
query: { type: 'string', description: 'dotaz pro vyhledávač' },
|
|
63
|
-
},
|
|
64
|
-
required: ['query'],
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
type: 'function',
|
|
70
|
-
function: {
|
|
71
|
-
name: 'browse_page',
|
|
72
|
-
description: 'Otevře webovou stránku a přečte její text',
|
|
73
|
-
parameters: {
|
|
74
|
-
type: 'object',
|
|
75
|
-
properties: {
|
|
76
|
-
url: { type: 'string', description: 'adresa stránky' },
|
|
77
|
-
},
|
|
78
|
-
required: ['url'],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const choice = response.choices[0];
|
|
86
|
-
const message = choice!.message;
|
|
87
|
-
|
|
88
|
-
// 🔧 Pokud AI volá funkci
|
|
89
|
-
if (message.tool_calls && message.tool_calls.length > 0) {
|
|
90
|
-
for (const tool of message.tool_calls) {
|
|
91
|
-
const fnName = tool.function.name;
|
|
92
|
-
const args = JSON.parse(tool.function.arguments || '{}');
|
|
93
|
-
|
|
94
|
-
console.log(`🛠️ AI volá funkci: ${fnName}`, args);
|
|
95
|
-
|
|
96
|
-
let result;
|
|
97
|
-
try {
|
|
98
|
-
if (fnName === 'search_web') result = await searchWeb(args.query);
|
|
99
|
-
else if (fnName === 'browse_page') result = await browsePage(args.url);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
result = { error: (err as Error).message };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Pošleme výsledek funkce zpět do konverzace
|
|
105
|
-
messages.push(message);
|
|
106
|
-
messages.push({
|
|
107
|
-
role: 'tool',
|
|
108
|
-
tool_call_id: tool.id,
|
|
109
|
-
content: JSON.stringify(result),
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const followUp = await client.chat.completions.create({
|
|
113
|
-
model: 'gpt-4.1',
|
|
114
|
-
messages,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const finalAnswer = followUp.choices[0]!.message?.content;
|
|
118
|
-
if (finalAnswer) console.log(`🤖 AI: ${finalAnswer}`);
|
|
119
|
-
messages.push({ role: 'assistant', content: finalAnswer || '' });
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
const text = message.content;
|
|
123
|
-
if (text) console.log(`🤖 AI: ${text}`);
|
|
124
|
-
messages.push({ role: 'assistant', content: text || '' });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
console.log('\n👋 Konec konverzace.');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
main();
|
|
@@ -1,68 +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 OpenAI from 'openai';
|
|
9
|
-
import { join } from 'path';
|
|
10
|
-
|
|
11
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
12
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
playground()
|
|
17
|
-
.catch((error) => {
|
|
18
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
19
|
-
console.error(error);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
})
|
|
22
|
-
.then(() => {
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
async function playground() {
|
|
27
|
-
console.info(`🧸 Playground`);
|
|
28
|
-
|
|
29
|
-
// Do here stuff you want to test
|
|
30
|
-
//========================================>
|
|
31
|
-
|
|
32
|
-
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
33
|
-
|
|
34
|
-
const stream = await openai.chat.completions.create({
|
|
35
|
-
// model: 'gpt-4o-mini',
|
|
36
|
-
model: 'gpt-4.1',
|
|
37
|
-
messages: [
|
|
38
|
-
{
|
|
39
|
-
role: 'system',
|
|
40
|
-
content: 'You are a Pavol Hejný, author of Promptbook',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
role: 'user',
|
|
44
|
-
content: 'Who are you?',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
temperature: 0.7,
|
|
48
|
-
top_p: 0.9,
|
|
49
|
-
stream: true,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
let fullResponse = '';
|
|
53
|
-
for await (const chunk of stream) {
|
|
54
|
-
const content = chunk.choices[0]?.delta?.content || '';
|
|
55
|
-
fullResponse += content;
|
|
56
|
-
|
|
57
|
-
// process.stdout.clearLine(0);
|
|
58
|
-
process.stdout.cursorTo(0);
|
|
59
|
-
process.stdout.write(colors.grey(fullResponse));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.info('\n---\n');
|
|
63
|
-
console.info(colors.green(fullResponse));
|
|
64
|
-
|
|
65
|
-
//========================================/
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Note: [⚫] Code for archived playground [playground-openai-streaming.ts](src/playground/backup/playground-openai-streaming.ts.txt) should never be published in any package */
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
/// <reference path="../../src/globals.d.ts" />
|
|
4
|
-
|
|
5
|
-
import * as dotenv from 'dotenv';
|
|
6
|
-
|
|
7
|
-
dotenv.config({ path: '.env' });
|
|
8
|
-
|
|
9
|
-
import { AnthropicClaudeExecutionTools } from '@promptbook/anthropic-claude';
|
|
10
|
-
import { makeKnowledgeSourceHandler } from '@promptbook/core';
|
|
11
|
-
import { $provideFilesystemForNode } from '@promptbook/node';
|
|
12
|
-
import { MarkdownScraper } from '@promptbook/markdown-utils';
|
|
13
|
-
import { spaceTrim } from '@promptbook/utils';
|
|
14
|
-
import colors from 'colors';
|
|
15
|
-
import { join } from 'path';
|
|
16
|
-
|
|
17
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
18
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
playground()
|
|
23
|
-
.catch((error) => {
|
|
24
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
25
|
-
console.error(error);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
})
|
|
28
|
-
.then(() => {
|
|
29
|
-
process.exit(0);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
async function playground() {
|
|
33
|
-
console.info(`🧸 Playground`);
|
|
34
|
-
|
|
35
|
-
// Do here stuff you want to test
|
|
36
|
-
//========================================>
|
|
37
|
-
const sourceContent = spaceTrim(`
|
|
38
|
-
Springfield is a city in the U.S. state of Illinois. It is the county seat of Sangamon County.
|
|
39
|
-
The city's population of 10566 as of 2019 makes it the sixth most populous city in the state.
|
|
40
|
-
`);
|
|
41
|
-
|
|
42
|
-
const fs = $provideFilesystemForNode();
|
|
43
|
-
const llm = new AnthropicClaudeExecutionTools({
|
|
44
|
-
isVerbose: false,
|
|
45
|
-
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY!,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const markdownScraper = new MarkdownScraper({ llm }, { isVerbose: true });
|
|
49
|
-
|
|
50
|
-
const knowledge = await markdownScraper.scrape(
|
|
51
|
-
await makeKnowledgeSourceHandler(
|
|
52
|
-
{
|
|
53
|
-
sourceContent,
|
|
54
|
-
},
|
|
55
|
-
{ fs },
|
|
56
|
-
),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
console.info(colors.bgGreen(' Knowledge: '));
|
|
60
|
-
console.info(knowledge);
|
|
61
|
-
|
|
62
|
-
//========================================/
|
|
63
|
-
|
|
64
|
-
console.info(`[ Done 🧸 Playground ]`);
|
|
65
|
-
}
|
|
@@ -1,44 +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 { promptbookFetch } from '../scrapers/_common/utils/promptbookFetch';
|
|
10
|
-
|
|
11
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
12
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
playground()
|
|
17
|
-
.catch((error) => {
|
|
18
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
19
|
-
console.error(error);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
})
|
|
22
|
-
.then(() => {
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
async function playground() {
|
|
27
|
-
console.info(`🧸 Playground`);
|
|
28
|
-
|
|
29
|
-
// Do here stuff you want to test
|
|
30
|
-
//========================================>
|
|
31
|
-
|
|
32
|
-
// const url= 'https://google.com';
|
|
33
|
-
// const url = 'https://pavolhejny.com';
|
|
34
|
-
// const url = 'https://www.pavolhejny.com';
|
|
35
|
-
const url = 'https://foo.pavolhejny.com';
|
|
36
|
-
|
|
37
|
-
const response = await promptbookFetch(url);
|
|
38
|
-
const text = await response.text();
|
|
39
|
-
console.log(text);
|
|
40
|
-
|
|
41
|
-
//========================================/
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Note: [⚫] Code for archived playground [playground-scraperFetch.ts](src/playground/backup/playground-scraperFetch.ts.txt) should never be published in any package */
|
package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt
DELETED
|
@@ -1,49 +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 OpenAI from 'openai';
|
|
9
|
-
import { join } from 'path';
|
|
10
|
-
|
|
11
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
12
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
playground()
|
|
17
|
-
.catch((error) => {
|
|
18
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
19
|
-
console.error(error);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
})
|
|
22
|
-
.then(() => {
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
async function playground() {
|
|
27
|
-
console.info(`🧸 Playground`);
|
|
28
|
-
|
|
29
|
-
// Do here stuff you want to test
|
|
30
|
-
//========================================>
|
|
31
|
-
|
|
32
|
-
const client = new OpenAI({
|
|
33
|
-
baseURL: 'http://localhost:4440/api/openai/v1', //'http://localhost:4440/agents/jack-green/api/openai',
|
|
34
|
-
apiKey: 'ptbk_6135a159114a40b99bdbf2d52db59e59',
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const response = await client.chat.completions.create({
|
|
38
|
-
model: 'agent:jack-green',
|
|
39
|
-
messages: [{ role: 'user', content: 'Tell me more about you.' }],
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
console.log(response.choices[0]!.message.content);
|
|
43
|
-
|
|
44
|
-
//========================================/
|
|
45
|
-
|
|
46
|
-
console.info(`[ Done 🧸 Playground ]`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Note: [⚫] Code for archived playground [playground-using-openai-compatible-route-on-agents-server.ts](src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt) should never be published in any package */
|
|
@@ -1,120 +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 { basename } from 'path';
|
|
10
|
-
import { spaceTrim } from 'spacetrim';
|
|
11
|
-
import { forTime } from 'waitasecond';
|
|
12
|
-
import { createPipelineCollectionFromDirectory } from '../../src/collection/constructors/createPipelineCollectionFromDirectory';
|
|
13
|
-
import { createPipelineExecutor } from '../../src/execution/00-createPipelineExecutor';
|
|
14
|
-
import { usageToHuman } from '../../src/execution/utils/usageToHuman';
|
|
15
|
-
import { $provideLlmToolsFromEnv } from '../../src/llm-providers/_common/register/$provideLlmToolsFromEnv';
|
|
16
|
-
import { JavascriptExecutionTools } from '../../src/scripting/javascript/JavascriptExecutionTools';
|
|
17
|
-
|
|
18
|
-
if (process.cwd() !== join(__dirname, '../..')) {
|
|
19
|
-
console.error(colors.red(`CWD must be root of the project`));
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
playground()
|
|
24
|
-
.catch((error) => {
|
|
25
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
26
|
-
console.error(error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
})
|
|
29
|
-
.then(() => {
|
|
30
|
-
process.exit(0);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
async function playground() {
|
|
34
|
-
console.info(`🧸 Playground`);
|
|
35
|
-
|
|
36
|
-
// Do here stuff you want to test
|
|
37
|
-
//========================================>
|
|
38
|
-
|
|
39
|
-
const collection = await createPipelineCollectionFromDirectory('./examples/pipelines/', {}, {
|
|
40
|
-
llmTools: undefined,
|
|
41
|
-
isVerbose: true,
|
|
42
|
-
isRecursive: false,
|
|
43
|
-
isCrashedOnError: true,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const pipeline = await collection.getPipelineByUrl('https://promptbook.studio/examples/simple-knowledge.book');
|
|
47
|
-
|
|
48
|
-
await forTime(100);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const pipelineExecutor = createPipelineExecutor({ pipeline, tools: $provideExecutionToolsForNode({ isVerbose: true }) });
|
|
52
|
-
|
|
53
|
-
const inputParameters = {
|
|
54
|
-
eventTitle: 'Biennial of Animation Bratislava',
|
|
55
|
-
eventDescription: spaceTrim(`
|
|
56
|
-
INTERNATIONAL LEADERSHIP FORUM ON ARTIFICIAL INTELLIGENCE
|
|
57
|
-
Animation and A.I.: Redefining Next-Gen Media Education
|
|
58
|
-
October 10, Bratislava Castle
|
|
59
|
-
|
|
60
|
-
**Format: Empowering Youth**
|
|
61
|
-
Youth and educators see the state of play in new tech, experience A.I. hands-on while peers network around media education and for future collaborations across industries.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Highlights
|
|
65
|
-
|
|
66
|
-
Industry State of Play: 6-Minute Challenge (5 leaders)
|
|
67
|
-
The Reponse: Expert Panel
|
|
68
|
-
Masterclass
|
|
69
|
-
Tech Playground: Interactive Lab
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## Why
|
|
73
|
-
|
|
74
|
-
While no one expected creatives and animation to be among the first hit by A.I. emergence, they are the vanguard shaping discourse in new tech. This animation biennial summons a trend-setting group for thought leadership across industries: assessing the state of play, exploring the paths ahead and engaging youth. Convening leaders from business, governance and creative industries we forge a path into the world of tomorrow.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
## Building on 40-Year Legacy
|
|
78
|
-
|
|
79
|
-
Over 40 years, the Biennial of Animation has hosted over 50 world-renowed luminaries, including Oscar, Emmy and BAFTA winners, and bestowned lifetime achievement awards to leaders known in every studio worldwide.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
##30,000 to 300,000: Bridging Professions
|
|
83
|
-
|
|
84
|
-
This Biennial’s tech-enabled jump from 30,000 to 300,000+ attendees also sets a high standard in A.I. discourse: a flagship format uniting professions, principals and young talent held in an iconic landmark.
|
|
85
|
-
`),
|
|
86
|
-
rules: spaceTrim(`
|
|
87
|
-
Event is not for technical people, but for children and educators
|
|
88
|
-
Speak for ordinary people
|
|
89
|
-
`),
|
|
90
|
-
};
|
|
91
|
-
const { isSuccessful, errors, warnings, outputParameters, usage } = await pipelineExecutor(
|
|
92
|
-
inputParameters,
|
|
93
|
-
(progress) => {
|
|
94
|
-
console.info(progress.isDone ? '☑' : '☐', progress);
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
for (const warning of warnings) {
|
|
99
|
-
console.error(colors.bgYellow(warning.name /* <- 11:11 */));
|
|
100
|
-
console.error(colors.yellow(warning.stack || warning.message));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
for (const error of errors) {
|
|
104
|
-
console.error(colors.bgRed(`${error.name} in ${basename(__filename)}`));
|
|
105
|
-
console.error(colors.red(error.stack || error.message));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.info(colors.cyan(usageToHuman(usage /* <- TODO: [🌳] Compare with `llmTools.getTotalUsage()` */)));
|
|
109
|
-
|
|
110
|
-
const { bio } = outputParameters;
|
|
111
|
-
|
|
112
|
-
console.info(colors.gray('---'));
|
|
113
|
-
console.info(colors.green(bio));
|
|
114
|
-
process.exit(isSuccessful ? 0 : 1);
|
|
115
|
-
|
|
116
|
-
//========================================/
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/** Note: [⚫] Code for archived playground [playground-write-pavolhejny-bio](src/playground/backup/playground-write-pavolhejny-bio.txt) should never be published in any package */
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
// Note: [❌] Turning off some global checks for playground file:
|
|
4
|
-
// spell-checker: disable
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
import * as dotenv from 'dotenv';
|
|
8
|
-
|
|
9
|
-
dotenv.config({ path: '.env' });
|
|
10
|
-
|
|
11
|
-
import colors from 'colors';
|
|
12
|
-
import { join } from 'path';
|
|
13
|
-
import { spaceTrim } from 'spacetrim';
|
|
14
|
-
|
|
15
|
-
if (process.cwd() !== join(__dirname, '../../..')) {
|
|
16
|
-
console.error(
|
|
17
|
-
colors.red(
|
|
18
|
-
spaceTrim(`
|
|
19
|
-
CWD must be root of the project
|
|
20
|
-
|
|
21
|
-
Script: _boilerplate.ts
|
|
22
|
-
Current CWD: ${process.cwd()}
|
|
23
|
-
Expected CWD: ${join(__dirname, '../../..')}
|
|
24
|
-
`),
|
|
25
|
-
),
|
|
26
|
-
);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
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
|
-
* Handles playground.
|
|
42
|
-
*/
|
|
43
|
-
async function playground() {
|
|
44
|
-
console.info(`🧸 Playground`);
|
|
45
|
-
|
|
46
|
-
// Do here stuff you want to test
|
|
47
|
-
//========================================>
|
|
48
|
-
|
|
49
|
-
// Note: [🎠] Do here the stuff and add in `terminals.json`
|
|
50
|
-
|
|
51
|
-
//========================================/
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Note: [⚫] Code for permanent playground [_boilerplate](src/playground/permanent/_boilerplate.ts) should never be published in any package
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
3
|
-
// Note: [❌] Turning off some global checks for playground file:
|
|
4
|
-
// spell-checker: disable
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
import * as dotenv from 'dotenv';
|
|
8
|
-
|
|
9
|
-
dotenv.config({ path: '.env' });
|
|
10
|
-
|
|
11
|
-
// TODO: import { PROMPTBOOK_ENGINE_VERSION } from '@promptbook-local/core';
|
|
12
|
-
import colors from 'colors';
|
|
13
|
-
import { join } from 'path';
|
|
14
|
-
import { chromium } from 'playwright';
|
|
15
|
-
import { spaceTrim } from 'spacetrim';
|
|
16
|
-
import { locateChrome } from '../../executables/browsers/locateChrome';
|
|
17
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
18
|
-
|
|
19
|
-
if (process.cwd() !== join(__dirname, '../../..')) {
|
|
20
|
-
console.error(
|
|
21
|
-
colors.red(
|
|
22
|
-
spaceTrim(`
|
|
23
|
-
CWD must be root of the project
|
|
24
|
-
|
|
25
|
-
Script: agent-with-browser-playground.ts
|
|
26
|
-
Current CWD: ${process.cwd()}
|
|
27
|
-
Expected CWD: ${join(__dirname, '../../..')}
|
|
28
|
-
`),
|
|
29
|
-
),
|
|
30
|
-
);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
playground()
|
|
35
|
-
.catch((error) => {
|
|
36
|
-
console.error(colors.bgRed(error.name || 'NamelessError'));
|
|
37
|
-
console.error(error);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
})
|
|
40
|
-
.then(() => {
|
|
41
|
-
process.exit(0);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Handles playground.
|
|
46
|
-
*/
|
|
47
|
-
async function playground() {
|
|
48
|
-
console.info(`🧸 Agents Playground`);
|
|
49
|
-
|
|
50
|
-
// Do here stuff you want to test
|
|
51
|
-
//========================================>
|
|
52
|
-
|
|
53
|
-
const browser = await chromium.launch({ headless: false, executablePath: (await locateChrome()) || undefined });
|
|
54
|
-
const context = await browser.newContext();
|
|
55
|
-
const page = await context.newPage();
|
|
56
|
-
|
|
57
|
-
/*
|
|
58
|
-
// 1. Go to LinkedIn login page
|
|
59
|
-
await page.goto('https://www.linkedin.com/login');
|
|
60
|
-
|
|
61
|
-
// 2. Log in
|
|
62
|
-
await page.fill('input[name="session_key"]', process.env.LINKEDIN_EMAIL);
|
|
63
|
-
await page.fill('input[name="session_password"]', process.env.LINKEDIN_PASSWORD);
|
|
64
|
-
await page.click('button[type="submit"]');
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
// 3. Wait for feed to load
|
|
68
|
-
await page.waitForURL('**/feed');
|
|
69
|
-
await page.waitForSelector('div.feed-shared-update-v2', { timeout: 10000 });
|
|
70
|
-
|
|
71
|
-
// 4. Scroll to load more posts
|
|
72
|
-
for (let i = 0; i < 3; i++) {
|
|
73
|
-
await page.mouse.wheel(0, 1000);
|
|
74
|
-
await page.waitForTimeout(2000);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 5. Extract posts text
|
|
78
|
-
const posts = await page.$$eval('div.feed-shared-update-v2', (elements) =>
|
|
79
|
-
elements.slice(0, 5).map((el) => {
|
|
80
|
-
const textEl = el.querySelector('.feed-shared-update-v2__description, span.break-words');
|
|
81
|
-
return textEl ? (textEl as TODO_any).innerText.trim() : '(no text)';
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
console.log('📰 Latest posts:');
|
|
86
|
-
posts.forEach((p, i) => console.log(`\nPost #${i + 1}:\n${p}\n`));
|
|
87
|
-
|
|
88
|
-
await browser.close();
|
|
89
|
-
//========================================/
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Note: [⚫] Code for permanent playground [agent-with-browser-playground](src/playground/permanent/agent-with-browser-playground.ts) should never be published in any package
|