Refactor: Rename entry point to main.ts and update start script.

This commit is contained in:
uxname committed 2025-05-24 16:32:50 +03:00
1 parent 40e71274dd
commit e9320e438f
7 files changed
+347 -352

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
import dotenv from 'dotenv';
import { Pipeline } from './models/pipeline';
import { PipelineExecutor } from './pipelines/pipeline-executor';
dotenv.config();
async function main() {
const openAIApiKey = process.env.OPENAI_API_KEY;
const mcpServerUrl =
process.env.MCP_SERVER_URL || 'https://santiment-mcp.dev.mind-dev.com/sse';
if (!openAIApiKey) {
console.error(
'Ошибка: Переменная окружения OPENAI_API_KEY не установлена.',
);
process.exit(1);
}
const pipelineExecutor = new PipelineExecutor(mcpServerUrl);
const testPipeline: Pipeline = {
description: 'Тестовый пайплайн',
systemPrompt:
'Ты полезный ассистент, который всегда отвечает на русском языке.',
steps: [
{
name: 'Приветствие',
prompt: 'Скажи привет пользователю, его имя - {{username}}.',
},
{
name: 'Использование инструмента',
prompt:
'Напиши какие инструменты тебе доступны? (Очень кратко напиши суть и входящие параметры).',
},
{
name: 'Использование инструмента',
prompt: 'Вызови **top_gainers** с pageSize=2 и покажи что получилось.',
},
{
name: 'Итог',
prompt:
'Отлично, теперь давай подытожим всё что мы сделали, соберём информацию вместе и оформим её как telegram пост.',
},
],
};
const variables = {
username: 'Вася',
};
const systemPrompts = ['Отвечай кратко и по существу.'];
try {
const results = await pipelineExecutor.executeChain({
pipeline: testPipeline,
variables: variables,
systemPrompts: systemPrompts,
openAIApiKey: openAIApiKey,
});
console.log('Результаты выполнения пайплайна:', results);
} catch (error) {
console.error('Ошибка при выполнении пайплайна:', error);
} finally {
await pipelineExecutor.mcpToolsService.disconnect();
}
}
main().catch(console.error);