@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
44 lines (38 loc) • 1.32 kB
JavaScript
import { AtomName } from "../../types/atom";
import { BaseAtom } from "../base";
import { getSystemPrompt } from "./prompt";
import { Factory } from "../../core/factory";
export class ImageReader extends BaseAtom {
constructor(context, option) {
super(context, option), this.name = AtomName.IMAGE_READER, this.isLLMAtom = !0;
}
getLLMMessages(query) {
const {image: image} = this.context;
return [ {
role: "system",
content: 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"
});
}
}
export const registerImageReaderAtom = () => {
Factory.registerAtom(AtomName.IMAGE_READER, ImageReader);
};
//# sourceMappingURL=index.js.map