Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very minor robustification #3926

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def decompose_orig_question(
),
writer,
)

# dispatches custom events for subquestion tokens, adding in subquestion ids.
streamed_tokens = dispatch_separated(
model.stream(msg),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ def dispatch_separated(
if sep in content:
sub_question_parts = content.split(sep)
_dispatch_nonempty(sub_question_parts[0], dispatch_event, num)

if sep_callback:
sep_callback(num)

num += 1
_dispatch_nonempty(
"".join(sub_question_parts[1:]).strip(), dispatch_event, num
Expand All @@ -315,6 +317,9 @@ def dispatch_separated(
_dispatch_nonempty(content, dispatch_event, num)
streamed_tokens.append(content)

if sep_callback:
sep_callback(num)

return streamed_tokens


Expand Down
2 changes: 2 additions & 0 deletions web/src/app/chat/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export interface SubQuestionDetail extends BaseQuestionIdentifier {
sub_queries?: SubQueryDetail[] | null;
context_docs?: { top_documents: OnyxDocument[] } | null;
is_complete?: boolean;
is_stopped?: boolean;
}

export interface SubQueryDetail {
Expand Down Expand Up @@ -255,6 +256,7 @@ export const constructSubQuestions = (
);
if (subQuestion) {
subQuestion.is_complete = true;
subQuestion.is_stopped = true;
}
} else if ("top_documents" in newDetail) {
const { level, level_question_num, top_documents } = newDetail;
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/chat/message/StreamingMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const useStreamingMessages = (
if (nextIndex <= sq.question.length) {
dynSQ.question = sq.question.slice(0, nextIndex);
p.questionCharIndex = nextIndex;
if (nextIndex >= sq.question.length) {
if (nextIndex >= sq.question.length && sq.is_stopped) {
p.questionDone = true;
}
didStreamQuestion = true;
Expand Down
18 changes: 1 addition & 17 deletions web/src/app/chat/message/SubQuestionsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
subQuestions,
() => {},
() => {
setTimeout(() => {
setShowSummarizing(true);
}, PHASE_MIN_MS * 3);
setShowSummarizing(true);
}
);
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
Expand Down Expand Up @@ -549,20 +547,6 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
}
}, [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(() => {
if (showSummarizing && streamedText !== "Summarize findings") {
const fullText = "Summarize findings";
Expand Down
Loading