Dspy.Prediction (dspy v0.1.0)
View SourceLanguage model predictions with completion metadata.
Predictions represent the outputs from language model calls, including the generated content and metadata about the generation process.
Summary
Functions
Add completion metadata to the prediction.
Get all completions.
Delete an attribute from the prediction.
Get an attribute from the prediction.
Get all attribute keys.
Get the most recent completion.
Create a new Prediction with the given attributes.
Put an attribute in the prediction.
Convert prediction to a map.
Types
@type completion() :: %{ text: String.t(), tokens: pos_integer() | nil, logprobs: map() | nil, finish_reason: String.t() | nil }
@type t() :: %Dspy.Prediction{ attrs: map(), completions: [completion()], metadata: map() }
Functions
Add completion metadata to the prediction.
Get all completions.
Delete an attribute from the prediction.
Get an attribute from the prediction.
Get all attribute keys.
Get the most recent completion.
Create a new Prediction with the given attributes.
Examples
iex> pred = Dspy.Prediction.new(%{answer: "4"})
iex> pred.answer
"4"
iex> pred = Dspy.Prediction.new(answer: "4", reasoning: "2+2=4")
iex> pred.reasoning
"2+2=4"
Put an attribute in the prediction.
Convert prediction to a map.