You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now let's test out the Typed Predictor by providing some sample input to the predictor and verifying the output type. We can create an `Input` instance and pass it to the predictor to get a dictionary of the output.
While the `dspy.TypedPredictor` and `dspy.TypedChainOfThought` provide a convenient way to use typed predictors, you can also use them as decorators to enforce type constraints on the inputs and outputs of the function. This relies on the internal definitions of the Signature class and its function arguments, outputs, and docstrings.
91
96
92
-
```
93
-
# Function name is output key
94
-
97
+
```python
95
98
@dspy.predictor
96
-
def qa_function(doc_query_pair: Input) -> Output:
97
-
"""Answer the question based on the context and query provided, and on the scale of 10 tell how confident you are about the answer."""
99
+
defanswer(doc_query_pair: Input) -> Output:
100
+
"""Answer the question based on the context and query provided, and on the scale of 0-1 tell how confident you are about the answer."""
98
101
pass
99
102
100
103
@dspy.cot
101
-
def qa_function(doc_query_pair: Input) -> Output:
102
-
"""Answer the question based on the context and query provided, and on the scale of 10 tell how confident you are about the answer."""
104
+
defanswer(doc_query_pair: Input) -> Output:
105
+
"""Answer the question based on the context and query provided, and on the scale of 0-1 tell how confident you are about the answer."""
0 commit comments