org.llm4s.prompt.Promptable
See thePromptable companion object
@Experimental
How a value of type A is written into a Prompt.
An interpolated value is rendered by its Promptable, never by toString, and a type without one does not compile: prompt"Summarise $client" (an LLMClient) is a compile error naming the type.
case class Invoice(customer: String, amount: BigDecimal, currency: String) derives Promptable
prompt"Check ${Invoice("ACME, Inc.", BigDecimal("12.5"), "EUR")}"
// Check Invoice(customer: "ACME, Inc.", amount: 12.5, currency: "EUR")
The rendering is deterministic: a case class is its name and labelled fields in declaration order, an enum case its name, a Seq its elements in order, a Set and a Map sorted by their rendered elements and keys, None is (none), and a Some its value. A string on its own is written as it is; inside a structure it is quoted, so a comma in a field cannot be read as the end of the field.
Type parameters
- A
-
the type rendered.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object given_Promptable_String
Members list
In this article