mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
init
This commit is contained in:
19
src/components/chat/remarkImageGeneration.ts
Normal file
19
src/components/chat/remarkImageGeneration.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { visit } from "unist-util-visit";
|
||||
|
||||
export default function remarkImageGeneration() {
|
||||
return (tree) => {
|
||||
visit(tree, "code", (node, index, parent) => {
|
||||
if (node.lang === "generation") {
|
||||
try {
|
||||
const data = JSON.parse(node.value);
|
||||
parent.children[index] = {
|
||||
type: "generation",
|
||||
data: data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Invalid JSON in image-generation block:", error);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user