39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
import os
|
|
from typing import Any, Dict, Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
from mem0.memory.setup import mem0_dir
|
|
from mem0.vector_stores.configs import VectorStoreConfig
|
|
from mem0.llms.configs import LlmConfig
|
|
from mem0.embeddings.configs import EmbedderConfig
|
|
|
|
class MemoryItem(BaseModel):
|
|
id: str = Field(..., description="The unique identifier for the text data")
|
|
memory: str = Field(..., description="The memory deduced from the text data") # TODO After prompt changes from platform, update this
|
|
hash: Optional[str] = Field(None, description="The hash of the memory")
|
|
# The metadata value can be anything and not just string. Fix it
|
|
metadata: Optional[Dict[str, Any]] = Field(None, description="Additional metadata for the text data")
|
|
score: Optional[float] = Field(
|
|
None, description="The score associated with the text data"
|
|
)
|
|
created_at: Optional[str] = Field(None, description="The timestamp when the memory was created")
|
|
updated_at: Optional[str] = Field(None, description="The timestamp when the memory was updated")
|
|
|
|
|
|
class MemoryConfig(BaseModel):
|
|
vector_store: VectorStoreConfig = Field(
|
|
description="Configuration for the vector store",
|
|
default_factory=VectorStoreConfig,
|
|
)
|
|
llm: LlmConfig = Field(
|
|
description="Configuration for the language model",
|
|
default_factory=LlmConfig,
|
|
)
|
|
embedder: EmbedderConfig = Field(
|
|
description="Configuration for the embedding model",
|
|
default_factory=EmbedderConfig,
|
|
)
|
|
history_db_path: str = Field(
|
|
description="Path to the history database",
|
|
default=os.path.join(mem0_dir, "history.db"),
|
|
) |