Strip thinking from copy message outputs (#5179)
This commit is contained in:
parent
563f95167d
commit
bc58939843
@ -1,11 +1,15 @@
|
||||
import { THOUGHT_REGEX_COMPLETE } from "@/components/WorkspaceChat/ChatContainer/ChatHistory/ThoughtContainer";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function useCopyText(delay = 2500) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const copyText = async (content) => {
|
||||
if (!content) return;
|
||||
navigator?.clipboard?.writeText(content);
|
||||
setCopied(content);
|
||||
|
||||
// Filter thinking blocks from the content if they exist
|
||||
const nonThinkingContent = content.replace(THOUGHT_REGEX_COMPLETE, "");
|
||||
navigator?.clipboard?.writeText(nonThinkingContent);
|
||||
setCopied(nonThinkingContent);
|
||||
setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, delay);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user