|
|
|
|
|
from typing import List, Optional, Union |
|
|
from pydantic import BaseModel, Field |
|
|
|
|
|
|
|
|
class SourceDocument(BaseModel): |
|
|
filename: Optional[str] = Field( |
|
|
None, alias="file_name", description="Name of the source document file" |
|
|
) |
|
|
title: Optional[str] = Field( |
|
|
None, alias="title", description="Title of the source document" |
|
|
) |
|
|
type: Optional[str] = Field( |
|
|
None, |
|
|
alias="file_type", |
|
|
description="Data source type of the source document (e.g., confluence, hiveDisk, slack, etc.).", |
|
|
) |
|
|
content: Optional[str] = Field( |
|
|
None, |
|
|
description="Relevant content in the source document used as a piece of context to generate the response.", |
|
|
) |
|
|
url: Optional[str] = Field( |
|
|
None, alias="doc_url", description="Link to the source document, if available." |
|
|
) |
|
|
created_date: Optional[str] = Field( |
|
|
None, description="Date when the source document was created." |
|
|
) |
|
|
created_by: Optional[str] = Field( |
|
|
None, description="Author of the source document." |
|
|
) |
|
|
mongodb_link: Optional[Union[str, bool]] = Field( |
|
|
None, |
|
|
description="Unique identifier of the source document in the MongoDB. This will use to check whether there is an image in the MongoDB or not related to this document.", |
|
|
) |
|
|
|
|
|
model_config = { |
|
|
"extra": "allow" |
|
|
} |
|
|
|
|
|
def __str__(self): |
|
|
return ( |
|
|
f"SourceDocument(\n" |
|
|
f" Title: {self.title or 'N/A'}\n" |
|
|
f" Type: {self.type or 'N/A'}\n" |
|
|
f" Author: {self.created_by or 'N/A'}\n" |
|
|
f" Content: {self.content or 'N/A'}\n" |
|
|
f" URL: {self.url or 'N/A'}\n" |
|
|
f" Created Date: {self.created_date or 'N/A'}\n" |
|
|
f" Updated Date: {self.updated_date or 'N/A'}\n" |
|
|
f")" |
|
|
) |
|
|
|
|
|
|
|
|
class DocumentCollection(BaseModel): |
|
|
list_of_doc: List[SourceDocument] |
|
|
|