Skip to content

init

Schemas related to controlling the behaviour of the application (i.e. all the settings etc in the right sidebar).

These are used by the frontend for display (and maybe some validation of values), and by the backend to actually use the values in related business logic

__all__ = ['AgentSchema', 'AssistantSchema', 'CondenseSettingsSchema', 'ConfigID', 'ConfigMetadataSchema', 'ConfigSchemaBase', 'ConfigType', 'ContextSettingsSchema', 'ExampleConfigSchema', 'LLMModels', 'LLMSettingsSchema', 'LanggraphSettingsSchema', 'OptionsSchema', 'PersonalitySettingsSchema'] module-attribute

AgentSchema

Bases: ConfigSchemaBase

agent_type = Field(default='basic', description='For differentiating structurally different Agents (e.g. different prompt structures)') class-attribute instance-attribute

options = OptionsSchema() class-attribute instance-attribute

sub_assistants = Field(default_factory=list) class-attribute instance-attribute

tools = Field(default_factory=list) class-attribute instance-attribute

AssistantSchema

Bases: ConfigSchemaBase

agent = AgentSchema() class-attribute instance-attribute

as_tool_description = None class-attribute instance-attribute

langgraph_settings = LanggraphSettingsSchema() class-attribute instance-attribute

CondenseSettingsSchema

Bases: ConfigSchemaBase

max_additional_instructions = 1000 class-attribute instance-attribute

max_additional_system_prompt = 500 class-attribute instance-attribute

max_context = 2000 class-attribute instance-attribute

max_intermediate_steps = 1000 class-attribute instance-attribute

max_previous_messages = 1000 class-attribute instance-attribute

max_summary = 1000 class-attribute instance-attribute

max_total = 8000 class-attribute instance-attribute

max_user_input = 1000 class-attribute instance-attribute

non_total_components = {'max_additional_system_prompt', 'max_context', 'max_summary', 'max_previous_messages', 'max_user_input', 'max_additional_instructions', 'max_intermediate_steps'} class-attribute

total_components property

validate_against_max()

Each component should be set less than the max total.

Note: The individual components do not need to sum to less than the max total. This allows for more flexibility in how the full context length is used.

ConfigID

Bases: UniqueIDBase[ConfigSchemaBase]

name instance-attribute

schema_class instance-attribute

type_ instance-attribute

user_id = None class-attribute instance-attribute

__hash__()

__repr__()

copy_without_version()

equal_excluding_version_and_deletion(other)

from_meta(meta, schema_class, version, deleted) classmethod

from_schema(schema, exact_version=False) classmethod

ConfigMetadataSchema

Bases: SchemaBase

copied_from_name = Field(default=None, max_length=100) class-attribute instance-attribute

copied_from_type = None class-attribute instance-attribute

name = Field(default='Default', max_length=100) class-attribute instance-attribute

type = ConfigType.NOT_SET class-attribute instance-attribute

user_id = Field(exclude=False, description='User ID is only relevant when type is USER, and is determined by the users login. Should not be exposed to the client, call .set_meta(user_id=None, nested=True) to remove.', default=None) class-attribute instance-attribute

equal_to(other, keys_to_recursively_remove=None, exclude_id=False, include_version=False, exclude_copied_from=False)

For more complex comparisons where schema1 == schema2 is not sufficient.

E.g. Trying to compare all values without metadatas or ids.

new_copy(new_name, new_type, new_user_id)

set(name=None, type_=None, user_id=None, copied_from_name=None, copied_from_type=None, as_new=False)

validate_copied_combination()

validate_copied_from_type(v)

validate_name(v)

validate_type_user_id_combination(info)

ConfigSchemaBase

Bases: DatabaseSchemaMixin, SchemaBase, ABC

Base class for all configs schemas.

meta = ConfigMetadataSchema() class-attribute instance-attribute

model_config = ConfigDict(extra='forbid') class-attribute instance-attribute

new_instance_on_change = True class-attribute

Should a whole new instance be created in the database for any change (version increment) vs changing in place.

determine_version_increment(other)

equal_to(other, keys_to_remove_recursively=None, exclude_metas=False, exclude_id=True, include_version=False)

For more complex comparisons where schema1 == schema2 is not sufficient.

E.g. Trying to compare all values without metadatas or ids.

increment_version()

mark_deleted(nested=False)

new_copy(new_name, new_type=None, new_user_id=None, nested=False)

Create a copy of the schema (resetting version and id).

PARAMETER DESCRIPTION
new_name

New name for the schema

TYPE: str

new_type

New type for the schema

TYPE: ConfigType | None DEFAULT: None

new_user_id

New user_id for the schema

TYPE: int | None DEFAULT: None

nested

Whether to also create new copies of all sub-schemas

TYPE: bool DEFAULT: False

Note: Replacing all nested schemas ensures that any future updates are not ambiguous as to which schema they are intended to update. Useful when sub-schemas are ONLY considered part of the parent schema.

reset_ids(nested=False)

Set all ids to None.

Remove all persistence ids.

reset_incremented_for_testing()

reset_version(nested)

Set all versions to None.

set_ids_from_model(model)

Set the ID and version from a model instance.

Used when creating a new schema from a model instance. Only used in repository/uow methods.

set_initial_version()

set_meta(name=None, type_=None, user_id=None, copied_from_name=None, copied_from_type=None, meta=None, nested=False, as_new=False, condition=None)

Update the metadata on the schema (and all nested schemas if nested is True).


name: Optional new name to set
type_: Optional new type to set
user_id: Optional new user_id to set
copied_from_name: Optional new copied_from_name to set
copied_from_type: Optional new copied_from_type to set
version: Optional new version to set
meta: Optional new full meta to set
nested: Whether to apply update to nested schemas
as_new: If true, resets version and id (and automatically copies from current)
condition: Callable to determine whether to apply the update to the schema (receives the schema as arg)

sub_schemas()

tablename() classmethod

ConfigType

Bases: StrEnum

GLOBAL = 'global' class-attribute instance-attribute

IMMUTABLE = 'immutable' class-attribute instance-attribute

NOT_SET = 'not_set' class-attribute instance-attribute

USER = 'user' class-attribute instance-attribute

ContextSettingsSchema

Bases: ConfigSchemaBase

num_user_messages = 5 class-attribute instance-attribute

search_user_messages = False class-attribute instance-attribute

ExampleConfigSchema

Bases: ConfigSchemaBase

value = 'Example Control Group value' class-attribute instance-attribute

LLMModels

Bases: SimpleNamespace

anthropic = AnthropicModels class-attribute instance-attribute

fake = FakeModels class-attribute instance-attribute

openai = OpenaiModels class-attribute instance-attribute

LLMSettingsSchema

Bases: ConfigSchemaBase

max_tokens = Field(default=1000, description='Max tokens for response if supported') class-attribute instance-attribute

model = LLMModels.openai.gpt4o_mini class-attribute instance-attribute

provider = LLMProviders.OPENAI class-attribute instance-attribute

temperature = 0.5 class-attribute instance-attribute

LanggraphSettingsSchema

Bases: ConfigSchemaBase

max_steps = 5 class-attribute instance-attribute

OptionsSchema

Bases: ConfigSchemaBase

Schema for storing all option values in control panel.

condense_settings = CondenseSettingsSchema() class-attribute instance-attribute

context_settings = ContextSettingsSchema() class-attribute instance-attribute

llm_settings = LLMSettingsSchema() class-attribute instance-attribute

personality_settings = PersonalitySettingsSchema() class-attribute instance-attribute

PersonalitySettingsSchema

Bases: ConfigSchemaBase

additional_instructions_prompt = '' class-attribute instance-attribute

additional_system_prompt = '' class-attribute instance-attribute