memoryscope.scheme

pydantic model memoryscope.scheme.MemoryNode[源代码]

基类:BaseModel

Represents a memory node with comprehensive attributes to store memory information including unique ID, user details, content, metadata, scoring metrics. Automatically handles timestamp conversion to date format during initialization.

Show JSON schema
{
   "title": "MemoryNode",
   "description": "Represents a memory node with comprehensive attributes to store memory information including unique ID,\nuser details, content, metadata, scoring metrics.\nAutomatically handles timestamp conversion to date format during initialization.",
   "type": "object",
   "properties": {
      "memory_id": {
         "description": "unique id for memory",
         "title": "Memory Id",
         "type": "string"
      },
      "user_name": {
         "default": "",
         "description": "the user who owns the memory",
         "title": "User Name",
         "type": "string"
      },
      "target_name": {
         "default": "",
         "description": "target name described by the memory",
         "title": "Target Name",
         "type": "string"
      },
      "meta_data": {
         "additionalProperties": {
            "type": "string"
         },
         "default": {},
         "description": "meta data infos",
         "title": "Meta Data",
         "type": "object"
      },
      "content": {
         "default": "",
         "description": "memory content",
         "title": "Content",
         "type": "string"
      },
      "key": {
         "default": "",
         "description": "memory key",
         "title": "Key",
         "type": "string"
      },
      "key_vector": {
         "default": [],
         "description": "memory key embedding result",
         "items": {
            "type": "number"
         },
         "title": "Key Vector",
         "type": "array"
      },
      "value": {
         "default": "",
         "description": "memory value",
         "title": "Value",
         "type": "string"
      },
      "score_recall": {
         "default": 0,
         "description": "embedding similarity score used in recall stage",
         "title": "Score Recall",
         "type": "number"
      },
      "score_rank": {
         "default": 0,
         "description": "rank model score used in rank stage",
         "title": "Score Rank",
         "type": "number"
      },
      "score_rerank": {
         "default": 0,
         "description": "rerank score used in rerank stage",
         "title": "Score Rerank",
         "type": "number"
      },
      "memory_type": {
         "default": "",
         "description": "conversation / observation / insight...",
         "title": "Memory Type",
         "type": "string"
      },
      "action_status": {
         "default": "none",
         "description": "new / content_modified / modified / deleted / none",
         "title": "Action Status",
         "type": "string"
      },
      "store_status": {
         "default": "valid",
         "description": "store_status: valid / expired",
         "title": "Store Status",
         "type": "string"
      },
      "vector": {
         "default": [],
         "description": "content embedding result",
         "items": {
            "type": "number"
         },
         "title": "Vector",
         "type": "array"
      },
      "timestamp": {
         "description": "timestamp of the memory node",
         "title": "Timestamp",
         "type": "integer"
      },
      "dt": {
         "default": "",
         "description": "dt of the memory node",
         "title": "Dt",
         "type": "string"
      },
      "obs_reflected": {
         "default": 0,
         "description": "if the observation is reflected: 0/1",
         "title": "Obs Reflected",
         "type": "integer"
      },
      "obs_updated": {
         "default": 0,
         "description": "if the observation has updated user profile or insight: 0/1",
         "title": "Obs Updated",
         "type": "integer"
      }
   }
}

Fields:
field memory_id: str [Optional]

unique id for memory

field user_name: str = ''

the user who owns the memory

field target_name: str = ''

target name described by the memory

field meta_data: Dict[str, str] = {}

meta data infos

field content: str = ''

memory content

field key: str = ''

memory key

field key_vector: List[float] = []

memory key embedding result

field value: str = ''

memory value

field score_recall: float = 0

embedding similarity score used in recall stage

field score_rank: float = 0

rank model score used in rank stage

field score_rerank: float = 0

rerank score used in rerank stage

field memory_type: str = ''

conversation / observation / insight...

field action_status: str = 'none'

new / content_modified / modified / deleted / none

field store_status: str = 'valid'

store_status: valid / expired

field vector: List[float] = []

content embedding result

field timestamp: int [Optional]

timestamp of the memory node

field obs_reflected: int = 0

if the observation is reflected: 0/1

field obs_updated: int = 0

if the observation has updated user profile or insight: 0/1

__init__(**kwargs)[源代码]

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

field dt: str = ''

dt of the memory node

property node_keys
pydantic model memoryscope.scheme.Message[源代码]

基类:BaseModel

Represents a structured message object with details about the sender, content, and metadata.

role

The role of the message sender (e.g., 'user', 'assistant', 'system').

Type:

str

role_name

Optional name associated with the role of the message sender.

Type:

str

content

The actual content or text of the message.

Type:

str

time_created

Timestamp indicating when the message was created.

Type:

int

memorized

Flag to indicate if the message has been saved or remembered.

Type:

bool

meta_data

Additional data or context attached to the message.

Type:

Dict[str, str]

Show JSON schema
{
   "title": "Message",
   "description": "Represents a structured message object with details about the sender, content, and metadata.\n\nAttributes:\n    role (str): The role of the message sender (e.g., 'user', 'assistant', 'system').\n    role_name (str): Optional name associated with the role of the message sender.\n    content (str): The actual content or text of the message.\n    time_created (int): Timestamp indicating when the message was created.\n    memorized (bool): Flag to indicate if the message has been saved or remembered.\n    meta_data (Dict[str, str]): Additional data or context attached to the message.",
   "type": "object",
   "properties": {
      "role": {
         "description": "The role of the message sender (user, assistant, system)",
         "title": "Role",
         "type": "string"
      },
      "role_name": {
         "default": "",
         "description": "Name describing the role of the message sender",
         "title": "Role Name",
         "type": "string"
      },
      "content": {
         "description": "The primary content of the message",
         "title": "Content",
         "type": "string"
      },
      "time_created": {
         "description": "Timestamp marking the message creation time",
         "title": "Time Created",
         "type": "integer"
      },
      "memorized": {
         "default": false,
         "description": "Indicates if the message is flagged for memory retention",
         "title": "Memorized",
         "type": "boolean"
      },
      "meta_data": {
         "additionalProperties": {
            "type": "string"
         },
         "default": {},
         "description": "Supplementary data attached to the message",
         "title": "Meta Data",
         "type": "object"
      }
   },
   "required": [
      "role",
      "content"
   ]
}

Fields:
field role: str [Required]

The role of the message sender (user, assistant, system)

field role_name: str = ''

Name describing the role of the message sender

field content: str [Required]

The primary content of the message

field time_created: int [Optional]

Timestamp marking the message creation time

field memorized: bool = False

Indicates if the message is flagged for memory retention

field meta_data: Dict[str, str] = {}

Supplementary data attached to the message

pydantic model memoryscope.scheme.ModelResponse[源代码]

基类:BaseModel

Show JSON schema
{
   "title": "ModelResponse",
   "type": "object",
   "properties": {
      "message": {
         "anyOf": [
            {
               "$ref": "#/$defs/Message"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "generation model result"
      },
      "delta": {
         "default": "",
         "description": "New text that just streamed in (only used when streaming)",
         "title": "Delta",
         "type": "string"
      },
      "embedding_results": {
         "anyOf": [
            {
               "items": {
                  "items": {
                     "type": "number"
                  },
                  "type": "array"
               },
               "type": "array"
            },
            {
               "items": {
                  "type": "number"
               },
               "type": "array"
            }
         ],
         "default": [],
         "description": "embedding vector",
         "title": "Embedding Results"
      },
      "rank_scores": {
         "additionalProperties": {
            "type": "number"
         },
         "default": {},
         "description": "The rank scores of each documents. key: index, value: rank score",
         "title": "Rank Scores",
         "type": "object"
      },
      "m_type": {
         "$ref": "#/$defs/ModelEnum",
         "default": "generation_model",
         "description": "One of LLM, EMB, RANK."
      },
      "status": {
         "default": true,
         "description": "Indicates whether the model call was successful.",
         "title": "Status",
         "type": "boolean"
      },
      "details": {
         "default": "",
         "description": "The details information for model call, usually for storage of raw response or failure messages.",
         "title": "Details",
         "type": "string"
      },
      "raw": {
         "default": "",
         "description": "Raw response from model call",
         "title": "Raw"
      },
      "meta_data": {
         "default": {},
         "description": "meta data for model response",
         "title": "Meta Data",
         "type": "object"
      }
   },
   "$defs": {
      "Message": {
         "description": "Represents a structured message object with details about the sender, content, and metadata.\n\nAttributes:\n    role (str): The role of the message sender (e.g., 'user', 'assistant', 'system').\n    role_name (str): Optional name associated with the role of the message sender.\n    content (str): The actual content or text of the message.\n    time_created (int): Timestamp indicating when the message was created.\n    memorized (bool): Flag to indicate if the message has been saved or remembered.\n    meta_data (Dict[str, str]): Additional data or context attached to the message.",
         "properties": {
            "role": {
               "description": "The role of the message sender (user, assistant, system)",
               "title": "Role",
               "type": "string"
            },
            "role_name": {
               "default": "",
               "description": "Name describing the role of the message sender",
               "title": "Role Name",
               "type": "string"
            },
            "content": {
               "description": "The primary content of the message",
               "title": "Content",
               "type": "string"
            },
            "time_created": {
               "description": "Timestamp marking the message creation time",
               "title": "Time Created",
               "type": "integer"
            },
            "memorized": {
               "default": false,
               "description": "Indicates if the message is flagged for memory retention",
               "title": "Memorized",
               "type": "boolean"
            },
            "meta_data": {
               "additionalProperties": {
                  "type": "string"
               },
               "default": {},
               "description": "Supplementary data attached to the message",
               "title": "Meta Data",
               "type": "object"
            }
         },
         "required": [
            "role",
            "content"
         ],
         "title": "Message",
         "type": "object"
      },
      "ModelEnum": {
         "description": "An enumeration representing different types of models used within the system.\n\nMembers:\n    GENERATION_MODEL: Represents a model responsible for generating content.\n    EMBEDDING_MODEL: Represents a model tasked with creating embeddings, typically used for transforming data into a\n        numerical form suitable for machine learning tasks.\n    RANK_MODEL: Denotes a model that specializes in ranking, often used to order items based on relevance.",
         "enum": [
            "generation_model",
            "embedding_model",
            "rank_model"
         ],
         "title": "ModelEnum",
         "type": "string"
      }
   }
}

Fields:
field message: Message | None = None

generation model result

field delta: str = ''

New text that just streamed in (only used when streaming)

field embedding_results: List[List[float]] | List[float] = []

embedding vector

field rank_scores: Dict[int, float] = {}

The rank scores of each documents. key: index, value: rank score

field m_type: ModelEnum = ModelEnum.GENERATION_MODEL

One of LLM, EMB, RANK.

field status: bool = True

Indicates whether the model call was successful.

field details: str = ''

The details information for model call, usually for storage of raw response or failure messages.

field raw: Any = ''

Raw response from model call

field meta_data: Dict[str, Any] = {}

meta data for model response