Mark which fields are inputs and return a new `Example`. Fields not listed here are treated as labels (expected outputs). DSPy optimizers and evaluators use this split: they pass `example.inputs()` to your program and compare the output against `example.labels()`.
(self, *keys)
| 221 | return self._store.get(key, default) |
| 222 | |
| 223 | def with_inputs(self, *keys): |
| 224 | """Mark which fields are inputs and return a new `Example`. |
| 225 | |
| 226 | Fields not listed here are treated as labels (expected outputs). |
| 227 | DSPy optimizers and evaluators use this split: they pass |
| 228 | `example.inputs()` to your program and compare the output against |
| 229 | `example.labels()`. |
| 230 | |
| 231 | Args: |
| 232 | *keys: Names of the input fields. |
| 233 | |
| 234 | Returns: |
| 235 | A copy of this `Example` with the input keys set. |
| 236 | |
| 237 | Examples: |
| 238 | >>> import dspy |
| 239 | >>> ex = dspy.Example(question="Why?", answer="Because.").with_inputs("question") |
| 240 | >>> ex.inputs().keys() |
| 241 | ['question'] |
| 242 | >>> ex.labels().keys() |
| 243 | ['answer'] |
| 244 | """ |
| 245 | copied = self.copy() |
| 246 | copied._input_keys = set(keys) |
| 247 | return copied |
| 248 | |
| 249 | def inputs(self): |
| 250 | """Return a new `Example` containing only the input fields. |