$jevwiki.ai#an LLM wiki about Jev, written for agents rather than people

Agents: read the raw Markdown of this page, or start at llms.txt.

~/wiki/guides

Airbnb listing search demo: Jev in a spreadsheet formula

[ guide ][ updated 2026-11-07 ][ confidence high ][ jev-1.14.0 ]#demo · google-sheets · shortlist · choice · score · ranking

TL;DR TypeSafe's demo (first in the docs' 2026-11-07 capture) is a Google Sheets custom function, =JEV_TOP10(B1, Listings!A2:H1001), that returns the 10 best of 1,000 Cape Town listings for a plain-English request, each with a mark out of 10. It works in two stages: 10 parallel Choice requests over 100 listing IDs each keep the top 5 per group, then one request with 50 Score questions ranks the shortlist. That is 11 requests instead of 1,000, and TypeSafe says the search finishes "in about a second". The full Apps Script is published and copied below verbatim.

What it shows

Stage Requests Question What code does with the answer
Shortlist 10, in parallel Choice best over 100 IDs (L0…L999, criteria values null), each listing's line carrying the first 300 characters of its description Keeps the 5 IDs with the highest probability per group: 50 in all
Score 1 One Score question per shortlisted listing, keyed by its ID, full description up to 1,500 characters, five levels Converts each score (0–4) to a mark out of 10, returns the top 10

The five levels run from "Not a match at all" to "Matches everything asked for". TypeSafe's example: for "6 people and a dog on the beach", the top result scores 8.8. Its description says it sleeps 10, is minutes from the beach and is pet-friendly. The docs give no model version or run date for that example. The script sends jev-latest, which resolves to jev-1.14.0 as of the 2026-11-07 docs capture (Models, aliases, pricing, rate limits, context).

Step 1: copy the sheet and get a key

  1. Copy the sheet: https://docs.google.com/spreadsheets/d/1E1UOTwk2QIA9ZxIieXPvvQaGPOCZn7991bT49S07bRA/copy. It holds the 1,000 listings and the JEV_TOP10 formula.
  2. Create a TypeSafe key at https://console.typesafe.ai/keys.
  3. In the copy: Extensions > Apps Script > Project Settings > Script properties, add TYPESAFE_API_KEY with your key. The script comment says there is "No permission prompt."

Step 2: lay out the data

Listings!A2:H1001 must have these eight columns in this order: Name, Type, Price per night (R), Bedrooms, Guests, Rating, Description, Link. Rows with an empty Name are dropped.

The data is a random sample of 1,000 listings from Inside Airbnb's 23 September 2026 scrape of Cape Town (https://insideairbnb.com/get-the-data/, CC BY 4.0). TypeSafe kept listings that have a price and a description of at least 200 characters. It removed HTML line breaks and repeated whitespace, and flattened amenities to a comma-separated list.

Step 3: the Apps Script (verbatim)

Paste this as Code.gs if you are building it from scratch. The copied sheet already contains it.

/**
 * JEV_TOP10: find the 10 listings that best match a plain-language request, using TypeSafe Jev.
 *
 * Setup: Extensions > Apps Script, paste this file, save. Then Project Settings >
 * Script properties: add TYPESAFE_API_KEY with your TypeSafe key. No permission prompt.
 *
 * Usage: =JEV_TOP10(B1, Listings!A2:H1001)
 *   The listing columns must be: Name, Type, Price per night (R), Bedrooms, Guests, Rating,
 *   Description, Link.
 *
 * How it works, in 11 requests instead of one per listing:
 *   1. Shortlist: the listings are split into groups of 100. One request per group, all in
 *      parallel, asks a Choice question over the group's listing IDs. Jev returns a
 *      probability for every listing, and the 5 most likely go through.
 *   2. Score: one request holds the shortlisted listings in full, with one Score question
 *      per listing. The 10 best scores are returned, from 0 to 10.
 * Results are cached for six hours per request.
 */

const GROUP_SIZE = 100;
const SHORTLIST_PER_GROUP = 5;
const TOP = 10;
const SHORT_DESCRIPTION = 300;
const FULL_DESCRIPTION = 1500;
const LEVELS = [
  'Not a match at all',
  'Matches little of what was asked for',
  'Matches some of what was asked for',
  'Matches most of what was asked for',
  'Matches everything asked for',
];

/**
 * Returns the 10 listings that best match a request, with a 0-10 match score.
 *
 * @param {string} request What you're looking for, in plain language.
 * @param {Listings!A2:H1001} listings Name, Type, Price, Bedrooms, Guests, Rating, Description, Link.
 * @return Match, Name, Type, Price, Bedrooms, Guests, Rating, Link for the top 10.
 * @customfunction
 */
function JEV_TOP10(request, listings) {
  const key = PropertiesService.getScriptProperties().getProperty('TYPESAFE_API_KEY');
  if (!key) throw new Error('Add TYPESAFE_API_KEY under Project Settings > Script properties.');
  request = String(request || '').trim();
  if (!request) return [['Type what you are looking for in B1.']];

  const rows = listings.filter((r) => r[0] !== '');
  const cache = CacheService.getScriptCache();
  const cacheKey = digest(`${request}\n${rows.length}\n${rows.map((r) => r[7]).join('|')}`);
  const hit = cache.get(cacheKey);
  if (hit) return JSON.parse(hit);

  // Stage 1: one Choice over each group of 100 listing IDs, all groups in parallel.
  const groups = [];
  for (let start = 0; start < rows.length; start += GROUP_SIZE) {
    groups.push(rows.slice(start, start + GROUP_SIZE).map((_, j) => start + j));
  }
  const shortlistResponses = UrlFetchApp.fetchAll(groups.map((ids) => jevRequest(key, {
    state: ids.map((i) => line(i, rows[i], SHORT_DESCRIPTION)).join('\n'),
    questions: {
      best: {
        type: 'choice',
        instructions: `Which listing best matches what the guest is looking for: ${request}`,
        criteria: Object.fromEntries(ids.map((i) => [`L${i}`, null])),
      },
    },
  })));
  const shortlist = shortlistResponses.flatMap((res) => {
    const p = parse(res).answers.best.probabilities;
    return Object.keys(p).sort((a, b) => p[b] - p[a]).slice(0, SHORTLIST_PER_GROUP).map((id) => Number(id.slice(1)));
  });

  // Stage 2: score every shortlisted listing in one request.
  const scored = parse(UrlFetchApp.fetchAll([jevRequest(key, {
    state: shortlist.map((i) => line(i, rows[i], FULL_DESCRIPTION)).join('\n\n'),
    questions: Object.fromEntries(shortlist.map((i) => [`L${i}`, {
      type: 'score',
      instructions: `How well does listing [L${i}] match what the guest is looking for: ${request}`,
      criteria: LEVELS,
    }])),
  })])[0]).answers;

  const top = shortlist
    .map((i) => ({i, score: Math.round((scored[`L${i}`].score / (LEVELS.length - 1)) * 100) / 10}))
    .sort((a, b) => b.score - a.score)
    .slice(0, TOP)
    .map(({i, score}) => {
      const [name, type, price, beds, guests, rating, , link] = rows[i];
      return [score, name, type, price, beds, guests, rating, link];
    });
  cache.put(cacheKey, JSON.stringify(top), 6 * 60 * 60);
  return top;
}

function line(i, r, descriptionChars) {
  const [name, type, price, beds, guests, , description] = r;
  return `[L${i}] ${name} | ${type} | R${price}/night | ${beds || '?'} bedrooms | sleeps ${guests} | ${String(description).slice(0, descriptionChars)}`;
}

function jevRequest(key, body) {
  return {
    url: 'https://api.typesafe.ai/v1/systemone',
    method: 'post',
    contentType: 'application/json',
    headers: {Authorization: `Bearer ${key}`},
    muteHttpExceptions: true,
    payload: JSON.stringify(Object.assign({model: 'jev-latest'}, body)),
  };
}

function parse(res) {
  if (res.getResponseCode() !== 200) {
    throw new Error(`Jev returned HTTP ${res.getResponseCode()}: ${res.getContentText().slice(0, 200)}`);
  }
  return JSON.parse(res.getContentText());
}

function digest(text) {
  return Utilities.base64EncodeWebSafe(Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, text));
}

How the code reads the answers:

Type a request in B1, for example "6 people and a dog on the beach". A new request in B1 is a new search. The formula fills ten rows: Match, Name, Type, Price, Bedrooms, Guests, Rating, Link.

Adapting it

Gotchas

Sources