File size: 3,349 Bytes
5374a2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from enum import Enum
from typing import List, Optional, Dict, Any

from pydantic import BaseModel, Field


class TableType(str, Enum):
    """
    Enum representing the default table types for the database.
    Each value corresponds to a specific table name used for storing different types of data.
    """
    store_agent = "agent"      # Table for agent data
    store_workflow = "workflow" # Table for workflow data
    store_memory = "memory"    # Table for memory data
    store_history = "history"  # Table for history data
    store_indexing = "indexing"   # Table for indexing data


class MemoryStore(BaseModel):
    """
    Stores memory-related metadata with optional fields for keywords, entities, and embeddings.
    """
    memory_id: str = Field(..., description="Unique identifier for the memory")      
    content: str = Field(..., description="Main content of the memory")
    date: str = Field(..., description="Date associated with the memory")
    key_words: Optional[List] = Field([], description="Optional list of keywords associated with the memory")
    entity_content: Optional[Dict[str, Any]] = Field({}, description="Optional dictionary of entity-related content")
    embedding: Optional[List] = Field([], description="Optional list of embedding vectors")

# Pydantic model for workflow data storage
class WorkflowStore(BaseModel):
    """
    Stores workflow metadata with a unique name and content dictionary.
    """
    name: str = Field(..., description="Unique workflow identifier")
    content: Dict[str, Any] = Field(..., description="Dictionary containing workflow details") 
    date: Optional[str] = Field("", description="Date associated with the workflow") 

# Pydantic model for agent data storage
class AgentStore(BaseModel):
    """
    Stores agent metadata with a unique name and content dictionary.
    """
    name: str = Field(..., description="Unique agent identifier")
    content: Dict[str, Any] = Field(..., description="Dictionary containing agent details")
    date: Optional[str] = Field("", description="Date associated with the agent")

# Pydantic model for history data storage
class HistoryStore(BaseModel):
    """
    Stores changes to memory with event details and timestamps.
    """
    memory_id: str = Field(..., description="Identifier of the memory being modified")
    old_memory: str = Field(..., description="Original memory content before change")
    new_memory: str = Field(..., description="Updated memory content after change")
    event: str = Field(..., description="Description of the event causing the change")
    created_at: Optional[str] = Field("", description="Optional timestamp for creation")
    updated_at: Optional[str] = Field("", description="Optional timestamp for last update")

# Pydantic model for index data storage
class IndexStore(BaseModel):
    """
    Stores indexing metadata with a unique id and basic chunk/node attribute.
    """
    corpus_id: str = Field(..., description="Identifier for the associated corpus")
    content: Dict[str, Any] = Field(..., description="Serialized index content (e.g., LlamaIndex JSON)")
    date: Optional[str] = Field(default="", description="Creation or last update date")
    metadata: Dict[str, Any] = Field(default_factory=dict, description="Additional metadata, e.g., vector store collection name")