Interface for interacting with a document.
| 104 | |
| 105 | |
| 106 | class Document(BaseModel): |
| 107 | """Interface for interacting with a document.""" |
| 108 | |
| 109 | content: str |
| 110 | metadata: DocMetaData |
| 111 | |
| 112 | def id(self) -> str: |
| 113 | return self.metadata.id |
| 114 | |
| 115 | @staticmethod |
| 116 | def from_string( |
| 117 | content: str, |
| 118 | source: str = "context", |
| 119 | is_chunk: bool = True, |
| 120 | ) -> "Document": |
| 121 | return Document( |
| 122 | content=content, |
| 123 | metadata=DocMetaData(source=source, is_chunk=is_chunk), |
| 124 | ) |
| 125 | |
| 126 | def __str__(self) -> str: |
| 127 | return dedent( |
| 128 | f""" |
| 129 | CONTENT: {self.content} |
| 130 | SOURCE:{str(self.metadata)} |
| 131 | """ |
| 132 | ) |
| 133 | |
| 134 | |
| 135 | class NonToolAction(str, Enum): |
no outgoing calls
searching dependent graphs…