UNPKG

@visactor/vmind

Version:

<div align="center"> <a href="https://github.com/VisActor#gh-light-mode-only" target="_blank"> <img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_light.svg"/> </a> <a href="https://githu

48 lines (42 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.registerChartQAExtractionAtom = exports.ChartQAExtraction = void 0; const atom_1 = require("../../types/atom"), base_1 = require("../base"), prompt_1 = require("./prompt"), json_1 = require("../../utils/json"), factory_1 = require("../../core/factory"); class ChartQAExtraction extends base_1.BaseAtom { constructor(context, option) { super(context, option), this.name = atom_1.AtomName.CHART_QA_EXTRACTION, this.isLLMAtom = !0; } getLLMMessages(query) { const {text: text} = this.context; return [ { role: "system", content: (0, prompt_1.getSystemPrompt)(this.options.language) }, { role: "user", content: text } ]; } parseLLMContent(resJson) { const {answerDSL: answerDSL, keyList: keyList, explanation: explanation} = resJson; if (!answerDSL) return console.error("Answer is Empty"), Object.assign(Object.assign({}, this.context), { error: "Answer is Empty" }); const jsonRes = (0, json_1.parseLLMJson)(answerDSL); return jsonRes.error ? Object.assign(Object.assign({}, this.context), { keyList: keyList, explanation: explanation, answer: answerDSL }) : Object.assign(Object.assign({}, this.context), { keyList: keyList, explanation: explanation, answer: jsonRes }); } } exports.ChartQAExtraction = ChartQAExtraction; const registerChartQAExtractionAtom = () => { factory_1.Factory.registerAtom(atom_1.AtomName.CHART_QA_EXTRACTION, ChartQAExtraction); }; exports.registerChartQAExtractionAtom = registerChartQAExtractionAtom; //# sourceMappingURL=index.js.map