Skip to content

Variable

Variables are the fundamental data containers in QType. All data flowing between Steps must be explicitly declared as variables. This "declare before use" principle creates clear data contracts and enables static validation.

Variable Scoping

Variables are scoped to the Flow where they are declared. Each flow's variables section lists all variables available within that flow.

flows:
  - type: Flow
    id: my_flow
    variables:
      - id: user_input
        type: text
      - id: processed_output
        type: text

Variable Declaration

Each variable must have: - Unique ID: Used to reference the variable throughout the flow. Must be unique within the flow's scope. - Type: Specifies the data type (primitive, domain-specific, or custom type).

Referencing Variables

Steps reference variables by their ID (as a string):

steps:
  - id: my_step
    type: LLMInference
    inputs:
      - user_input  # References the variable declared above
    outputs:
      - processed_output

The validator ensures that all referenced variables are declared in the flow's variables section.

Variable

Schema for a variable that can serve as input, output, or parameter within the DSL.

  • id (str): Unique ID of the variable. Referenced in prompts or steps.
  • type (VariableType | str): Type of data expected or produced. Either a CustomType or domain specific type.

PrimitiveTypeEnum

Represents the type of data a user or system input can accept within the DSL.

  • audio: Represents the type of data a user or system input can accept within the DSL.
  • boolean: Represents the type of data a user or system input can accept within the DSL.
  • bytes: Represents the type of data a user or system input can accept within the DSL.
  • citation_document: Represents the type of data a user or system input can accept within the DSL.
  • citation_url: Represents the type of data a user or system input can accept within the DSL.
  • date: Represents the type of data a user or system input can accept within the DSL.
  • datetime: Represents the type of data a user or system input can accept within the DSL.
  • file: Represents the type of data a user or system input can accept within the DSL.
  • float: Represents the type of data a user or system input can accept within the DSL.
  • image: Represents the type of data a user or system input can accept within the DSL.
  • int: Represents the type of data a user or system input can accept within the DSL.
  • name: The name of the Enum member.
  • text: Represents the type of data a user or system input can accept within the DSL.
  • thinking: Represents the type of data a user or system input can accept within the DSL.
  • time: Represents the type of data a user or system input can accept within the DSL.
  • value: The value of the Enum member.
  • video: Represents the type of data a user or system input can accept within the DSL.

Domain Specific Types

Domain specific types are included for common use cases (chat bots, RAG, etc)

ChatMessage

A standard, built-in representation of a chat message.

  • role (MessageRole): The role of the message sender (e.g., 'user', 'assistant').
  • blocks (list[ChatContent]): The content blocks of the chat message, which can include text, images, or other media.

ChatContent

No documentation available.

  • type (PrimitiveTypeEnum): The type of content, such as 'text', 'image', etc.
  • content (Any): The actual content, which can be a string, image data, etc.
  • mime_type (str | None): The MIME type of the content, if known.

Embedding

A standard, built-in representation of a vector embedding.

  • vector (list[float]): The vector representation of the embedding.
  • content (Any | None): The original content that was embedded.
  • metadata (dict[str, Any]): Metadata associated with the embedding.