UNPKG

@agentica/core

Version:

Agentic AI Library specialized in LLM Function Calling

50 lines 2.65 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChatGptDescribeFunctionAgent = void 0; exports.describe = describe; const AgenticaDefaultPrompt_1 = require("../constants/AgenticaDefaultPrompt"); const AgenticaSystemPrompt_1 = require("../constants/AgenticaSystemPrompt"); const events_1 = require("../factory/events"); const histories_1 = require("../factory/histories"); const ChatGptCompletionStreamingUtil_1 = require("../utils/ChatGptCompletionStreamingUtil"); function describe(ctx, histories) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d; if (histories.length === 0) { return; } const completionStream = yield ctx.request("describe", { messages: [ // COMMON SYSTEM PROMPT { role: "system", content: AgenticaDefaultPrompt_1.AgenticaDefaultPrompt.write(ctx.config), }, // FUNCTION CALLING HISTORIES ...histories.map(histories_1.decodeHistory).flat(), // SYSTEM PROMPT { role: "system", content: (_d = (_c = (_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.systemPrompt) === null || _b === void 0 ? void 0 : _b.describe) === null || _c === void 0 ? void 0 : _c.call(_b, histories)) !== null && _d !== void 0 ? _d : AgenticaSystemPrompt_1.AgenticaSystemPrompt.DESCRIBE, }, ], }); yield (0, ChatGptCompletionStreamingUtil_1.reduceStreamingWithDispatch)(completionStream, (props) => { const event = (0, events_1.createDescribeEvent)(Object.assign({ executes: histories }, props)); void ctx.dispatch(event).catch(() => { }); }, ctx.abortSignal); }); } exports.ChatGptDescribeFunctionAgent = { execute: describe, }; //# sourceMappingURL=describe.js.map