mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-22 14:00:57 +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, "stop_reason") &&
|
||||||
Object.hasOwn(packet, "level_question_num")
|
Object.hasOwn(packet, "level_question_num")
|
||||||
) {
|
) {
|
||||||
sub_questions = constructSubQuestions(
|
// sub_questions = constructSubQuestions(
|
||||||
sub_questions,
|
// sub_questions,
|
||||||
packet as StreamStopInfo
|
// packet as StreamStopInfo
|
||||||
);
|
// );
|
||||||
} else if (Object.hasOwn(packet, "sub_question")) {
|
} else if (Object.hasOwn(packet, "sub_question")) {
|
||||||
is_generating = true;
|
is_generating = true;
|
||||||
sub_questions = constructSubQuestions(
|
sub_questions = constructSubQuestions(
|
||||||
|
@ -256,7 +256,7 @@ export const constructSubQuestions = (
|
|||||||
(sq) => sq.level === level && sq.level_question_num === level_question_num
|
(sq) => sq.level === level && sq.level_question_num === level_question_num
|
||||||
);
|
);
|
||||||
if (subQuestion) {
|
if (subQuestion) {
|
||||||
subQuestion.is_complete = true;
|
// subQuestion.is_complete = true;
|
||||||
}
|
}
|
||||||
} else if ("top_documents" in newDetail) {
|
} else if ("top_documents" in newDetail) {
|
||||||
const { level, level_question_num, top_documents } = newDetail;
|
const { level, level_question_num, top_documents } = newDetail;
|
||||||
@ -271,6 +271,7 @@ export const constructSubQuestions = (
|
|||||||
answer: "",
|
answer: "",
|
||||||
sub_queries: [],
|
sub_queries: [],
|
||||||
context_docs: { top_documents },
|
context_docs: { top_documents },
|
||||||
|
is_complete: false,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
subQuestion.context_docs = { top_documents };
|
subQuestion.context_docs = { top_documents };
|
||||||
@ -291,6 +292,7 @@ export const constructSubQuestions = (
|
|||||||
answer: "",
|
answer: "",
|
||||||
sub_queries: [],
|
sub_queries: [],
|
||||||
context_docs: undefined,
|
context_docs: undefined,
|
||||||
|
is_complete: false,
|
||||||
};
|
};
|
||||||
updatedSubQuestions.push(subQuestion);
|
updatedSubQuestions.push(subQuestion);
|
||||||
}
|
}
|
||||||
@ -314,6 +316,7 @@ export const constructSubQuestions = (
|
|||||||
answer: "",
|
answer: "",
|
||||||
sub_queries: [],
|
sub_queries: [],
|
||||||
context_docs: undefined,
|
context_docs: undefined,
|
||||||
|
is_complete: false,
|
||||||
};
|
};
|
||||||
updatedSubQuestions.push(subQuestion);
|
updatedSubQuestions.push(subQuestion);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import rehypeKatex from "rehype-katex";
|
|||||||
import "katex/dist/katex.min.css";
|
import "katex/dist/katex.min.css";
|
||||||
import SubQuestionsDisplay from "./SubQuestionsDisplay";
|
import SubQuestionsDisplay from "./SubQuestionsDisplay";
|
||||||
import { StatusRefinement } from "../Refinement";
|
import { StatusRefinement } from "../Refinement";
|
||||||
|
import SubQuestionProgress from "./SubQuestionProgress";
|
||||||
|
|
||||||
export const AgenticMessage = ({
|
export const AgenticMessage = ({
|
||||||
docSidebarToggled,
|
docSidebarToggled,
|
||||||
@ -250,15 +251,10 @@ export const AgenticMessage = ({
|
|||||||
? agenticDocs
|
? agenticDocs
|
||||||
: docs
|
: docs
|
||||||
}
|
}
|
||||||
subQuestions={
|
subQuestions={[
|
||||||
(isViewingInitialAnswer
|
...(subQuestions || []),
|
||||||
? subQuestions && subQuestions.length > 0
|
...(secondLevelSubquestions || []),
|
||||||
? subQuestions
|
]}
|
||||||
: secondLevelSubquestions
|
|
||||||
: secondLevelSubquestions && secondLevelSubquestions.length > 0
|
|
||||||
? secondLevelSubquestions
|
|
||||||
: subQuestions) || undefined
|
|
||||||
}
|
|
||||||
openQuestion={openQuestion}
|
openQuestion={openQuestion}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
@ -399,8 +395,18 @@ export const AgenticMessage = ({
|
|||||||
{subQuestions && subQuestions.length > 0 && (
|
{subQuestions && subQuestions.length > 0 && (
|
||||||
<SubQuestionsDisplay
|
<SubQuestionsDisplay
|
||||||
docSidebarToggled={docSidebarToggled || false}
|
docSidebarToggled={docSidebarToggled || false}
|
||||||
finishedGenerating={finalContent.length > 8}
|
finishedGenerating={
|
||||||
overallAnswerGenerating={finalContent.length < 8}
|
finalContent.length > 8 &&
|
||||||
|
streamedContent.length == streamedContent.length
|
||||||
|
}
|
||||||
|
overallAnswerGenerating={false}
|
||||||
|
// overallAnswerGenerating={
|
||||||
|
// !!(
|
||||||
|
// secondLevelSubquestions &&
|
||||||
|
// secondLevelSubquestions.length > 0 &&
|
||||||
|
// finalContent.length < 8
|
||||||
|
// )
|
||||||
|
// }
|
||||||
showSecondLevel={!isViewingInitialAnswer}
|
showSecondLevel={!isViewingInitialAnswer}
|
||||||
currentlyOpenQuestion={currentlyOpenQuestion}
|
currentlyOpenQuestion={currentlyOpenQuestion}
|
||||||
allowStreaming={() => setAllowStreaming(true)}
|
allowStreaming={() => setAllowStreaming(true)}
|
||||||
|
@ -27,14 +27,22 @@ export const MemoizedAnchor = memo(
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}): JSX.Element => {
|
}): JSX.Element => {
|
||||||
const value = children?.toString();
|
const value = children?.toString();
|
||||||
// return <></>
|
|
||||||
if (value?.startsWith("[") && value?.endsWith("]")) {
|
if (value?.startsWith("[") && value?.endsWith("]")) {
|
||||||
const match = value.match(/\[(D|Q)?(\d+)\]/);
|
const match = value.match(/\[(D|Q)?(\d+)\]/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const index = parseInt(match[2], 10) - 1;
|
const isSubQuestion = match[1] === "Q";
|
||||||
const associatedDoc = docs?.[index];
|
if (!isSubQuestion) {
|
||||||
if (!associatedDoc) {
|
const index = parseInt(match[2], 10) - 1;
|
||||||
return <a href={children as string}>{children}</a>;
|
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;
|
: undefined;
|
||||||
|
|
||||||
if (!associatedDoc && !associatedSubQuestion) {
|
if (!associatedDoc && !associatedSubQuestion) {
|
||||||
return (
|
return <>{children}</>;
|
||||||
<>
|
|
||||||
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> */}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let icon: React.ReactNode = null;
|
let icon: React.ReactNode = null;
|
||||||
@ -85,22 +82,6 @@ export const MemoizedAnchor = memo(
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return (
|
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
|
<MemoizedLink
|
||||||
updatePresentingDocument={updatePresentingDocument}
|
updatePresentingDocument={updatePresentingDocument}
|
||||||
document={associatedDocInfo}
|
document={associatedDocInfo}
|
||||||
|
@ -480,10 +480,10 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
||||||
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
||||||
useStreamingMessages(secondLevelQuestions || [], () => {});
|
useStreamingMessages(secondLevelQuestions || [], () => {});
|
||||||
const memoizedSubQuestions = useMemo(() => {
|
// const memoizedSubQuestions = useMemo(() => {
|
||||||
return overallAnswerGenerating ? dynamicSubQuestions : subQuestions;
|
// return overallAnswerGenerating ? dynamicSubQuestions : subQuestions;
|
||||||
}, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]);
|
// }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]);
|
||||||
|
const memoizedSubQuestions = dynamicSubQuestions;
|
||||||
const memoizedSecondLevelQuestions = useMemo(() => {
|
const memoizedSecondLevelQuestions = useMemo(() => {
|
||||||
return overallAnswerGenerating
|
return overallAnswerGenerating
|
||||||
? dynamicSecondLevelQuestions
|
? dynamicSecondLevelQuestions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user