mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
feat: add memory-json importer, tweak observation content
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from basic_memory.file_utils import ParseError
|
||||
from basic_memory.markdown.entity_parser import EntityParser
|
||||
from basic_memory.markdown.markdown_processor import MarkdownProcessor
|
||||
from basic_memory.markdown.schemas import (
|
||||
EntityMarkdown,
|
||||
EntityFrontmatter,
|
||||
@@ -13,6 +14,7 @@ __all__ = [
|
||||
"EntityMarkdown",
|
||||
"EntityFrontmatter",
|
||||
"EntityParser",
|
||||
"MarkdownProcessor",
|
||||
"Observation",
|
||||
"Relation",
|
||||
"ParseError",
|
||||
|
||||
@@ -68,7 +68,7 @@ def parse_observation(token: Token) -> Dict[str, Any]:
|
||||
|
||||
return {
|
||||
'category': category,
|
||||
'content': ' '.join(content_parts).strip(),
|
||||
'content': content,
|
||||
'tags': list(tags) if tags else None,
|
||||
'context': context
|
||||
}
|
||||
|
||||
@@ -9,15 +9,13 @@ from pydantic import BaseModel
|
||||
class Observation(BaseModel):
|
||||
"""An observation about an entity."""
|
||||
|
||||
category: Optional[str] = None
|
||||
category: Optional[str] = "Note"
|
||||
content: str
|
||||
tags: Optional[List[str]] = None
|
||||
context: Optional[str] = None
|
||||
|
||||
def __str__(self) -> str:
|
||||
obs_string = f"- [{self.category}] {self.content}"
|
||||
if self.tags:
|
||||
obs_string += " " + " ".join(f"#{tag}" for tag in sorted(self.tags))
|
||||
if self.context:
|
||||
obs_string += f" ({self.context})"
|
||||
return obs_string
|
||||
|
||||
Reference in New Issue
Block a user