mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-24 23:11:01 +02:00
k
This commit is contained in:
parent
3bf6b77319
commit
f96a3ee29a
@ -942,6 +942,7 @@ def translate_db_message_to_chat_message_detail(
|
|||||||
sub_questions=translate_db_sub_questions_to_server_objects(
|
sub_questions=translate_db_sub_questions_to_server_objects(
|
||||||
chat_message.sub_questions
|
chat_message.sub_questions
|
||||||
),
|
),
|
||||||
|
refined_answer_improvement=chat_message.refined_answer_improvement,
|
||||||
)
|
)
|
||||||
|
|
||||||
return chat_msg_detail
|
return chat_msg_detail
|
||||||
|
@ -239,6 +239,7 @@ class ChatMessageDetail(BaseModel):
|
|||||||
sub_questions: list[SubQuestionDetail] | None = None
|
sub_questions: list[SubQuestionDetail] | None = None
|
||||||
files: list[FileDescriptor]
|
files: list[FileDescriptor]
|
||||||
tool_call: ToolCallFinalResult | None
|
tool_call: ToolCallFinalResult | None
|
||||||
|
refined_answer_improvement: bool | None = None
|
||||||
|
|
||||||
def model_dump(self, *args: list, **kwargs: dict[str, Any]) -> dict[str, Any]: # type: ignore
|
def model_dump(self, *args: list, **kwargs: dict[str, Any]) -> dict[str, Any]: # type: ignore
|
||||||
initial_dict = super().model_dump(mode="json", *args, **kwargs) # type: ignore
|
initial_dict = super().model_dump(mode="json", *args, **kwargs) # type: ignore
|
||||||
|
@ -1404,6 +1404,14 @@ export function ChatPage({
|
|||||||
isImprovement = (packet as RefinedAnswerImprovement)
|
isImprovement = (packet as RefinedAnswerImprovement)
|
||||||
.refined_answer_improvement;
|
.refined_answer_improvement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Object.hasOwn(packet, "stream_type")) {
|
||||||
|
if ((packet as any).stream_type == "main_answer") {
|
||||||
|
is_generating = false;
|
||||||
|
second_level_generating = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Continuously refine the sub_questions based on the packets that we receive
|
// Continuously refine the sub_questions based on the packets that we receive
|
||||||
if (
|
if (
|
||||||
Object.hasOwn(packet, "stop_reason") &&
|
Object.hasOwn(packet, "stop_reason") &&
|
||||||
|
@ -146,6 +146,7 @@ export interface BackendMessage {
|
|||||||
// Keeping existing properties
|
// Keeping existing properties
|
||||||
comments: any;
|
comments: any;
|
||||||
parentMessageId: number | null;
|
parentMessageId: number | null;
|
||||||
|
refined_answer_improvement: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageResponseIDInfo {
|
export interface MessageResponseIDInfo {
|
||||||
|
@ -497,6 +497,8 @@ export function processRawChatHistory(
|
|||||||
latestChildMessageId: messageInfo.latest_child_message,
|
latestChildMessageId: messageInfo.latest_child_message,
|
||||||
overridden_model: messageInfo.overridden_model,
|
overridden_model: messageInfo.overridden_model,
|
||||||
sub_questions: subQuestions,
|
sub_questions: subQuestions,
|
||||||
|
isImprovement:
|
||||||
|
(messageInfo.refined_answer_improvement as unknown as boolean) || false,
|
||||||
};
|
};
|
||||||
|
|
||||||
messages.set(messageInfo.message_id, message);
|
messages.set(messageInfo.message_id, message);
|
||||||
|
@ -372,33 +372,35 @@ export const AgenticMessage = ({
|
|||||||
onMessageSelection &&
|
onMessageSelection &&
|
||||||
otherMessagesCanSwitchTo &&
|
otherMessagesCanSwitchTo &&
|
||||||
otherMessagesCanSwitchTo.length > 1;
|
otherMessagesCanSwitchTo.length > 1;
|
||||||
|
const currentIndexRef = useRef(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!allowStreaming) {
|
if (!allowStreaming) {
|
||||||
// if (typeof content === "string") {
|
|
||||||
// setStreamedContent(finalContent);
|
|
||||||
// setLastKnownContentLength(finalContent.length);
|
|
||||||
// }
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof finalContent !== "string") return;
|
if (typeof finalContent !== "string") return;
|
||||||
|
|
||||||
let currentIndex = streamedContent.length;
|
|
||||||
let intervalId: NodeJS.Timeout | null = null;
|
let intervalId: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
// if (finalContent.length > currentIndex) {
|
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
setStreamedContent((prev) => {
|
setStreamedContent((prev) => {
|
||||||
if (prev.length < finalContent.length) {
|
if (streamedContent.length == finalContent.length) {
|
||||||
const nextLength = Math.min(prev.length + 5, finalContent.length);
|
return finalContent;
|
||||||
|
}
|
||||||
|
if (currentIndexRef.current < finalContent.length) {
|
||||||
|
const nextLength = Math.min(
|
||||||
|
currentIndexRef.current + 5,
|
||||||
|
finalContent.length
|
||||||
|
);
|
||||||
|
currentIndexRef.current = nextLength;
|
||||||
return finalContent.slice(0, nextLength);
|
return finalContent.slice(0, nextLength);
|
||||||
} else {
|
} else {
|
||||||
if (intervalId) clearInterval(intervalId);
|
if (intervalId) clearInterval(intervalId);
|
||||||
return finalContent;
|
return finalContent;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 10);
|
}, 5);
|
||||||
// } else {
|
// } else {
|
||||||
// setStreamedContent(finalContent);
|
// setStreamedContent(finalContent);
|
||||||
// }
|
// }
|
||||||
@ -472,47 +474,81 @@ export const AgenticMessage = ({
|
|||||||
Answer
|
Answer
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isImprovement == null &&
|
{/* {
|
||||||
subQuestions &&
|
<div className="bg-gray-100 p-4 rounded-md shadow-sm">
|
||||||
subQuestions.length > 0 ? (
|
<p>
|
||||||
<RefinemenetBadge
|
isGenerating: {isGenerating ? "true" : "false"}
|
||||||
finished={!secondLevelGenerating}
|
</p>
|
||||||
overallAnswer={secondLevelAssistantMessage || ""}
|
<p>
|
||||||
secondLevelSubquestions={secondLevelSubquestions}
|
secondLevelGenerating:{" "}
|
||||||
toggleInitialAnswerVieinwg={() => {
|
{secondLevelGenerating ? "true" : "false"}
|
||||||
setIsViewingInitialAnswer(
|
</p>
|
||||||
!isViewingInitialAnswer
|
<p>
|
||||||
);
|
isImprovement:{" "}
|
||||||
}}
|
{isImprovement === null ? "null" : "not null"}
|
||||||
isViewingInitialAnswer={isViewingInitialAnswer}
|
</p>
|
||||||
/>
|
<p>
|
||||||
) : secondLevelAssistantMessage ? (
|
subQuestions:{" "}
|
||||||
isImprovement ? (
|
{subQuestions ? "exists" : "does not exist"}
|
||||||
<Badge
|
</p>
|
||||||
// NOTE: This is a hack to make the badge slightly higher
|
<p>
|
||||||
className="cursor-pointer mt-[1px]"
|
subQuestions length:{" "}
|
||||||
variant="agent"
|
{subQuestions ? subQuestions.length : "N/A"}
|
||||||
onClick={() => {
|
</p>
|
||||||
const viewInitialAnswer =
|
</div>
|
||||||
!isViewingInitialAnswer;
|
} */}
|
||||||
setIsViewingInitialAnswer(viewInitialAnswer);
|
{/* {isImprovement ? "true" : "false"} */}
|
||||||
toggleDocDisplay &&
|
{
|
||||||
toggleDocDisplay(isViewingInitialAnswer);
|
// !isGenerating &&
|
||||||
if (viewInitialAnswer) {
|
secondLevelGenerating &&
|
||||||
setIsViewingInitialAnswer(true);
|
isImprovement == null &&
|
||||||
}
|
subQuestions &&
|
||||||
|
subQuestions.length > 0 ? (
|
||||||
|
<RefinemenetBadge
|
||||||
|
finished={!secondLevelGenerating}
|
||||||
|
overallAnswer={
|
||||||
|
secondLevelAssistantMessage || ""
|
||||||
|
}
|
||||||
|
secondLevelSubquestions={
|
||||||
|
secondLevelSubquestions
|
||||||
|
}
|
||||||
|
toggleInitialAnswerVieinwg={() => {
|
||||||
|
setIsViewingInitialAnswer(
|
||||||
|
!isViewingInitialAnswer
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
isViewingInitialAnswer={isViewingInitialAnswer}
|
||||||
{isViewingInitialAnswer
|
/>
|
||||||
? "See Refined Answer"
|
) : secondLevelAssistantMessage ? (
|
||||||
: "See Original Answer"}
|
isImprovement ? (
|
||||||
</Badge>
|
<Badge
|
||||||
|
// NOTE: This is a hack to make the badge slightly higher
|
||||||
|
className="cursor-pointer mt-[1px]"
|
||||||
|
variant="agent"
|
||||||
|
onClick={() => {
|
||||||
|
const viewInitialAnswer =
|
||||||
|
!isViewingInitialAnswer;
|
||||||
|
setIsViewingInitialAnswer(
|
||||||
|
viewInitialAnswer
|
||||||
|
);
|
||||||
|
toggleDocDisplay &&
|
||||||
|
toggleDocDisplay(isViewingInitialAnswer);
|
||||||
|
if (viewInitialAnswer) {
|
||||||
|
setIsViewingInitialAnswer(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isViewingInitialAnswer
|
||||||
|
? "See Refined Answer"
|
||||||
|
: "See Original Answer"}
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<NoNewAnswerMessage />
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<NoNewAnswerMessage />
|
<></>
|
||||||
)
|
)
|
||||||
) : (
|
}
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
|
@ -35,7 +35,7 @@ export const StatusIndicator = ({ status }: { status: ToggleState }) => {
|
|||||||
bg-background border-3 border-background-900 "
|
bg-background border-3 border-background-900 "
|
||||||
${
|
${
|
||||||
status === ToggleState.Todo
|
status === ToggleState.Todo
|
||||||
? "!border-4 border border-background-900 bg-background"
|
? "!border-[3px] border border-background-900 bg-background"
|
||||||
: false
|
: false
|
||||||
? "bg-background border-3 border border-background-900 rotating-border"
|
? "bg-background border-3 border border-background-900 rotating-border"
|
||||||
: "bg-background-900 flex items-center justify-center"
|
: "bg-background-900 flex items-center justify-center"
|
||||||
|
@ -231,7 +231,7 @@ export default function RefinemenetBadge({
|
|||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<div
|
<div
|
||||||
className="relative w-full max-w-sm"
|
className="relative w-fit max-w-sm"
|
||||||
onMouseEnter={() => setIsHovered(true)}
|
onMouseEnter={() => setIsHovered(true)}
|
||||||
onMouseLeave={() => setIsHovered(false)}
|
onMouseLeave={() => setIsHovered(false)}
|
||||||
>
|
>
|
||||||
@ -254,7 +254,7 @@ export default function RefinemenetBadge({
|
|||||||
<TooltipContent
|
<TooltipContent
|
||||||
side="bottom"
|
side="bottom"
|
||||||
align="start"
|
align="start"
|
||||||
className="w-80 p-4 bg-white shadow-lg rounded-md"
|
className="w-fit p-4 bg-white border-2 border-border shadow-lg rounded-md"
|
||||||
>
|
>
|
||||||
{/* If not done, show the "Refining" box + a chevron */}
|
{/* If not done, show the "Refining" box + a chevron */}
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ export const NoNewAnswerMessage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-gray-600 text-sm" style={{ opacity: opacity }}>
|
<div className="text-gray-600 text-sm" style={{ opacity: opacity }}>
|
||||||
No new answer found...
|
{/* No new answer found... */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,10 @@ export function Citation({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent width="mb-2 max-w-lg" className="bg-background">
|
<TooltipContent
|
||||||
|
width="mb-2 max-w-lg"
|
||||||
|
className="border-2 border-border shadow-lg bg-white"
|
||||||
|
>
|
||||||
{document_info?.document ? (
|
{document_info?.document ? (
|
||||||
<CompactDocumentCard
|
<CompactDocumentCard
|
||||||
updatePresentingDocument={document_info.updatePresentingDocument}
|
updatePresentingDocument={document_info.updatePresentingDocument}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user