Skip to main content

Attributes

The Chat system is configured through the Chat class, which provides the following attributes:
AttributeTypeDefaultDescription
session_idstr(required)Unique identifier for this chat session
user_idstr(required)Unique identifier for the user
agentAgent(required)The Agent instance to handle conversations
storageStorage | NoneNoneStorage backend (defaults to InMemoryStorage)
full_session_memoryboolTrueEnable full conversation history storage
summary_memoryboolFalseEnable conversation summarization
user_analysis_memoryboolFalseEnable user profile analysis
user_profile_schematype | NoneNoneCustom user profile schema
dynamic_user_profileboolFalseEnable dynamic profile schema generation
num_last_messagesint | NoneNoneLimit conversation history to last N messages
feed_tool_call_resultsboolFalseInclude tool calls in memory
user_memory_modeLiteral['update', 'replace']'update'How to update user profiles
debugboolFalseEnable debug logging
max_concurrent_invocationsint1Maximum concurrent invoke calls
retry_attemptsint3Number of retry attempts for failed calls
retry_delayfloat1.0Delay between retry attempts

Configuration Example

from upsonic import Agent, Task, Chat
from upsonic.storage.providers import SqliteStorage

# Setup storage
storage = SqliteStorage("sessions", "profiles", "chat.db")

# Create agent
agent = Agent("openai/gpt-4o")

# Create chat with configuration
chat = Chat(
    session_id="session1",
    user_id="user1",
    agent=agent,
    storage=storage,
    full_session_memory=True,
    summary_memory=True,
    user_analysis_memory=True,
    num_last_messages=50,
    retry_attempts=3,
    retry_delay=1.0
)

# Use chat
response = await chat.invoke("Hello!")
print(response)