-
Notifications
You must be signed in to change notification settings - Fork 3
Schema
Schema is a key component of any plan. A Frags schema, is a JsonSchema that describes in great detail the shape of the data that will be produced by the LLM.
In addition to all the default fields you find in the specification, two Frags extensions are available:
-
x-session(required): defines which session is in charge of generating that piece of data
Note: the x-session field can be applied ONLY at to the sub-fields of the root object.
At the very first level, the schema MUST be an object and all the children are required to have at least the
x-session fields, referencing the name of an existing session.
- fields should have a name that's evocative of the data they describe
- Use the
descriptionfield to instruct the LLM on what the data is about. Don't bloat your prompts, use the data descriptions as an extension of the prompt!
Example:
schema:
type: object
required:
- classification
- other_family_members
properties:
classification:
x-session: s1
description: the classification of the animal
type: object
required:
- scientific_name
- common_name
- taxonomy
properties:
scientific_name:
type: string
common_name:
type: string
taxonomy:
type: object
description: the full taxonomy of the animal
required:
- kingdom
- phylum
- class
- order
properties:
kingdom:
type: string
phylum:
type: string
class:
type: string
order:
type: string
family:
type: string
genus:
type: string
species:
type: string
other_family_member:
type: array
x-session: s2
description: other animals of the same family
items:
type: stringSame example, but in Go. Here you may appreciate one extremely important distinction: while the CLI unmarshals to a generic data structure (ProgMap, a thread-safe incremental map), things can be different in Go, as you're free to unmarshal to any map or struct you want, as long as it's been properly described by the schema.
frags.Schema{
Type: "object",
Required: []string{"classification", "other_family_members"},
Properties: map[string]*frags.Schema{
"classification": {
Type: "object",
XSession: &session1,
Required: []string{"scientific_name", "common_name", "taxonomy"},
Properties: map[string]*frags.Schema{
"scientific_name": {Type: "string"},
"common_name": {Type: "string"},
"taxonomy": {
Type: "object",
Required: []string{"kingdom", "phylum", "class", "order", "family", "genus", "species"},
Properties: map[string]*frags.Schema{
"kingdom": {Type: "string"},
"phylum": {Type: "string"},
"class": {Type: "string"},
"order": {Type: "string"},
"family": {Type: "string"},
"genus": {Type: "string"},
"species": {Type: "string"},
},
},
}},
"other_family_members": {
Type: "array",
XSession: &session2,
Items: &frags.Schema{Type: "string"},
},
},
}