UNPKG

taskforce-aiagent

Version:

TaskForce is a modular, open-source, production-ready TypeScript agent framework for orchestrating AI agents, LLM-powered autonomous agents, task pipelines, dynamic toolchains, RAG workflows and memory/retrieval systems.

46 lines (45 loc) 1.97 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateMemorySummary = generateMemorySummary; exports.summarizeOldMessages = summarizeOldMessages; const enum_js_1 = require("../configs/enum.js"); const systemAi_helper_js_1 = require("./systemAi.helper.js"); const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); /** * Summarizes a single long output string for memory storage. */ async function generateMemorySummary(output) { if (!output.trim()) return ""; const model = process.env.DEFAULT_AI_SUMMARY_MODEL || enum_js_1.SupportedModel.GPT_4O_MINI; const summary = await (0, systemAi_helper_js_1.callOpenAIFunction)({ model, system: "Summarize the following output. Keep the task context intact. Write concisely and clearly, focusing on actionable insights. Do not omit any risk or strategy-related details.", user: output, }); return summary; } /** * Summarizes previous ChatMessage[] context. */ async function summarizeOldMessages(messages) { const model = process.env.DEFAULT_AI_SUMMARY_MODEL || enum_js_1.SupportedModel.GPT_4O_MINI; const content = await (0, systemAi_helper_js_1.callOpenAIFunction)({ model, messages: [ { role: "system", content: "You are a memory summarizer AI. The following conversation history may be too long to fit in future prompts. Please summarize the key facts, user intentions, tool calls, decisions, or conclusions from context. Be concise, and retain all relevant context that would help the assistant continue the session.", }, ...messages, ], }); return { role: "system", content: `📘 Context Summary (from old history):\n${content}`, }; }