File size: 1,929 Bytes
8816dfd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
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]