mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-17 23:51:19 +00:00
Some checks are pending
Pre-commit / run (ubuntu-latest) (push) Waiting to run
- Introduce BaseAsTokenCounter and EstimatedAsTokenCounter for token estimation - Add AsMsgStat and AsBlockStat schema for message statistics tracking - Implement FileIO class with read/write/append/edit operations - Create file utility functions for safe async file reading and truncation - Add MemorySearch component for semantic search in memory files - Register new component types in ComponentEnum and update imports - Add constants for default host, port, and truncation limits - Create BaseService abstract base class for service implementations - Implement BaseStep with component accessors and lifecycle management - Add proper __all__ exports for all new modules and components
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Base node schema module.
|
|
|
|
This module defines the BaseNode model, which serves as the foundational
|
|
data structure for nodes in the knowledge graph or document processing pipeline.
|
|
"""
|
|
|
|
from uuid import uuid4
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BaseNode(BaseModel):
|
|
"""Base node model for graph and document structures.
|
|
|
|
This model represents a single node in the knowledge graph or
|
|
a chunk in the document processing pipeline. It contains text content,
|
|
optional embeddings, and associated metadata.
|
|
|
|
Attributes:
|
|
id: Unique identifier for the node, auto-generated if not provided.
|
|
text: Text content of the node.
|
|
embedding: Optional vector embedding of the text content.
|
|
metadata: Additional metadata associated with the node.
|
|
"""
|
|
|
|
id: str = Field(default_factory=lambda: uuid4().hex, description="Unique node identifier")
|
|
text: str = Field(default="", description="Text content of the node")
|
|
embedding: list[float] | None = Field(default=None, description="Vector embedding of text")
|
|
metadata: dict = Field(default_factory=dict, description="Additional metadata")
|