bug on file
This commit is contained in:
parent
6ba97f64c4
commit
4cc2babcf1
6 changed files with 49 additions and 16 deletions
20
src/frontend/package-lock.json
generated
20
src/frontend/package-lock.json
generated
|
|
@ -25,6 +25,7 @@
|
||||||
"ace-builds": "^1.16.0",
|
"ace-builds": "^1.16.0",
|
||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"axios": "^1.3.2",
|
"axios": "^1.3.2",
|
||||||
|
"base64-js": "^1.5.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-ace": "^10.1.0",
|
"react-ace": "^10.1.0",
|
||||||
|
|
@ -5862,6 +5863,25 @@
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/base64-js": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/batch": {
|
"node_modules/batch": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
"ace-builds": "^1.16.0",
|
"ace-builds": "^1.16.0",
|
||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"axios": "^1.3.2",
|
"axios": "^1.3.2",
|
||||||
|
"base64-js": "^1.5.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-ace": "^10.1.0",
|
"react-ace": "^10.1.0",
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
|
||||||
{chat.thought && chat.thought !== "" && !hidden && (
|
{chat.thought && chat.thought !== "" && !hidden && (
|
||||||
<div
|
<div
|
||||||
onClick={() => setHidden((prev) => !prev)}
|
onClick={() => setHidden((prev) => !prev)}
|
||||||
className=" text-start inline-block rounded-md h-full
|
className=" text-start inline-block rounded-md h-full border border-gray-300
|
||||||
bg-white w-[95%] pb-3 pt-3 px-2 ml-3 cursor-pointer scrollbar-hide overflow-scroll"
|
bg-gray-100 w-[95%] pb-3 pt-3 px-2 ml-3 cursor-pointer scrollbar-hide overflow-scroll"
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: convert.toHtml(chat.thought),
|
__html: convert.toHtml(chat.thought),
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import { ArrowDownTrayIcon, CloudArrowDownIcon, DocumentIcon } from "@heroicons/react/24/outline";
|
import { CloudArrowDownIcon, DocumentIcon } from "@heroicons/react/24/outline";
|
||||||
|
import * as base64js from 'base64-js';
|
||||||
|
|
||||||
export default function FileCard({ fileName, content, fileType }) {
|
export default function FileCard({ fileName, content, fileType }) {
|
||||||
const handleDownload = () => {
|
const handleDownload = () => {
|
||||||
const blob = new Blob([content], { type: "application/octet-stream" });
|
const byteArray = new Uint8Array(base64js.toByteArray(content));
|
||||||
|
const blob = new Blob([byteArray], { type: 'application/octet-stream' });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const link = document.createElement("a");
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = fileName;
|
link.download = fileName;
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export default function ChatModal({
|
||||||
console.log("Received data:", data);
|
console.log("Received data:", data);
|
||||||
//get chat history
|
//get chat history
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
console.log("entrou");
|
console.log(data);
|
||||||
|
|
||||||
setChatHistory((_) => {
|
setChatHistory((_) => {
|
||||||
let newChatHistory: ChatMessageType[] = [];
|
let newChatHistory: ChatMessageType[] = [];
|
||||||
|
|
@ -71,7 +71,16 @@ export default function ChatModal({
|
||||||
is_bot: boolean;
|
is_bot: boolean;
|
||||||
message: string;
|
message: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
data?:string;
|
||||||
}) => {
|
}) => {
|
||||||
|
if(chatItem.type==="file"){
|
||||||
|
newChatHistory.push({
|
||||||
|
isSend: !chatItem.is_bot,
|
||||||
|
message: chatItem.message,
|
||||||
|
thought: chatItem.intermediate_steps,
|
||||||
|
file:chatItem.data
|
||||||
|
});
|
||||||
|
}
|
||||||
newChatHistory.push({
|
newChatHistory.push({
|
||||||
isSend: !chatItem.is_bot,
|
isSend: !chatItem.is_bot,
|
||||||
message: chatItem.message,
|
message: chatItem.message,
|
||||||
|
|
@ -87,6 +96,7 @@ export default function ChatModal({
|
||||||
setLockChat(false)
|
setLockChat(false)
|
||||||
}
|
}
|
||||||
if (data.type=="file"){
|
if (data.type=="file"){
|
||||||
|
console.log(data)
|
||||||
}
|
}
|
||||||
// Do something with the data received from the WebSocket
|
// Do something with the data received from the WebSocket
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ import { ReactFlowInstance } from 'reactflow';
|
||||||
import { FlowType } from "../flow";
|
import { FlowType } from "../flow";
|
||||||
|
|
||||||
export type ChatType = {flow:FlowType,reactFlowInstance:ReactFlowInstance}
|
export type ChatType = {flow:FlowType,reactFlowInstance:ReactFlowInstance}
|
||||||
export type ChatMessageType = { message: string; isSend: boolean, thought?:string,file?:Blob }
|
export type ChatMessageType = { message: string; isSend: boolean, thought?:string,file?:string }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue