Class: Aireview::JevClient
- Inherits:
-
Object
- Object
- Aireview::JevClient
- Defined in:
- lib/aireview/jev_client.rb
Overview
One evaluation request to Jev (TypeSafe, POST /v1/systemone): a state and named questions in, one answer per question out. RubyLLM does not know Jev and the router is built for text models, so Jev has its own small client: one retry on 429/529, no key rotation, no reserves. A failure is a JevError; the caller decides whether it matters.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- API_URL =
'https://api.typesafe.ai/v1/'- OPEN_TIMEOUT =
5- RETRY_STATUSES =
[429, 529].freeze
- RETRY_DELAY =
2- MAX_RETRY_DELAY =
retry-after beyond this is not worth waiting for in a review job.
10
Instance Method Summary collapse
-
#evaluate(state:, questions:) ⇒ Object
questions — => question; returns Result with answers under the same keys, each checked against the type of its question.
-
#initialize(config:, logger: Logger.new($stderr), **dependencies) ⇒ JevClient
constructor
Jev goes out the same way as the LLM providers, through LLM_HTTP_PROXY when it is set.
Constructor Details
#initialize(config:, logger: Logger.new($stderr), **dependencies) ⇒ JevClient
Jev goes out the same way as the LLM providers, through LLM_HTTP_PROXY when it is set. dependencies — connection: and sleeper: for tests.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/aireview/jev_client.rb', line 26 def initialize(config:, logger: Logger.new($stderr), **dependencies) require 'faraday' raise ConfigError, 'JEV_API_KEY is required' if Aireview::Utils.blank?(config.jev_api_key) @api_key = config.jev_api_key @model = config.jev_model @logger = logger @connection = dependencies[:connection] || build_connection(config.jev_timeout, config.llm_http_proxy) @sleeper = dependencies[:sleeper] || ->(seconds) { sleep(seconds) } end |
Instance Method Details
#evaluate(state:, questions:) ⇒ Object
questions — => question; returns Result with answers under the same keys, each checked against the type of its question.
40 41 42 43 44 45 46 47 |
# File 'lib/aireview/jev_client.rb', line 40 def evaluate(state:, questions:) body = JSON.generate(model: @model, state: state, questions: questions) @logger.info("Jev request started (model=#{@model}, questions=#{questions.size})") response = post_with_one_retry(body) result = parse(response, questions) log_completed(result) result end |