mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-28 12:39:54 +02:00
fix misc issues
This commit is contained in:
parent
9438f9df05
commit
feaa3b653f
@ -1429,10 +1429,10 @@ export function ChatPage({
|
||||
Object.hasOwn(packet, "stop_reason") &&
|
||||
Object.hasOwn(packet, "level_question_num")
|
||||
) {
|
||||
sub_questions = constructSubQuestions(
|
||||
sub_questions,
|
||||
packet as StreamStopInfo
|
||||
);
|
||||
// sub_questions = constructSubQuestions(
|
||||
// sub_questions,
|
||||
// packet as StreamStopInfo
|
||||
// );
|
||||
} else if (Object.hasOwn(packet, "sub_question")) {
|
||||
is_generating = true;
|
||||
sub_questions = constructSubQuestions(
|
||||
|
@ -256,7 +256,7 @@ export const constructSubQuestions = (
|
||||
(sq) => sq.level === level && sq.level_question_num === level_question_num
|
||||
);
|
||||
if (subQuestion) {
|
||||
subQuestion.is_complete = true;
|
||||
// subQuestion.is_complete = true;
|
||||
}
|
||||
} else if ("top_documents" in newDetail) {
|
||||
const { level, level_question_num, top_documents } = newDetail;
|
||||
@ -271,6 +271,7 @@ export const constructSubQuestions = (
|
||||
answer: "",
|
||||
sub_queries: [],
|
||||
context_docs: { top_documents },
|
||||
is_complete: false,
|
||||
};
|
||||
} else {
|
||||
subQuestion.context_docs = { top_documents };
|
||||
@ -291,6 +292,7 @@ export const constructSubQuestions = (
|
||||
answer: "",
|
||||
sub_queries: [],
|
||||
context_docs: undefined,
|
||||
is_complete: false,
|
||||
};
|
||||
updatedSubQuestions.push(subQuestion);
|
||||
}
|
||||
@ -314,6 +316,7 @@ export const constructSubQuestions = (
|
||||
answer: "",
|
||||
sub_queries: [],
|
||||
context_docs: undefined,
|
||||
is_complete: false,
|
||||
};
|
||||
updatedSubQuestions.push(subQuestion);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import rehypeKatex from "rehype-katex";
|
||||
import "katex/dist/katex.min.css";
|
||||
import SubQuestionsDisplay from "./SubQuestionsDisplay";
|
||||
import { StatusRefinement } from "../Refinement";
|
||||
import SubQuestionProgress from "./SubQuestionProgress";
|
||||
|
||||
export const AgenticMessage = ({
|
||||
docSidebarToggled,
|
||||
@ -250,15 +251,10 @@ export const AgenticMessage = ({
|
||||
? agenticDocs
|
||||
: docs
|
||||
}
|
||||
subQuestions={
|
||||
(isViewingInitialAnswer
|
||||
? subQuestions && subQuestions.length > 0
|
||||
? subQuestions
|
||||
: secondLevelSubquestions
|
||||
: secondLevelSubquestions && secondLevelSubquestions.length > 0
|
||||
? secondLevelSubquestions
|
||||
: subQuestions) || undefined
|
||||
}
|
||||
subQuestions={[
|
||||
...(subQuestions || []),
|
||||
...(secondLevelSubquestions || []),
|
||||
]}
|
||||
openQuestion={openQuestion}
|
||||
>
|
||||
{props.children}
|
||||
@ -399,8 +395,18 @@ export const AgenticMessage = ({
|
||||
{subQuestions && subQuestions.length > 0 && (
|
||||
<SubQuestionsDisplay
|
||||
docSidebarToggled={docSidebarToggled || false}
|
||||
finishedGenerating={finalContent.length > 8}
|
||||
overallAnswerGenerating={finalContent.length < 8}
|
||||
finishedGenerating={
|
||||
finalContent.length > 8 &&
|
||||
streamedContent.length == streamedContent.length
|
||||
}
|
||||
overallAnswerGenerating={false}
|
||||
// overallAnswerGenerating={
|
||||
// !!(
|
||||
// secondLevelSubquestions &&
|
||||
// secondLevelSubquestions.length > 0 &&
|
||||
// finalContent.length < 8
|
||||
// )
|
||||
// }
|
||||
showSecondLevel={!isViewingInitialAnswer}
|
||||
currentlyOpenQuestion={currentlyOpenQuestion}
|
||||
allowStreaming={() => setAllowStreaming(true)}
|
||||
|
@ -27,14 +27,22 @@ export const MemoizedAnchor = memo(
|
||||
children: React.ReactNode;
|
||||
}): JSX.Element => {
|
||||
const value = children?.toString();
|
||||
// return <></>
|
||||
if (value?.startsWith("[") && value?.endsWith("]")) {
|
||||
const match = value.match(/\[(D|Q)?(\d+)\]/);
|
||||
if (match) {
|
||||
const index = parseInt(match[2], 10) - 1;
|
||||
const associatedDoc = docs?.[index];
|
||||
if (!associatedDoc) {
|
||||
return <a href={children as string}>{children}</a>;
|
||||
const isSubQuestion = match[1] === "Q";
|
||||
if (!isSubQuestion) {
|
||||
const index = parseInt(match[2], 10) - 1;
|
||||
const associatedDoc = docs?.[index];
|
||||
if (!associatedDoc) {
|
||||
return <a href={children as string}>{children}</a>;
|
||||
}
|
||||
} else {
|
||||
const index = parseInt(match[2], 10) - 1;
|
||||
const associatedSubQuestion = subQuestions?.[index];
|
||||
if (!associatedSubQuestion) {
|
||||
return <a href={children as string}>{children}</a>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,18 +59,7 @@ export const MemoizedAnchor = memo(
|
||||
: undefined;
|
||||
|
||||
if (!associatedDoc && !associatedSubQuestion) {
|
||||
return (
|
||||
<>
|
||||
l{children}
|
||||
{/* No associated docs or subquestions.
|
||||
<div className="text-sm text-gray-600">
|
||||
<p>Number of questions: {subQuestions?.length}</p>
|
||||
<p>Number of docs: {docs?.length}</p>
|
||||
<p>{children}</p>
|
||||
<p>index: {index}</p>
|
||||
</div> */}
|
||||
</>
|
||||
);
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
let icon: React.ReactNode = null;
|
||||
@ -85,22 +82,6 @@ export const MemoizedAnchor = memo(
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
// <div
|
||||
// className="debug-info"
|
||||
// style={{
|
||||
// backgroundColor: "#f0f0f0",
|
||||
// padding: "10px",
|
||||
// border: "1px solid #ccc",
|
||||
// margin: "5px 0",
|
||||
// }}
|
||||
// >
|
||||
// <h4>Debug Info:</h4>
|
||||
// {children}
|
||||
// <p>document length: {docs?.length}</p>
|
||||
// <p>question length: {subQuestions?.length}</p>
|
||||
// <p>document_info: {JSON.stringify(associatedDoc)}</p>
|
||||
// <p>question_info: {JSON.stringify(associatedSubQuestion)}</p>
|
||||
// </div>
|
||||
<MemoizedLink
|
||||
updatePresentingDocument={updatePresentingDocument}
|
||||
document={associatedDocInfo}
|
||||
|
@ -480,10 +480,10 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
||||
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
||||
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
||||
useStreamingMessages(secondLevelQuestions || [], () => {});
|
||||
const memoizedSubQuestions = useMemo(() => {
|
||||
return overallAnswerGenerating ? dynamicSubQuestions : subQuestions;
|
||||
}, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]);
|
||||
|
||||
// const memoizedSubQuestions = useMemo(() => {
|
||||
// return overallAnswerGenerating ? dynamicSubQuestions : subQuestions;
|
||||
// }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]);
|
||||
const memoizedSubQuestions = dynamicSubQuestions;
|
||||
const memoizedSecondLevelQuestions = useMemo(() => {
|
||||
return overallAnswerGenerating
|
||||
? dynamicSecondLevelQuestions
|
||||
|
Loading…
x
Reference in New Issue
Block a user