-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] writer 노드 종료시 줄바꿈 #106
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,12 @@ | |
| "CreditInsufficient": "system_notice", | ||
| "Fallback": "system_notice", | ||
| } | ||
| # LLM 토큰 스트리밍 완료 후 줄바꿈(\n\n)을 추가로 emit해야 하는 노드 목록 | ||
| # (Writer 노드 등 feature 응답 완료 후 구분선 역할) | ||
| STREAMING_TRAILING_NEWLINE_NODES: set[str] = { | ||
| "Solve_Writer", | ||
| "Explain", | ||
| } | ||
| VISIBLE_NODES: set[str] = set(PROGRESS_MESSAGES.keys()) | { | ||
| "FinalResponse", | ||
| "Simple_response", | ||
|
|
@@ -379,6 +385,8 @@ async def message_generator( | |
|
|
||
| progress_messages = PROGRESS_MESSAGES | ||
| emitted_progress_nodes: set[str] = set() | ||
| # 스트리밍 노드 완료 후 줄바꿈 emit 중복 방지 | ||
| streaming_newline_emitted: set[str] = set() | ||
|
|
||
| def emit_progress(node_name: str) -> str | None: | ||
| if node_name in emitted_progress_nodes: | ||
|
|
@@ -432,6 +440,18 @@ def emit_progress(node_name: str) -> str | None: | |
| if progress_line is not None: | ||
| yield progress_line # type: ignore[misc] | ||
|
|
||
| # 스트리밍 노드 완료 후 줄바꿈 토큰 emit | ||
| if ( | ||
| user_input.stream_tokens | ||
| and node_name in STREAMING_TRAILING_NEWLINE_NODES | ||
| and node_name not in streaming_newline_emitted | ||
| ): | ||
| streaming_newline_emitted.add(node_name) | ||
| newline_payload = json.dumps( | ||
| {"type": "token", "content": "\n\n"}, ensure_ascii=False | ||
| ) | ||
| yield f"data: {newline_payload}\n\n" | ||
|
|
||
| feature_nodes = { | ||
| "Solve", | ||
| "Explain", | ||
|
|
@@ -1061,6 +1081,18 @@ async def _pump_stream(queue: asyncio.Queue[tuple[str, Any]]) -> None: | |
| if "skip_stream" in tag_list: | ||
| continue | ||
| if active_llm_message_id is not None: | ||
| # Writer 노드 등 스트리밍 feature 응답 완료 후 줄바꿈 추가 | ||
| if active_llm_node in STREAMING_TRAILING_NEWLINE_NODES: | ||
| yield emitter.emit( | ||
| "llm.token.delta", | ||
| { | ||
| "message_id": active_llm_message_id, | ||
| "node": active_llm_node, | ||
| "delta": "\n\n", | ||
| "index": active_llm_token_index, | ||
| }, | ||
| ) | ||
| active_llm_token_index += 1 | ||
|
Comment on lines
+1084
to
+1095
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v2 경로에 v1의 v1 경로는
🐛 제안 수정: v2에 deduplication 집합 추가
emitted_artifacts: set[str] = set()
last_credit_signature: tuple[Any, Any, Any] | None = None
+streaming_newline_emitted: set[str] = set()
- if active_llm_node in STREAMING_TRAILING_NEWLINE_NODES:
+ if (
+ active_llm_node in STREAMING_TRAILING_NEWLINE_NODES
+ and active_llm_node not in streaming_newline_emitted
+ ):
+ streaming_newline_emitted.add(active_llm_node)
yield emitter.emit(
"llm.token.delta",🤖 Prompt for AI Agents |
||
| yield emitter.emit( | ||
| "llm.message.completed", | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
rg -n "skip_stream" --type py -C 3Repository: Team-Proovy/Proovy-ai
Length of output: 10802
🏁 Script executed:
rg -n "STREAMING_TRAILING_NEWLINE_NODES" --type py -C 3Repository: Team-Proovy/Proovy-ai
Length of output: 1515
🏁 Script executed:
rg -n "Solve_Writer\|Explain" --type py -C 2Repository: Team-Proovy/Proovy-ai
Length of output: 47
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 1151
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 1613
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 740
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 127
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 2702
🏁 Script executed:
Repository: Team-Proovy/Proovy-ai
Length of output: 2647
v1 경로의 줄바꿈 emit 로직이
skip_stream태그를 확인하지 않아, v2 경로와 비일관적입니다.확인 결과
STREAMING_TRAILING_NEWLINE_NODES에 포함된Solve_Writer(solve/graph.py:428)와Explain(explain/graph.py:100) 노드 모두skip_stream태그 없이 구성되어 있습니다. 따라서 현재는 실제 문제가 발생하지 않습니다.그러나 v2 경로 (
on_chat_model_end핸들러, 1078-1082줄)는 명시적으로if "skip_stream" in tag_list: continue를 확인하는 반면, v1 경로 (443-453줄)는 이 검사가 없습니다. 향후 이 노드들에skip_stream을 추가할 경우 v1 경로에서만 불필요한 줄바꿈이 emit될 수 있으므로, v1 경로에도 동일한skip_stream확인 로직을 추가하는 것이 좋습니다.🤖 Prompt for AI Agents