Skip to content

message_intel

django_spire.ai.chat.message_intel

BaseMessageIntel

Bases: BaseIntel, ABC

template property

__init_subclass__

Source code in django_spire/ai/chat/message_intel.py
def __init_subclass__(cls):
    super().__init_subclass__()

    if cls._template is None or cls._template == '':
        raise ValueError(f'{cls.__module__}.{cls.__qualname____}._template must be set')

content_to_str abstractmethod

Source code in django_spire/ai/chat/message_intel.py
@abstractmethod
def content_to_str(self) -> str:
    raise NotImplementedError

render_to_string

Source code in django_spire/ai/chat/message_intel.py
def render_to_string(self, context_data: dict | None = None):
    return render_to_string(
        template_name=self._template,
        context={**self.model_dump(), **(context_data or {})},
    )

DefaultMessageIntel

Bases: BaseMessageIntel

text instance-attribute

content_to_str

Source code in django_spire/ai/chat/message_intel.py
def content_to_str(self):
    return self.text