Flowform Language
This guide provides a comprehensive overview of the Flowform schema language, which is used to define the structure and behavior of your Flowformer applications.
Table of Contents
- Introduction
- Schema Structure
- Model Declarations
- Attributes
- Union Declarations
- Field Definitions
- Functions
- Literals and Primitive Types
Introduction
The Flowform schema language allows you to create well-structured and customizable generative AI applications. By defining models, attributes, unions, fields, and functions, you can build sophisticated applications with ease.
Schema Structure
A Flowform schema is composed of multiple definition nodes. Each definition node can be one of the following:
- Model Declaration
- Attribute Declaration
- Function Declaration
- Union Declaration
These nodes collectively define the behavior and structure of your Flowformer application.
Model Declarations
Model declarations are the core of your schema, defining the main data structures used in your application.
Syntax
model ModelName (attributes)* {
fieldName FieldType (optional)? (attributes)* (functionPipes)*
}
Example
model Presentation {
title String? @description("The title of the presentation")
slides PresentationSlide[] @description("The slides in the presentation.") @itemRenderer("PresentationSlide")
}
Attributes
Attributes provide additional metadata and behavior to models and fields.
Using Attributes
Attributes can be applied to models and fields.
model Presentation {
title String @description("The title of the presentation")
}
Union Declarations
Union declarations allow you to define a type that can be one of several specified types.
Syntax
union UnionName = Type1 | Type2 | Type3
Example
union PresentationSlide = SingleImageSlide | BulletPointSlide | TitleOnlySlide
Field Definitions
Fields define the properties of a model. They specify the name, type, and optional attributes or functions associated with the field.
Syntax
fieldName FieldType (optional)? (attributes)* (functionPipes)*
Example
model BulletPointSlide {
title String @description("The title of the slide")
narration String @description("The narration for the slide")
bulletPoints String[] @description("The bullet points on the slide")
}
Optional Fields
Fields can be optional, indicated by a ?
.
title String?
Field Functions
Fields can have functions applied to them using pipes.
queryForImage String -> fn generateImage as generatedImage @description("The generated image")
Functions
The language currently supports declaring functions, but the Flowformer platform does not yet support implementing them.
Functions define custom logic that can be applied to fields.
Syntax
fn functionName(paramName: Type) => ReturnType
Example
fn generateImage(query: String) => ImageType
Literals and Primitive Types
The Flowform language supports several primitive types and literal values.
Primitive Types
String
Number
Boolean
Literals
String Literal
"title" | 'title'
Number Literal
123
Boolean Literal
true | false
Literal Expressions
Literal expressions can be used as attribute arguments.
@description("This is a description")