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 (41 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.registerImageReaderAtom = exports.ImageReader = void 0; const atom_1 = require("../../types/atom"), base_1 = require("../base"), prompt_1 = require("./prompt"), factory_1 = require("../../core/factory"); class ImageReader extends base_1.BaseAtom { constructor(context, option) { super(context, option), this.name = atom_1.AtomName.IMAGE_READER, this.isLLMAtom = !0; } getLLMMessages(query) { const {image: image} = this.context; return [ { role: "system", content: (0, prompt_1.getSystemPrompt)() }, { role: "user", content: [ { type: "image_url", image_url: { url: image } }, { type: "text", text: "Please read this image and generate a JSON based on the chart information in the image that can be used to recreate the chart." } ] } ]; } parseLLMContent(resJson) { return resJson ? Object.assign(Object.assign({}, this.context), { simpleVChartSpec: resJson }) : Object.assign(Object.assign({}, this.context), { error: "Image is Empty" }); } } exports.ImageReader = ImageReader; const registerImageReaderAtom = () => { factory_1.Factory.registerAtom(atom_1.AtomName.IMAGE_READER, ImageReader); }; exports.registerImageReaderAtom = registerImageReaderAtom; //# sourceMappingURL=index.js.map