Skip to content

Commit a4d162d

Browse files
authored
Merge pull request #27 from HolobiomicsLab/fix-stream-freeze-smooth-refs
Deactivate streaming copyright pass + smooth reference reveal
2 parents 105f995 + 5aa047c commit a4d162d

2 files changed

Lines changed: 11 additions & 24 deletions

File tree

frontend/src/components/ChatPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,12 @@ function AssistantMessage({
907907
// once the turn is final.
908908
const displayed = useTypewriter(
909909
turn.text,
910-
turn.streaming && streaming ? 12 : 99999,
910+
// While streaming, type at a deliberate pace. Once the stream ends, finish
911+
// the buffered tail (e.g. the references block, which arrives in one chunk)
912+
// at a fast but FINITE rate so it eases in smoothly instead of snapping in
913+
// all at once. Historical loads stay instant — useTypewriter starts caught
914+
// up, so no animation runs.
915+
turn.streaming && streaming ? 12 : 48,
911916
);
912917

913918
// Progressively reveal steps + sources while streaming, so a burst

src/perspicacite/rag/modes/basic.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,6 @@ async def execute_stream(
879879
]
880880

881881
# Stream the LLM response
882-
full_response = ""
883882
try:
884883
async for chunk in llm.stream(
885884
messages=messages,
@@ -889,7 +888,6 @@ async def execute_stream(
889888
temperature=0.3,
890889
stage="basic.answer",
891890
):
892-
full_response += chunk
893891
yield StreamEvent.content(chunk)
894892
except Exception as e:
895893
logger.error("basic_streaming_error", error=str(e))
@@ -903,28 +901,12 @@ async def execute_stream(
903901
preamble=scope.scope_note,
904902
)
905903
yield StreamEvent.content(answer)
906-
full_response = answer
907904

908-
# Defense-in-depth copyright filter on the full streamed
909-
# response. For action="log" we just emit a warning log; for
910-
# quote/strip/rewrite we emit a "revision" event after the
911-
# answer with the corrected text — clients may render it or
912-
# ignore. Does not retract the already-streamed content.
913-
try:
914-
revised = await _apply_copyright_filter(
915-
answer=full_response, paper_results=paper_results, llm=llm,
916-
config=self.config,
917-
)
918-
if revised != full_response:
919-
yield StreamEvent(
920-
event="revision",
921-
data=json.dumps({
922-
"kind": "copyright_filter",
923-
"revised_content": revised,
924-
}),
925-
)
926-
except Exception as exc:
927-
logger.warning("copyright_filter_stream_failed", error=str(exc))
905+
# The synchronous copyright-detection pass is intentionally NOT run on
906+
# the streaming (GUI) path. The body has already streamed to the client
907+
# and the client ignores the "revision" event, so it only added a
908+
# visible mid-stream stall before the references with no user-facing
909+
# effect. The non-streaming execute() path still runs it for compliance.
928910

929911
# Append references section after streaming completes
930912
if sources:

0 commit comments

Comments
 (0)