Check the output links are hallucinations from AI (#139)

* feat: check output links if a hallucination from AI
This commit is contained in:
JeffJiang
2025-05-15 10:39:53 +08:00
committed by GitHub
parent 25e7b86f02
commit bf4820c68f
6 changed files with 88 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
import { Check, Copy, Headphones, X } from "lucide-react";
import { Check, Copy, Headphones, Pencil, Undo2, X } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { ScrollContainer } from "~/components/deer-flow/scroll-container";
@@ -47,6 +47,7 @@ export function ResearchBlock({
await listenToPodcast(researchId);
}, [researchId]);
const [editing, setEditing] = useState(false);
const [copied, setCopied] = useState(false);
const handleCopy = useCallback(() => {
if (!reportId) {
@@ -63,6 +64,10 @@ export function ResearchBlock({
}, 1000);
}, [reportId]);
const handleEdit = useCallback(() => {
setEditing((editing) => !editing);
}, []);
// When the research id changes, set the active tab to activities
useEffect(() => {
if (!hasReport) {
@@ -87,6 +92,16 @@ export function ResearchBlock({
<Headphones />
</Button>
</Tooltip>
<Tooltip title="Edit">
<Button
className="text-gray-400"
size="icon"
variant="ghost"
onClick={handleEdit}
>
{editing ? <Undo2 /> : <Pencil />}
</Button>
</Tooltip>
<Tooltip title="Copy">
<Button
className="text-gray-400"
@@ -147,6 +162,7 @@ export function ResearchBlock({
className="mt-4"
researchId={researchId}
messageId={reportId}
editing={editing}
/>
)}
</ScrollContainer>

View File

@@ -13,10 +13,12 @@ import { cn } from "~/lib/utils";
export function ResearchReportBlock({
className,
messageId,
editing,
}: {
className?: string;
researchId: string;
messageId: string;
editing: boolean;
}) {
const message = useMessage(messageId);
const { isReplay } = useReplay();
@@ -55,7 +57,7 @@ export function ResearchReportBlock({
ref={contentRef}
className={cn("relative flex flex-col pt-4 pb-8", className)}
>
{!isReplay && isCompleted ? (
{!isReplay && isCompleted && editing ? (
<ReportEditor
content={message?.content}
onMarkdownChange={handleMarkdownChange}