namedtuples
org.llm4s.schema.namedtuples
@Experimental
object namedtuples
A uPickle ReadWriter for named tuples, which uPickle does not provide, so that a named tuple can be a structured output or a tool's arguments and result with no case class to declare:
import org.llm4s.schema.*
import org.llm4s.schema.namedtuples.given
val review = client.completeStructuredOf[(sentiment: Sentiment, confidence: Double)](conversation)
review.map(_.sentiment)
A named tuple is written as uPickle writes a case class with the same fields and no default values: a JSON object keyed by the names, in order, with null for a None. It is read the same way, except that an absent Option element reads as None (a case class needs a default for that); any other absent element is an error naming it, and keys the tuple has no element for are ignored. Each element needs a ReadWriter of its own.
It is imported explicitly, never found on its own, so that it cannot compete with an instance uPickle may add later.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
namedtuples.type
Members list
In this article