流式调用工作流,event None没有传出来,直接处理成了None,很奇怪的处理方式
- Dominant language
- Python
- Stars
- 492
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
```python
def _workflow_stream_handler(data: Dict[str, str], raw_response: httpx.Response) -> Optional[WorkflowEvent]:
id = int(data["id"])
event = data["event"]
event_data = data["data"] # type: str
if event == WorkflowEventType.DONE:
return None
elif event == WorkflowEventType.MESSAGE:
return WorkflowEvent(
id=id,
event=event,
message=WorkflowEventMessage.model_validate_json(event_data),
)
elif event == WorkflowEventType.ERROR:
return WorkflowEvent(id=id, event=event, error=WorkflowEventError.model_validate_json(event_data))
elif event == WorkflowEventType.INTERRUPT:
return WorkflowEvent(
id=id,
event=event,
interrupt=WorkflowEventInterrupt.model_validate_json(event_data),
)
else:
return WorkflowEvent(id=id, event=WorkflowEventType.UNKNOWN, unknown=data)
```
中的这行
```python
if event == WorkflowEventType.DONE:
return None
```
Contributor guide
Research direction
Start at _workflow_stream_handler, especially the DONE event branch shown in the issue, and trace how its return value is consumed by the workflow streaming path. Check existing streaming tests or response handling to determine the intended treatment of DONE events; done means the behavior is specified and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100