Class: Typesafe::Jev
Overview
Convenience facade over Client for TypeSafe's flagship model, Jev.
The model is pinned to "jev-latest"; for any other model, use Client directly.
Typesafe::Jev.evaluate(state: "My payouts failed", questions: { urgent: Typesafe::Noul.new("Is this urgent?") })
or, reusing one client:
jev = Typesafe::Jev.new
jev.evaluate(state: state, questions: questions)
Constant Summary collapse
- PINNED_MODEL =
"jev-latest"
Constants inherited from Client
Client::API_ENDPOINT, Client::DEFAULT_MODEL
Instance Attribute Summary
Attributes inherited from Client
Class Method Summary collapse
-
.evaluate(state:, questions:, api_key: nil) ⇒ Response
One-shot evaluation using a client built from the environment (or the given API key).
Instance Method Summary collapse
-
#evaluate(state:, questions:, model: nil) ⇒ Response
Evaluates a state against a map of questions with the pinned model.
-
#initialize(api_key: nil) ⇒ Jev
constructor
A new instance of Jev.
Constructor Details
#initialize(api_key: nil) ⇒ Jev
Returns a new instance of Jev.
23 24 25 |
# File 'lib/typesafe/jev.rb', line 23 def initialize(api_key: nil) super(api_key: api_key, model: PINNED_MODEL) end |
Class Method Details
.evaluate(state:, questions:, api_key: nil) ⇒ Response
One-shot evaluation using a client built from the environment (or the given API key). Equivalent to Jev.new(api_key:).evaluate(...).
58 59 60 |
# File 'lib/typesafe/jev.rb', line 58 def self.evaluate(state:, questions:, api_key: nil) new(api_key: api_key).evaluate(state: state, questions: questions) end |
Instance Method Details
#evaluate(state:, questions:, model: nil) ⇒ Response
Evaluates a state against a map of questions with the pinned model.
40 41 42 43 44 45 46 47 |
# File 'lib/typesafe/jev.rb', line 40 def evaluate(state:, questions:, model: nil) if model && model != PINNED_MODEL raise ArgumentError, "Typesafe::Jev pins the model to \"jev-latest\"; use Typesafe::Client for other models" end super(state: state, questions: questions, model: model) end |