Creating Custom Types¶
QType allows you to create custom types for variable inputs and outputs.
Custom types must be defined the in types
list in your Application. They can not be defined in-line in variables.
Internally, custom types are mapped to pydantic objects.
CustomType¶
A simple declaration of a custom data type by the user.
- id (
str
): (No documentation available.) - description (
str | None
): (No documentation available.) - properties (
dict[str, str]
): (No documentation available.)
A Simple Example¶
The following example illustrates the key features of custom types:
- The custom types
Arthor
andBook
are defined. Those terms can be used as atype
in any variable. - All fields of the custom types should be other custom types, primitive types, or domain types
- A
?
can be used after the type to indicate it is optional. In this case, it will beNone
if not provided. - A
list[type]
can be used to indicate a list. - Forward references are allowed --
Book
referencesArthor
which is defined later
id: valid_custom_type
types:
- id: Book
properties:
title: text
author: Author # <-- this is a forward reference
year: int?
tags: "list[text]"
published: boolean
- id: Author
properties:
id: int
name: text
flows:
- id: my_person_flow
mode: Complete
steps:
- id: prompt_template
template: >
You are a helpful assistant. Please provide information about the following book:
{book}
inputs:
- id: book
type: Book
outputs:
- id: prompt_format
type: text