mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 20:38:32 +02:00
Very minor robustification (#3926)
* very minor robustification * robust
This commit is contained in:
@@ -110,6 +110,7 @@ def decompose_orig_question(
|
|||||||
),
|
),
|
||||||
writer,
|
writer,
|
||||||
)
|
)
|
||||||
|
|
||||||
# dispatches custom events for subquestion tokens, adding in subquestion ids.
|
# dispatches custom events for subquestion tokens, adding in subquestion ids.
|
||||||
streamed_tokens = dispatch_separated(
|
streamed_tokens = dispatch_separated(
|
||||||
model.stream(msg),
|
model.stream(msg),
|
||||||
|
@@ -305,8 +305,10 @@ def dispatch_separated(
|
|||||||
if sep in content:
|
if sep in content:
|
||||||
sub_question_parts = content.split(sep)
|
sub_question_parts = content.split(sep)
|
||||||
_dispatch_nonempty(sub_question_parts[0], dispatch_event, num)
|
_dispatch_nonempty(sub_question_parts[0], dispatch_event, num)
|
||||||
|
|
||||||
if sep_callback:
|
if sep_callback:
|
||||||
sep_callback(num)
|
sep_callback(num)
|
||||||
|
|
||||||
num += 1
|
num += 1
|
||||||
_dispatch_nonempty(
|
_dispatch_nonempty(
|
||||||
"".join(sub_question_parts[1:]).strip(), dispatch_event, num
|
"".join(sub_question_parts[1:]).strip(), dispatch_event, num
|
||||||
@@ -315,6 +317,9 @@ def dispatch_separated(
|
|||||||
_dispatch_nonempty(content, dispatch_event, num)
|
_dispatch_nonempty(content, dispatch_event, num)
|
||||||
streamed_tokens.append(content)
|
streamed_tokens.append(content)
|
||||||
|
|
||||||
|
if sep_callback:
|
||||||
|
sep_callback(num)
|
||||||
|
|
||||||
return streamed_tokens
|
return streamed_tokens
|
||||||
|
|
||||||
|
|
||||||
|
@@ -218,6 +218,7 @@ export interface SubQuestionDetail extends BaseQuestionIdentifier {
|
|||||||
sub_queries?: SubQueryDetail[] | null;
|
sub_queries?: SubQueryDetail[] | null;
|
||||||
context_docs?: { top_documents: OnyxDocument[] } | null;
|
context_docs?: { top_documents: OnyxDocument[] } | null;
|
||||||
is_complete?: boolean;
|
is_complete?: boolean;
|
||||||
|
is_stopped?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubQueryDetail {
|
export interface SubQueryDetail {
|
||||||
@@ -255,6 +256,7 @@ export const constructSubQuestions = (
|
|||||||
);
|
);
|
||||||
if (subQuestion) {
|
if (subQuestion) {
|
||||||
subQuestion.is_complete = true;
|
subQuestion.is_complete = true;
|
||||||
|
subQuestion.is_stopped = 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;
|
||||||
|
@@ -134,7 +134,7 @@ export const useStreamingMessages = (
|
|||||||
if (nextIndex <= sq.question.length) {
|
if (nextIndex <= sq.question.length) {
|
||||||
dynSQ.question = sq.question.slice(0, nextIndex);
|
dynSQ.question = sq.question.slice(0, nextIndex);
|
||||||
p.questionCharIndex = nextIndex;
|
p.questionCharIndex = nextIndex;
|
||||||
if (nextIndex >= sq.question.length) {
|
if (nextIndex >= sq.question.length && sq.is_stopped) {
|
||||||
p.questionDone = true;
|
p.questionDone = true;
|
||||||
}
|
}
|
||||||
didStreamQuestion = true;
|
didStreamQuestion = true;
|
||||||
|
@@ -481,9 +481,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
subQuestions,
|
subQuestions,
|
||||||
() => {},
|
() => {},
|
||||||
() => {
|
() => {
|
||||||
setTimeout(() => {
|
|
||||||
setShowSummarizing(true);
|
setShowSummarizing(true);
|
||||||
}, PHASE_MIN_MS * 3);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
||||||
@@ -549,20 +547,6 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
}
|
}
|
||||||
}, [memoizedSubQuestions]);
|
}, [memoizedSubQuestions]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const allSubQuestionsAnswered =
|
|
||||||
memoizedSubQuestions.length > 0 &&
|
|
||||||
memoizedSubQuestions.every(
|
|
||||||
(subQuestion) => subQuestion?.question.length > 5
|
|
||||||
);
|
|
||||||
|
|
||||||
if (allSubQuestionsAnswered) {
|
|
||||||
setTimeout(() => {
|
|
||||||
setShowSummarizing(true);
|
|
||||||
}, PHASE_MIN_MS * 0.75);
|
|
||||||
}
|
|
||||||
}, [memoizedSubQuestions, finishedGenerating]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showSummarizing && streamedText !== "Summarize findings") {
|
if (showSummarizing && streamedText !== "Summarize findings") {
|
||||||
const fullText = "Summarize findings";
|
const fullText = "Summarize findings";
|
||||||
|
Reference in New Issue
Block a user