+
{_messagesTree === null ? (
diff --git a/client/src/components/Nav/ExportConversation/ExportModel.jsx b/client/src/components/Nav/ExportConversation/ExportModel.jsx
index dfcc9cba2..b4c0080c8 100644
--- a/client/src/components/Nav/ExportConversation/ExportModel.jsx
+++ b/client/src/components/Nav/ExportConversation/ExportModel.jsx
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useRecoilValue, useRecoilCallback } from 'recoil';
import exportFromJSON from 'export-from-json';
+import download from 'downloadjs';
import DialogTemplate from '~/components/ui/DialogTemplate.jsx';
import { Dialog, DialogClose, DialogButton } from '~/components/ui/Dialog.tsx';
import { Input } from '~/components/ui/Input.tsx';
@@ -8,11 +9,14 @@ import { Label } from '~/components/ui/Label.tsx';
import { Checkbox } from '~/components/ui/Checkbox.tsx';
import Dropdown from '~/components/ui/Dropdown';
import { cn } from '~/utils/';
+import { useScreenshot } from '~/utils/screenshotContext';
import store from '~/store';
import cleanupPreset from '~/utils/cleanupPreset.js';
export default function ExportModel({ open, onOpenChange }) {
+ const { captureScreenshot } = useScreenshot();
+
const [filename, setFileName] = useState('');
const [type, setType] = useState('');
@@ -32,7 +36,7 @@ export default function ExportModel({ open, onOpenChange }) {
[]
);
- const typeOptions = ['text', 'markdown', 'csv', 'json']; //, 'screenshot', 'webpage'];
+ const typeOptions = ['text', 'markdown', 'csv', 'json', 'screenshot']; //,, 'webpage'];
useEffect(() => {
setFileName(
@@ -105,6 +109,11 @@ export default function ExportModel({ open, onOpenChange }) {
}
};
+ const exportScreenshot = async () => {
+ const data = await captureScreenshot();
+ download(data, `${filename}.png`, 'image/png');
+ };
+
const exportCSV = async () => {
let data = [];
@@ -256,6 +265,7 @@ export default function ExportModel({ open, onOpenChange }) {
else if (type == 'text') exportText();
else if (type == 'markdown') exportMarkdown();
else if (type == 'csv') exportCSV();
+ else if (type == 'screenshot') exportScreenshot();
};
const defaultTextProps =
@@ -311,7 +321,7 @@ export default function ExportModel({ open, onOpenChange }) {
- {type !== 'csv' ? (
+ {type !== 'csv' && type !== 'screenshot' ? (
) : null}
-
-
-
-
-
+
+
+
+ {exportBranchesSupport ? 'Enabled' : 'Not Supported'}
+
+
-
+ ) : null}
{type === 'json' ? (
{
+ const { ref } = useContext(ScreenshotContext);
+ const [image, takeScreenshot] = useScreenshot_();
+
+ const captureScreenshot = () => {
+ return takeScreenshot(ref.current);
+ };
+
+ return { screenshotTargetRef: ref, captureScreenshot };
+};
+
+export const ScreenshotProvider = ({ children }) => {
+ const ref = useRef(null);
+
+ return {children};
+};