@curless/hotel-storefront 0.55.4 → 0.55.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -1371,6 +1371,10 @@ export const buildOutputSchemas = (n) => ({
1371
1371
  degraded: ARR,
1372
1372
  /** What `degraded` means, as the text says it: not that those groups have none here. */
1373
1373
  degradedSaid: STR,
1374
+ /** In a market: the place asked for, when it was not recognised - the hotels are not that place's (`unplacedOf`). */
1375
+ unplaced: STR,
1376
+ /** What `unplaced` means, as the text says it. */
1377
+ unplacedSaid: STR,
1374
1378
  ...HOTEL_PAGE,
1375
1379
  },
1376
1380
  required: ['view'],
@@ -1572,6 +1576,9 @@ export const buildOutputSchemas = (n) => ({
1572
1576
  /** A \`city\` read in a market: the groups that did not answer in time (\`degradedOf\`). */
1573
1577
  degraded: ARR,
1574
1578
  degradedSaid: STR,
1579
+ /** A \`city\` not recognised as a place: what was read is not that city's (\`unplacedOf\`). */
1580
+ unplaced: STR,
1581
+ unplacedSaid: STR,
1575
1582
  },
1576
1583
  required: ['view'],
1577
1584
  },
@@ -3053,6 +3060,26 @@ card = !noCards) => {
3053
3060
  said,
3054
3061
  };
3055
3062
  };
3063
+ /**
3064
+ * A place no table here knows (`HotelSearchResult.unplaced`), as the sentence the
3065
+ * model is told and the field the card draws its own line from.
3066
+ *
3067
+ * ⚠️ NEVER "N HOTELS IN REYKJAVIK" (总线程 11-04, 0.55.5). Words that name no
3068
+ * place this market knows narrow nothing, and the backend answers a place it
3069
+ * cannot match with every hotel each group has - so the list is Sanya's,
3070
+ * Singapore's, Tokyo's. Said once, in the text and in `structuredContent`
3071
+ * alike: a host with no card has only the words.
3072
+ */
3073
+ const unplacedOf = (deps, answer,
3074
+ /** The words were a `city` - or a guest's own words (`query`), a place looked for inside them. */
3075
+ asCity) => {
3076
+ const place = answer.unplaced?.trim();
3077
+ if (!place)
3078
+ return { structured: {}, said: '' };
3079
+ const n = deps.vocab.nounPlural;
3080
+ const said = `${asCity ? `"${place}" was not recognised as a place` : `No place was recognised in "${place}"`}, so these are the ${n} the groups returned, each in its own city - they are not ${n} in the place asked for, and are not to be called that.`;
3081
+ return { structured: { unplaced: place, unplacedSaid: said }, said };
3082
+ };
3056
3083
  /**
3057
3084
  * What is said when a read could not be had because hotel groups did not answer
3058
3085
  * in time - one group, or several, or every one.
@@ -5310,6 +5337,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
5310
5337
  // Every one by name and city, and that there are no others - or, told
5311
5338
  // only "2 hotels", the model asked for the list again to learn which.
5312
5339
  const degraded = degradedOf(deps, answer, undefined, ctx?.noCards);
5340
+ const unplaced = unplacedOf(deps, answer, !!asked.city);
5313
5341
  const inAll = homeList
5314
5342
  ? `There are ${total} ${branded(deps.vocab, deps.vocab.nounPlural)} here in all, and this answer lists every one: ${hotels
5315
5343
  .map((h) => `${hotelName(h.name)}${h.city ? ` in ${h.city}` : ''}`)
@@ -5364,6 +5392,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
5364
5392
  ...(answer.currencies.length > 1 ? { currencies: answer.currencies } : {}),
5365
5393
  // A group that did not answer, in both: the card draws a line from it.
5366
5394
  ...degraded.structured,
5395
+ // A place not recognised, in both: the card heads the list without it.
5396
+ ...unplaced.structured,
5367
5397
  // In both, like a plan's: a host with no card may hand its model this
5368
5398
  // rather than the text.
5369
5399
  ...(ctx.noCards ? { notDrawn: LIST_NOT_DRAWN } : {}),
@@ -5372,6 +5402,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
5372
5402
  text: [
5373
5403
  inAll ||
5374
5404
  `${total} ${branded(deps.vocab, total === 1 ? deps.vocab.noun : deps.vocab.nounPlural)}${where}.`,
5405
+ unplaced.said,
5375
5406
  // ⚠️ NO "BELOW", NO "TAP". This sentence is read out by a voice
5376
5407
  // assistant as often as it is drawn next to a card, and a guest whose
5377
5408
  // host has no card at all cannot tap the one it tells them to tap. The
@@ -5633,6 +5664,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
5633
5664
  }
5634
5665
  // `look_up` draws no card: the guest asks again in words (`askLater`).
5635
5666
  const degraded = degradedOf(deps, degradedFound, undefined, ctx?.noCards, false);
5667
+ // A city no table here knows: what was read is not that city's (0.55.5).
5668
+ const unplaced = unplacedOf(deps, degradedFound, true);
5636
5669
  const unique = [...new Set(ids)];
5637
5670
  // A name that fits more than one is said with the ones it fits; the rest are not found.
5638
5671
  const notFound = dropped.filter((d) => !candidates.some((c) => c.for === d));
@@ -5717,9 +5750,11 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
5717
5750
  ...(dropped.length ? { dropped } : {}),
5718
5751
  ...(candidates.length ? { candidates } : {}),
5719
5752
  ...degraded.structured,
5753
+ ...unplaced.structured,
5720
5754
  },
5721
5755
  text: [
5722
5756
  `Read ${read.length}${total > read.length ? ` of ${total}` : ''} ${read.length === 1 ? deps.vocab.noun : deps.vocab.nounPlural}. Nothing was shown to the guest.`,
5757
+ unplaced.said,
5723
5758
  degraded.said,
5724
5759
  ...blocks,
5725
5760
  notFound.length ? `Not found: ${notFound.map((d) => `"${d}"`).join(', ')}.` : '',