MCPcopy
hub / github.com/stanfordnlp/dspy / with_inputs

Method with_inputs

dspy/primitives/example.py:223–247  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

_shuffle_and_sampleMethod · 0.95
__init__Method · 0.80
from_huggingfaceMethod · 0.80
from_csvMethod · 0.80
from_pandasMethod · 0.80
from_jsonMethod · 0.80
from_parquetMethod · 0.80
from_rmMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 2

copyMethod · 0.95
setFunction · 0.85