UNPKG

@agentscope/studio

Version:

AgentScope Studio is a powerful local monitoring and visualization tool designed to provide real-time insights into your system's performance and behavior.

98 lines (97 loc) 3.55 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.ReplyDao = void 0; const Reply_1 = require("../models/Reply"); class ReplyDao { static getReply(replyId) { return __awaiter(this, void 0, void 0, function* () { try { const reply = yield Reply_1.ReplyTable.findOne({ where: { replyId, }, relations: ['messages'], }); if (reply) { return { replyId: reply.replyId, replyName: reply.replyName, replyRole: reply.replyRole, createdAt: reply.createdAt, finishedAt: reply.finishedAt, messages: reply.messages.map((msg) => ({ id: msg.id, name: msg.msg.name, role: msg.msg.role, content: msg.msg.content, timestamp: msg.msg.timestamp, metadata: msg.msg.metadata, speech: msg.speech, })), }; } return null; } catch (error) { console.error(error); throw error; } }); } static saveReply(data) { return __awaiter(this, void 0, void 0, function* () { try { yield Reply_1.ReplyTable.create(Object.assign({}, data)).save(); } catch (error) { console.error(error); throw error; } }); } static doesReplyExist(replyId) { return __awaiter(this, void 0, void 0, function* () { try { const reply = yield Reply_1.ReplyTable.findOne({ where: { replyId, }, }); return reply !== null; } catch (error) { console.error(error); throw error; } }); } static finishReply(replyId, finishedAt) { return __awaiter(this, void 0, void 0, function* () { try { const reply = yield Reply_1.ReplyTable.findOne({ where: { replyId, }, }); if (reply) { reply.finishedAt = finishedAt; yield reply.save(); } } catch (error) { console.error(error); throw error; } }); } } exports.ReplyDao = ReplyDao;