Class: SkillBench::Clients::RequestBuilder
- Inherits:
-
Object
- Object
- SkillBench::Clients::RequestBuilder
- Defined in:
- lib/skill_bench/clients/request_builder.rb
Overview
Builds and executes HTTP requests to LLM provider APIs. Encapsulates Faraday connection setup and request execution.
Constant Summary collapse
- DEFAULT_OPEN_TIMEOUT =
10- DEFAULT_TIMEOUT =
120
Class Method Summary collapse
-
.build_connection(base_url, open_timeout: DEFAULT_OPEN_TIMEOUT, timeout: DEFAULT_TIMEOUT) ⇒ Faraday::Connection
Creates a Faraday connection with JSON middleware.
-
.execute(connection, path, headers:, body:) ⇒ Faraday::Response
Executes a POST request to the LLM API.
Class Method Details
.build_connection(base_url, open_timeout: DEFAULT_OPEN_TIMEOUT, timeout: DEFAULT_TIMEOUT) ⇒ Faraday::Connection
Creates a Faraday connection with JSON middleware.
19 20 21 22 23 24 25 26 |
# File 'lib/skill_bench/clients/request_builder.rb', line 19 def self.build_connection(base_url, open_timeout: DEFAULT_OPEN_TIMEOUT, timeout: DEFAULT_TIMEOUT) Faraday.new(url: base_url) do |f| f.request :json f.response :json f..open_timeout = open_timeout f..timeout = timeout end end |
.execute(connection, path, headers:, body:) ⇒ Faraday::Response
Executes a POST request to the LLM API.
35 36 37 38 39 40 |
# File 'lib/skill_bench/clients/request_builder.rb', line 35 def self.execute(connection, path, headers:, body:) connection.post(path) do |req| req.headers.update(headers) req.body = body.to_json end end |