Skip to content

Truffler

Rails gem for intent search: Jev answers declared questions when records are saved, and searches become weighted SQL over those answers.

Projectbeta

Overview

Truffler adds intent search to Rails apps using the app's own database and Jev. When a record is saved, Truffler asks Jev the yes/no, choice and score questions declared for that model and stores each answer as a number. Together these form a named-dimension embedding per record. At search time, Jev decides for each label whether the query filters on it, prefers it or ignores it, and one SQL query ranks records by a weighted dot product plus text similarity, keyword and exact hits.

Optional features include smart search, where Jev reranks top candidates into Strong, Possible and Unlikely buckets streamed over Action Cable; provider backup search such as Gmail; and lenses, where a permitted user describes a new kind of search in plain language and Truffler drafts, previews and versions new label questions. It ships no UI and returns plain Ruby data.

What the decision model decides

TypeQuestionAnswers
Yes / noDeclared yes/no question about a record (asked on save)yes · no
ChoiceDoes this search query filter on, prefer, or ignore this label?filter · prefer · ignore
ChoiceHow relevant is this candidate to the query (smart search)?Strong · Possible · Unlikely

How it works

  1. Declare typed questions for a model.
  2. On save, a background job asks Jev and stores numeric answers.
  3. On search, Jev encodes the query's intent per label.
  4. A single SQL query ranks records; optional Jev rerank buckets the top results.

Strengths

  • Read-time search is ordinary SQL, so it is fast and cheap.
  • Answers are stored once per record, not per query.
  • Lenses let users add new searchable dimensions.
  • Backfill spend cap is tracked across runs.

Caveats

  • Requires Rails 7.2 or 8, a job backend and a shared cache store.
  • Labeling cost scales with records and questions.
  • Vector option needs Postgres and pgvector.

Getting started

Add gem "truffler" and gem "ruby_llm-typesafe" to the Gemfile, then bin/rails generate truffler:install && bin/rails db:migrate

At a glance

Type
Project
Status
beta
Language
Ruby
Runtime
Rails gem
Has code
yes

Use cases and integrations

How curated lists describe it

  • Intent search for Rails: the typed questions you declare about a record are asked when it is saved and the answers stored, so the query at read time is ordinary SQL.

    MrJev/awesome-jev

Frequently asked questions

When does Truffler call Jev?

When records are saved, when a query is encoded, and optionally to rerank top results.

Does it include a search UI?

No, it returns plain Ruby data for your own views.

What is a lens?

A user-described kind of search that Truffler turns into new, versioned label questions.

Related projects

  • Drop-in rerank API that speaks Cohere, Jina and Voyage request shapes and scores each document with a Jev relevance question.

    ServicebetaJavaScript
  • Milvus's model library with a Jev reranker that sends candidate documents as yes/no relevance questions and returns them sorted.

    LibraryproductionPython
  • Unofficial LlamaIndex reranker and router where Jev scores retrieved passages and selects query engines, with BEIR results.

    LibrarybetaPython
  • PostgreSQL toolkit with 41 Jev-powered semantic operators and natural-language-to-SQL, leaving joins and arithmetic to SQL.

    ProjectbetaPython
  • RubyLLM provider gem for TypeSafe Jev: block-style typed evaluations with noul, choice and score, plus RubyLLM.rerank support.

    ProjectbetaRuby
  • 248 small installable TypeScript recipes that each make one typed Jev decision: route, rerank, gate, grade, compare or label.

    LibraryproductionTypeScript