Skip to content

Commit

Permalink
fix streamify docstring (stanfordnlp#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmoneygithub authored Dec 30, 2024
1 parent a76c682 commit 8825040
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions dspy/utils/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,27 @@ def streamify(program: Module) -> Callable[[Any, Any], Awaitable[Any]]:
Args:
program: The DSPy program to wrap with streaming functionality.
Returns:
A function that takes the same arguments as the original program, but returns an async
generator that yields the program's outputs incrementally.
generator that yields the program's outputs incrementally.
Example:
>>> class TestSignature(dspy.Signature):
>>> input_text: str = dspy.InputField()
>>> output_text: str = dspy.OutputField()
>>>
>>> # Create the program and wrap it with streaming functionality
>>> program = dspy.streamify(dspy.Predict(TestSignature))
>>>
>>> # Use the program with streaming output
>>> async def use_streaming():
>>> output_stream = program(input_text="Test")
>>> async for value in output_stream:
>>> print(value) # Print each streamed value incrementally
```python
class TestSignature(dspy.Signature):
input_text: str = dspy.InputField()
output_text: str = dspy.OutputField()
# Create the program and wrap it with streaming functionality
program = dspy.streamify(dspy.Predict(TestSignature))
# Use the program with streaming output
async def use_streaming():
output_stream = program(input_text="Test")
async for value in output_stream:
print(value) # Print each streamed value incrementally
```
"""
import dspy

Expand Down

0 comments on commit 8825040

Please sign in to comment.