@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
46 lines (40 loc) • 1.53 kB
JavaScript
import { AtomName } from "../../types/atom";
import { BaseAtom } from "../base";
import { getSystemPrompt } from "./prompt";
import { parseLLMJson } from "../../utils/json";
import { Factory } from "../../core/factory";
export class ChartQAExtraction extends BaseAtom {
constructor(context, option) {
super(context, option), this.name = AtomName.CHART_QA_EXTRACTION, this.isLLMAtom = !0;
}
getLLMMessages(query) {
const {text: text} = this.context;
return [ {
role: "system",
content: 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 = 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
});
}
}
export const registerChartQAExtractionAtom = () => {
Factory.registerAtom(AtomName.CHART_QA_EXTRACTION, ChartQAExtraction);
};
//# sourceMappingURL=index.js.map