@@ -18,23 +18,27 @@ def streamify(program: Module) -> Callable[[Any, Any], Awaitable[Any]]:
1818
1919 Args:
2020 program: The DSPy program to wrap with streaming functionality.
21+
2122 Returns:
2223 A function that takes the same arguments as the original program, but returns an async
23- generator that yields the program's outputs incrementally.
24+ generator that yields the program's outputs incrementally.
2425
2526 Example:
26- >>> class TestSignature(dspy.Signature):
27- >>> input_text: str = dspy.InputField()
28- >>> output_text: str = dspy.OutputField()
29- >>>
30- >>> # Create the program and wrap it with streaming functionality
31- >>> program = dspy.streamify(dspy.Predict(TestSignature))
32- >>>
33- >>> # Use the program with streaming output
34- >>> async def use_streaming():
35- >>> output_stream = program(input_text="Test")
36- >>> async for value in output_stream:
37- >>> print(value) # Print each streamed value incrementally
27+
28+ ```python
29+ class TestSignature(dspy.Signature):
30+ input_text: str = dspy.InputField()
31+ output_text: str = dspy.OutputField()
32+
33+ # Create the program and wrap it with streaming functionality
34+ program = dspy.streamify(dspy.Predict(TestSignature))
35+
36+ # Use the program with streaming output
37+ async def use_streaming():
38+ output_stream = program(input_text="Test")
39+ async for value in output_stream:
40+ print(value) # Print each streamed value incrementally
41+ ```
3842 """
3943 import dspy
4044
0 commit comments