Class: WaveDispatch::Client
- Inherits:
-
Object
- Object
- WaveDispatch::Client
- Defined in:
- lib/wave_dispatch.rb
Overview
0.5.1 — payment hook: a Proc called once with the 402 challenge body (Hash) that returns the headers (Hash[String => String]) to retry the request with. Pair with ‘Client.wallet_hook(provider:, credentials:)` for the built-in CDP / Privy / Bridge factories, or build a Proc yourself.
Class Method Summary collapse
-
.wallet_hook(provider:, credentials: {}) ⇒ Object
0.5.1 — build a payment_hook for a built-in provider.
Instance Method Summary collapse
-
#execute(prompt, profile = nil) ⇒ Object
Classify and run on the edge if your plan allows it.
-
#initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online", agents_endpoint: ENV["WAVE_AGENTS_ENDPOINT"] || "https://dispatch-agents.wave.online", payment_hook: nil) ⇒ Client
constructor
A new instance of Client.
-
#route(prompt, profile = nil) ⇒ Object
Classify a prompt (no execution) -> “probability”, “margin”, “forward” Sovereign tier: pass profile (Fast|Expert|Heavy|Code) to request a named routing profile.
-
#route_vector(vector, profile = nil) ⇒ Object
Classify a pre-computed 768-d embedding (matmul-only: cheapest + fastest).
-
#savings ⇒ Object
This license’s savings ledger (decisions, saved_usd, saved_pct, …).
-
#subscribe(plan) ⇒ Object
Start/replace a programmatic subscription (plan: agent_starter | agent_pro | agent_scale).
-
#subscription ⇒ Object
This license’s agent-subscription status.
Constructor Details
#initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online", agents_endpoint: ENV["WAVE_AGENTS_ENDPOINT"] || "https://dispatch-agents.wave.online", payment_hook: nil) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 |
# File 'lib/wave_dispatch.rb', line 16 def initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online", agents_endpoint: ENV["WAVE_AGENTS_ENDPOINT"] || "https://dispatch-agents.wave.online", payment_hook: nil) @license = license @endpoint = endpoint @agents = agents_endpoint @payment_hook = payment_hook # 0.5.1 — handles 402 inside the client end |
Class Method Details
.wallet_hook(provider:, credentials: {}) ⇒ Object
0.5.1 — build a payment_hook for a built-in provider. provider: :cdp | :privy | :bridge. credentials per provider: cdp: api_secret:, address:; privy: app_secret:, wallet_id:; bridge: source_wallet:, destination:. For custom wallets, build a Proc of your own that returns the header Hash you want set on the retry.
48 49 50 51 52 53 |
# File 'lib/wave_dispatch.rb', line 48 def self.wallet_hook(provider:, credentials: {}) provider = provider.to_sym header = { cdp: "cdp-payment", privy: "privy-payment", bridge: "bridge-payment" }[provider] raise "dispatch.wallet_hook: unknown provider #{provider.inspect}" unless header ->(challenge) { { header => WaveDispatch.wallet_sign(provider, credentials, challenge) } } end |
Instance Method Details
#execute(prompt, profile = nil) ⇒ Object
Classify and run on the edge if your plan allows it. Optional profile as in route.
30 |
# File 'lib/wave_dispatch.rb', line 30 def execute(prompt, profile = nil) = send_req(:post, @endpoint + "/", with_profile({ prompt: prompt, execute: true }, profile)) |
#route(prompt, profile = nil) ⇒ Object
Classify a prompt (no execution) -> “probability”, “margin”, “forward” Sovereign tier: pass profile (Fast|Expert|Heavy|Code) to request a named routing profile.
27 |
# File 'lib/wave_dispatch.rb', line 27 def route(prompt, profile = nil) = send_req(:post, @endpoint + "/", with_profile({ prompt: prompt }, profile)) |
#route_vector(vector, profile = nil) ⇒ Object
Classify a pre-computed 768-d embedding (matmul-only: cheapest + fastest).
33 |
# File 'lib/wave_dispatch.rb', line 33 def route_vector(vector, profile = nil) = send_req(:post, @endpoint + "/", with_profile({ vector: vector }, profile)) |
#savings ⇒ Object
This license’s savings ledger (decisions, saved_usd, saved_pct, …). Requires a license.
36 |
# File 'lib/wave_dispatch.rb', line 36 def savings = send_req(:get, "#{@agents}/ledger/summary?license=#{lic}") |
#subscribe(plan) ⇒ Object
Start/replace a programmatic subscription (plan: agent_starter | agent_pro | agent_scale).
42 |
# File 'lib/wave_dispatch.rb', line 42 def subscribe(plan) = send_req(:post, "#{@agents}/subscription/create", { license: @license, plan: plan }) |
#subscription ⇒ Object
This license’s agent-subscription status.
39 |
# File 'lib/wave_dispatch.rb', line 39 def subscription = send_req(:get, "#{@agents}/subscription/status?license=#{lic}") |