shipwithjev

Catalog / Tools & apps

0394GitHub

ruby_decision_model

Ruby client with standard-library transport for TypeSafe and OpenRouter decision endpoints.

obie/ruby_decision_modelREADME ↗
# ruby_decision_model

The decision-model interface for Ruby. Decision models answer typed questions
about a state with calibrated probabilities instead of generating text. This gem
talks to them through one `Client` with a provider behind it: OpenRouter by
default, Typesafe's native API as a second door, more providers as labs ship
them. No runtime dependencies beyond the standard library.

## Install

```ruby
gem "ruby_decision_model"
```

## Quick start

```ruby
require "ruby_decision_model"

client = RubyDecisionModel::Client.new

response = client.ask(
  state: { title: "Server returns 500 on checkout", reporter: "support" },
  questions: {
    "urgent" => RubyDecisionModel::Questions.noul("Is this urgent?"),
    "severity" => RubyDecisionModel::Questions.score(
      "How severe is this issue?",
      criteria: ["cosmetic", "minor", "major", "critical"]
    )
  }
)

response["urgent"].noul       # => 0.87
response["severity"].score    # => 2.4
response.usage.input_tokens   # => 120
```

`Client.new` with no arguments reads the environment: `TYPESAFE_API_KEY` selects
Typesafe, otherwise `OPENROUTER_API_KEY` selects OpenRouter. With neither set it
raises `ConfigurationError` naming both. `RubyDecisionModel.client` memoizes one
such default client; assign `nil` to reset it.

## Providers

### OpenRouter (default)

```ruby
# ENV["OPENROUTER_API_KEY"]
client = RubyDecisionModel::Client.new(provider: :open_router)

# or pass the key directly; api_key: alone still means OpenRouter
client = RubyDecisionModel::Client.new(api_key: "sk-or-...")
```

Requests go to `https://openrouter.ai/api/alpha/decisions`. The default model is
`typesafe/jev-1.13`. Usage reports `input_tokens`, `output_tokens`, and `cost`.

### Typesafe native API

```ruby
# ENV["TYPESAFE_API_KEY"]
client =

Also filed under Tools & apps

  1. 0573

    Support chat: agent offered a human escalation path

    A frustrated customer hits a bot loop twice; the judge checks whether a human handoff was offered.

    everyai-com · Tools & apps

  2. 0572

    Subscription cancel: effective date is explicit

    An agent cancels a subscription; the judge checks the exact date the cancellation takes effect.

    everyai-com · Tools & apps

  3. 0571

    Sales quote: numbers match the official price list

    An agent quotes $29/seat against a price list; the judge checks the quote matches exactly.

    everyai-com · Tools & apps

  4. 0570

    Refund chat: agent stated the amount before issuing it

    A support agent issues a $42.50 refund; the judge checks the exact amount was stated before the refund was confirmed.

    everyai-com · Tools & apps