Function Signature
Import
Parameters
Database name for storage. Pass
None for in-memory storage that doesn’t persist when the process exits, or a file path (e.g., "chat.db") for persistent SQLite storage.Example: "my_conversation.db" or NoneThe type of messages this conversation will contain. Typically
ConversationMessage or TranscriptMessage.Example: ConversationMessageOptional name for the conversation, used in diagnostics and metadata.Example:
"customer_support_chat"Optional list of tags for the entire conversation. These are different from per-message tags and apply to the conversation metadata.Example:
["support", "product_feedback"]Optional conversation settings that control knowledge extraction and indexing behavior. If
None, creates default settings with knowledge extraction enabled.See ConversationSettings for configuration options.Optional dictionary of custom metadata key-value pairs to attach to the conversation.Example:
{"user_id": "12345", "session_id": "abc"}Returns
A fully initialized conversation ready to accept messages. The conversation includes:
- Message and semantic reference collections
- All 6 index types (semantic refs, properties, timestamps, message text, related terms, threads)
- Configured knowledge extraction pipeline
Behavior
Default Knowledge Extraction
Whensettings is None, the factory automatically creates settings with knowledge extraction enabled by default:
Storage Provider Initialization
The function automatically creates the appropriate storage provider:- SQLite when
dbnameis a file path - In-memory when
dbnameisNone
Index Creation
All 6 secondary indexes are created and initialized:- Semantic reference index - term to knowledge mappings
- Property index - fast name/value property lookups
- Timestamp index - date range queries
- Message text index - semantic search over message content
- Related terms index - term synonyms and fuzzy matching
- Conversation threads - thread descriptions and groupings
Examples
Basic In-Memory Conversation
Persistent Conversation with Custom Settings
Transcript Processing
Error Handling
Related
- ConversationBase - The returned conversation object
- ConversationSettings - Configuration options
- ConversationMessage - Message types
- Environment Variables - API key configuration