Files
SIA/sia/reasoning_entry.py

51 lines
1.3 KiB
Python

from datetime import datetime
import xml.etree.ElementTree as ET
from .entry import Entry
from .util import escape_text_for_xml
class ReasoningEntry(Entry):
"""
Entry type for agent reasoning steps.
Attributes:
_content: The reasoning text
"""
def __init__(self, content: str, id: str, timestamp: datetime):
"""
Initialize a new reasoning entry.
Args:
content: The reasoning text
id: Unique identifier for this entry
timestamp: Creation timestamp for this entry
"""
super().__init__(id, timestamp)
self._content = content
@property
def content(self) -> str:
"""
Get the reasoning text.
"""
return self._content
def update(self) -> None:
"""No update needed for reasoning entries."""
pass
def generate_context(self) -> ET.Element:
"""
Generate an XML Element representing this reasoning entry.
Returns:
ET.Element: XML element containing the entry's data
"""
# Create root element
element = ET.Element("reasoning", {"id": self._id})
# Add content as CDATA or escaped text
element.text = escape_text_for_xml(self._content)
return element