Skip to content

storage

Class info

Classes

Name Children Inherits
BaseStorageProviderConfig
llmling_agent.models.storage
FileStorageConfig
llmling_agent.models.storage
File storage configuration.
    Mem0Config
    llmling_agent.models.storage
    Configuration for mem0 storage.
      MemoryStorageConfig
      llmling_agent.models.storage
      In-memory storage configuration for testing.
        SQLStorageConfig
        llmling_agent.models.storage
        SQL database storage configuration.
          StorageConfig
          llmling_agent.models.storage
          Global storage configuration.
            TextLogConfig
            llmling_agent.models.storage
            Text log configuration.

              🛈 DocStrings

              BaseStorageProviderConfig

              Bases: BaseModel

              Source code in src/llmling_agent/models/storage.py
              26
              27
              28
              29
              30
              31
              32
              33
              34
              35
              36
              37
              38
              39
              40
              41
              42
              43
              44
              45
              46
              47
              class BaseStorageProviderConfig(BaseModel):
                  type: str = Field(init=False)
              
                  log_messages: bool = True
                  """Whether to log messages"""
              
                  agents: set[str] | None = None
                  """Optional set of agent names to include. If None, logs all agents."""
              
                  log_conversations: bool = True
                  """Whether to log conversations"""
              
                  log_tool_calls: bool = True
                  """Whether to log tool calls"""
              
                  log_commands: bool = True
                  """Whether to log command executions"""
              
                  log_context: bool = True
                  """Whether to log context messages."""
              
                  model_config = ConfigDict(frozen=True, use_attribute_docstrings=True, extra="forbid")
              

              agents class-attribute instance-attribute

              agents: set[str] | None = None
              

              Optional set of agent names to include. If None, logs all agents.

              log_commands class-attribute instance-attribute

              log_commands: bool = True
              

              Whether to log command executions

              log_context class-attribute instance-attribute

              log_context: bool = True
              

              Whether to log context messages.

              log_conversations class-attribute instance-attribute

              log_conversations: bool = True
              

              Whether to log conversations

              log_messages class-attribute instance-attribute

              log_messages: bool = True
              

              Whether to log messages

              log_tool_calls class-attribute instance-attribute

              log_tool_calls: bool = True
              

              Whether to log tool calls

              FileStorageConfig

              Bases: BaseStorageProviderConfig

              File storage configuration.

              Source code in src/llmling_agent/models/storage.py
              84
              85
              86
              87
              88
              89
              90
              91
              92
              93
              94
              95
              96
              class FileStorageConfig(BaseStorageProviderConfig):
                  """File storage configuration."""
              
                  type: Literal["file"] = Field("file", init=False)
              
                  path: str
                  """Path to storage file (extension determines format unless specified)"""
              
                  format: FormatType = "auto"
                  """Storage format (auto=detect from extension)"""
              
                  encoding: str = "utf-8"
                  """File encoding"""
              

              encoding class-attribute instance-attribute

              encoding: str = 'utf-8'
              

              File encoding

              format class-attribute instance-attribute

              format: FormatType = 'auto'
              

              Storage format (auto=detect from extension)

              path instance-attribute

              path: str
              

              Path to storage file (extension determines format unless specified)

              Mem0Config

              Bases: BaseStorageProviderConfig

              Configuration for mem0 storage.

              Source code in src/llmling_agent/models/storage.py
              105
              106
              107
              108
              109
              110
              111
              112
              113
              114
              115
              116
              117
              118
              class Mem0Config(BaseStorageProviderConfig):
                  """Configuration for mem0 storage."""
              
                  type: Literal["mem0"] = Field("mem0", init=False)
                  """Type discriminator for storage config."""
              
                  api_key: SecretStr | None = None
                  """API key for mem0 service."""
              
                  page_size: int = 100
                  """Number of results per page when retrieving paginated data."""
              
                  output_format: Literal["v1.0", "v1.1"] = "v1.1"
                  """API output format version. 1.1 is recommended and provides enhanced details."""
              

              api_key class-attribute instance-attribute

              api_key: SecretStr | None = None
              

              API key for mem0 service.

              output_format class-attribute instance-attribute

              output_format: Literal['v1.0', 'v1.1'] = 'v1.1'
              

              API output format version. 1.1 is recommended and provides enhanced details.

              page_size class-attribute instance-attribute

              page_size: int = 100
              

              Number of results per page when retrieving paginated data.

              type class-attribute instance-attribute

              type: Literal['mem0'] = Field('mem0', init=False)
              

              Type discriminator for storage config.

              MemoryStorageConfig

              Bases: BaseStorageProviderConfig

              In-memory storage configuration for testing.

              Source code in src/llmling_agent/models/storage.py
               99
              100
              101
              102
              class MemoryStorageConfig(BaseStorageProviderConfig):
                  """In-memory storage configuration for testing."""
              
                  type: Literal["memory"] = Field("memory", init=False)
              

              SQLStorageConfig

              Bases: BaseStorageProviderConfig

              SQL database storage configuration.

              Source code in src/llmling_agent/models/storage.py
              50
              51
              52
              53
              54
              55
              56
              57
              58
              59
              60
              61
              62
              class SQLStorageConfig(BaseStorageProviderConfig):
                  """SQL database storage configuration."""
              
                  type: Literal["sql"] = Field("sql", init=False)
              
                  url: str = Field(default_factory=get_database_path)
                  """Database URL (e.g. sqlite:///history.db)"""
              
                  pool_size: int = 5
                  """Connection pool size"""
              
                  auto_migration: bool = True
                  """Whether to automatically add missing columns"""
              

              auto_migration class-attribute instance-attribute

              auto_migration: bool = True
              

              Whether to automatically add missing columns

              pool_size class-attribute instance-attribute

              pool_size: int = 5
              

              Connection pool size

              url class-attribute instance-attribute

              url: str = Field(default_factory=get_database_path)
              

              Database URL (e.g. sqlite:///history.db)

              StorageConfig

              Bases: BaseModel

              Global storage configuration.

              Source code in src/llmling_agent/models/storage.py
              131
              132
              133
              134
              135
              136
              137
              138
              139
              140
              141
              142
              143
              144
              145
              146
              147
              148
              149
              150
              151
              152
              153
              154
              155
              156
              157
              158
              159
              160
              161
              162
              163
              164
              165
              166
              167
              168
              169
              170
              171
              172
              173
              174
              175
              176
              177
              178
              179
              class StorageConfig(BaseModel):
                  """Global storage configuration."""
              
                  providers: list[StorageProviderConfig] | None = None
                  """List of configured storage providers"""
              
                  default_provider: str | None = None
                  """Name of default provider for history queries.
                  If None, uses first configured provider."""
              
                  agents: set[str] | None = None
                  """Global agent filter. Can be overridden by provider-specific filters."""
              
                  filter_mode: FilterMode = "and"
                  """How to combine global and provider agent filters:
                  - "and": Both global and provider filters must allow the agent
                  - "override": Provider filter overrides global filter if set
                  """
              
                  log_messages: bool = True
                  """Whether to log messages."""
              
                  log_conversations: bool = True
                  """Whether to log conversations."""
              
                  log_tool_calls: bool = True
                  """Whether to log tool calls."""
              
                  log_commands: bool = True
                  """Whether to log command executions."""
              
                  log_context: bool = True
                  """Whether to log additions to the context."""
              
                  model_config = ConfigDict(frozen=True, use_attribute_docstrings=True, extra="forbid")
              
                  @property
                  def effective_providers(self) -> list[StorageProviderConfig]:
                      """Get effective list of providers.
              
                      Returns:
                          - Default SQLite provider if providers is None
                          - Empty list if providers is empty list
                          - Configured providers otherwise
                      """
                      if self.providers is None:
                          cfg = SQLStorageConfig()
                          return [cfg]
                      return self.providers
              

              agents class-attribute instance-attribute

              agents: set[str] | None = None
              

              Global agent filter. Can be overridden by provider-specific filters.

              default_provider class-attribute instance-attribute

              default_provider: str | None = None
              

              Name of default provider for history queries. If None, uses first configured provider.

              effective_providers property

              effective_providers: list[StorageProviderConfig]
              

              Get effective list of providers.

              Returns:

              Type Description
              list[StorageProviderConfig]
              • Default SQLite provider if providers is None
              list[StorageProviderConfig]
              • Empty list if providers is empty list
              list[StorageProviderConfig]
              • Configured providers otherwise

              filter_mode class-attribute instance-attribute

              filter_mode: FilterMode = 'and'
              

              How to combine global and provider agent filters: - "and": Both global and provider filters must allow the agent - "override": Provider filter overrides global filter if set

              log_commands class-attribute instance-attribute

              log_commands: bool = True
              

              Whether to log command executions.

              log_context class-attribute instance-attribute

              log_context: bool = True
              

              Whether to log additions to the context.

              log_conversations class-attribute instance-attribute

              log_conversations: bool = True
              

              Whether to log conversations.

              log_messages class-attribute instance-attribute

              log_messages: bool = True
              

              Whether to log messages.

              log_tool_calls class-attribute instance-attribute

              log_tool_calls: bool = True
              

              Whether to log tool calls.

              providers class-attribute instance-attribute

              providers: list[StorageProviderConfig] | None = None
              

              List of configured storage providers

              TextLogConfig

              Bases: BaseStorageProviderConfig

              Text log configuration.

              Source code in src/llmling_agent/models/storage.py
              65
              66
              67
              68
              69
              70
              71
              72
              73
              74
              75
              76
              77
              78
              79
              80
              class TextLogConfig(BaseStorageProviderConfig):
                  """Text log configuration."""
              
                  type: Literal["text_file"] = Field("text_file", init=False)
              
                  path: str
                  """Path to log file"""
              
                  format: LogFormat = "chronological"
                  """Log format template to use"""
              
                  template: Literal["chronological", "conversations"] | str | None = "chronological"  # noqa: PYI051
                  """Template to use: either predefined name or path to custom template"""
              
                  encoding: str = "utf-8"
                  """File encoding"""
              

              encoding class-attribute instance-attribute

              encoding: str = 'utf-8'
              

              File encoding

              format class-attribute instance-attribute

              format: LogFormat = 'chronological'
              

              Log format template to use

              path instance-attribute

              path: str
              

              Path to log file

              template class-attribute instance-attribute

              template: Literal['chronological', 'conversations'] | str | None = 'chronological'
              

              Template to use: either predefined name or path to custom template

              get_database_path

              get_database_path() -> str
              

              Get the database file path, creating directories if needed.

              Source code in src/llmling_agent/models/storage.py
              19
              20
              21
              22
              23
              def get_database_path() -> str:
                  """Get the database file path, creating directories if needed."""
                  db_path = DATA_DIR / DEFAULT_DB_NAME
                  db_path.parent.mkdir(parents=True, exist_ok=True)
                  return f"sqlite:///{db_path}"