dspy.streaming.StreamListener
dspy.streaming.StreamListener(signature_field_name: str, predict: Any = None, predict_name: str = None)
Class that listens to the stream to capture the streeaming of a specific output field of a predictor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signature_field_name
|
str
|
The name of the field to listen to. |
required |
predict
|
Any
|
The predictor to listen to. If None, when calling |
None
|
predict_name
|
str
|
The name of the predictor to listen to. If None, when calling |
None
|
Source code in dspy/streaming/streaming_listener.py
Functions
flush() -> str
Flush all tokens in the field end queue.
This method is called to flush out the last a few tokens when the stream is ended. These tokens are in the buffer because we don't directly yield the tokens received by the stream listener with the purpose to not yield the tokens "[[ ## ... ## ]]".