Skip to main content

Add a skill with cards

When. The person must see things of the tenant (products, slots, templates) as cards, with their name, price, image and link.

Steps​

  1. cognitive.objective tells the model when to call the skill.
  2. invoke names the operation that returns the rows (method, a read). What the model gives is a parameter (params, set_by: [llm]), sent through invoke.args under the argument's name: args: {q: "$params.q"}.
  3. kinds makes the rows items: one kind without when takes them all; several kinds each write their when on a presented field ($fields.<name>).
  4. present.fields declares what each item carries: from (the tenant's field), type and role. Roles: title, billed (a price), link (a url), cadence, eyebrow (the line above the name), badge (a pill, several allowed), meta (the small line under the name), tile (an image or a text).
  5. render.component: carousel, cards, steps (a bundle) or report (a figure).
  6. For the person to choose, add a submit (Submit the selection); for them to fill something in, guards (A form and its guards).

The example​

skill-with-cards.yaml
# A skill whose rows become cards: `invoke` reads the tenant's rows, `kinds` makes them items,
# `present` says which field plays which role on the card, `render` draws them. Nothing is filed
# here: the cards are to look at (a selection and its submit are the next recipes).
# Replace api.example.com and shop.example.com by the API and the site.
station:
id: book-corner
name: Book Corner

global:
language: en
currency: EUR
locale: en-GB

domain:
domain_type: retail
entity_name: book
entity_name_plural: books

voice:
tone: friendly
persona: "a bookseller who reads everything"
rules:
- "Never invent a book or a price: everything comes from the tool."

apis:
- name: books
openapi_url: https://api.example.com/openapi.json
base_url: https://api.example.com
operations:
- {id: searchBooks, access: read}
auth: {type: none}

profiles:
everyone:
when: "true"
grants: [books.searchBooks]

skills:
- name: find-books
cognitive:
objective: "show the books that match what the person asks for: a title, an author, a theme"
params:
q: {type: text, set_by: [llm]}
invoke:
method: searchBooks
args: {q: "$params.q"}
kinds: {book: {}} # one kind, no `when`: every row is a book
present:
fields:
name: {from: title, type: text, role: title} # `name` is the title's field
price: {from: price, type: price, role: billed} # `price` is the billed one
image_url: {from: cover, type: image} # the first image is the card's
author: {from: author, type: text, role: eyebrow} # the line above the name
genre: {from: genre, type: text, role: badge} # a pill; several badges may show
pages: {from: page_count, type: text, role: meta} # the small line under the name
summary: {from: summary, type: text} # in the card's details
page:
from: isbn
type: url
role: link
template: "https://shop.example.com/books/{value}" # `{value}` is the field's value
render: {component: carousel}

The pitfalls​

  • Three names are reserved: name is the title field, price the billed, image_url the first image. code, slug and id are refused: Core writes the item's reference there.
  • One field per role (but badge), of the right type: billed asks for a price, link a url, tile an image or a text.
  • Only what is declared is read. A key of the tenant's row missing from present reaches neither the card, nor a when, nor a submit ($item.fields.<name>).
  • A link is never invented. Without a role: link field, the card has no link. Its template knows only {value} and {tenant_url}, and starts with {tenant_url} or an absolute http(s) address.
  • A price that is not a number ("12,50", null): the row is not offered.
  • A parameter must be used. A set_by: [llm] parameter that invoke.args does not read is refused; required: false goes only on a model parameter without default.
  • present, select and submit go with kinds: on a skill without kinds, they are refused. So is kinds without invoke.
  • render has a closed vocabulary: an unknown component refuses the station.

Reference: Skills, params and invoke.args, Field types.