Docs /Templates/ sinapsis-chat-history

ChatHistoryFetch

sinapsis-chat-historyChat Historychatbotschat_historycontext

Python template · sinapsis_chat_history.templates.chat_history_fetch

Overview

Template for loading chat history messages from a storage backend.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-chat-history==1.0.0
uv pip install sinapsis-chat-history==1.0.0
uv add sinapsis-chat-history==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
provider
typing.Literal['postgres', 'sqlite', 'supabase']
Optional
Default: "sqlite"
db_config
dict[str, typing.Any]
Optional
Default: null
fetch_args

Query options used when loading chat history messages.

ChatHistoryFetchArgs
Optional
Default: null
limit

Maximum number of messages to fetch. Use `-1` to fetch all matching messages.

int
Optional
Default: 100
order

Sort direction for the returned messages.

typing.Literal['asc', 'desc']
Optional
Default: "asc"
offset

Number of matching messages to skip before returning results.

int
Optional
Default: 0
filters

Optional message-level filters applied in addition to packet identity scope.

ChatHistoryFilters
Optional
Default: null
id
str | None
Optional
Default: null
role
typing.Optional[typing.Literal['system', 'user', 'assistant', 'tool', 'developer']]
Optional
Default: null
content
str | None
Optional
Default: null
order_by

Field used to order the returned messages.

typing.Literal['created_at', 'id']
Optional
Default: "created_at"

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: ChatHistoryFetch
  class_name: ChatHistoryFetch
  template_input: InputTemplate
  attributes:
    provider: sqlite
    db_config:
      db_path: "chat_history.sqlite3"
      table: "chat"
    fetch_args:
      limit: 10
      offset: 0
      order: asc
      order_by: created_at
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "ChatHistoryFetch"
    class_name: "ChatHistoryFetch"
    attributes:
      provider: "sqlite"
      db_config: null
      fetch_args:
        limit: 100
        order: "asc"
        offset: 0
        filters:
          id: null
          role: null
          content: null
        order_by: "created_at"

Inheritance

Immediate parent: sinapsis_chat_history.templates.chat_history_base.ChatHistoryBase

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.