Skip to main content

types.py

Source: sunholo/types.py

Functions

convert_to_langchain_doc(doc: sunholo.types.Document) -> Union[Any, ForwardRef('LangchainDocument')]

Convert our Document to a LangChain Document.

Returns Any when LangChain isn't available to avoid type errors. Only imports LangChain when the function is actually called.

Classes

Document

A simple document class with content and metadata.

Used for storing text content and associated metadata when not using LangChain. Maintains the same basic interface (page_content and metadata) for compatibility.

Using @dataclass makes it automatically serializable and provides nice defaults.

  • eq(self, other)

    • Return self==value.
  • init(self, page_content: str, metadata: Dict[str, Any] = None) -> None

    • Initialize self. See help(type(self)) for accurate signature.
  • post_init(self) -> None

    • Initialize metadata if None.
  • repr(self)

    • Return repr(self).
  • json(self) -> str

    • Convert to JSON string - for compatibility with LangChain's Document.
  • to_dict(self) -> Dict[str, Any]

    • Convert to dictionary.
Sunholo Multivac

Get in touch to see if we can help with your GenAI project.

Contact us

Other Links

Sunholo Multivac - GenAIOps

Copyright ©

Holosun ApS 2025