@@ -18,23 +18,27 @@ def streamify(program: Module) -> Callable[[Any, Any], Awaitable[Any]]:
18
18
19
19
Args:
20
20
program: The DSPy program to wrap with streaming functionality.
21
+
21
22
Returns:
22
23
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.
24
25
25
26
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
+ ```
38
42
"""
39
43
import dspy
40
44
0 commit comments