forked from openai/chatgpt-retrieval-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
models.py
79 lines (53 loc) · 1.68 KB
/
models.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from pydantic import BaseModel
from typing import List, Optional
from enum import Enum
class Source(str, Enum):
email = "email"
file = "file"
chat = "chat"
class DocumentMetadata(BaseModel):
source: Optional[Source] = None
source_id: Optional[str] = None
url: Optional[str] = None
created_at: Optional[str] = None
author: Optional[str] = None
class DocumentChunkMetadata(DocumentMetadata):
document_id: Optional[str] = None
class DocumentChunk(BaseModel):
id: Optional[str] = None
text: str
metadata: DocumentChunkMetadata
embedding: Optional[List[float]] = None
class DocumentChunkWithScore(DocumentChunk):
score: float
class Document(BaseModel):
id: Optional[str] = None
text: str
metadata: Optional[DocumentMetadata] = None
class DocumentWithChunks(Document):
chunks: List[DocumentChunk]
class DocumentMetadataFilter(BaseModel):
document_id: Optional[str] = None
source: Optional[Source] = None
source_id: Optional[str] = None
author: Optional[str] = None
start_date: Optional[str] = None # any date string format
end_date: Optional[str] = None # any date string format
class Query(BaseModel):
query: str
filter: Optional[DocumentMetadataFilter] = None
top_k: Optional[int] = 3
class QueryWithEmbedding(Query):
embedding: List[float]
class QueryResult(BaseModel):
query: str
results: List[DocumentChunkWithScore]
class ActiveCollection(BaseModel):
collection_name: str
overview: Optional[str]
class Collection(BaseModel):
collection_name: str
embedding_method: str
overview: Optional[str] = None
description: Optional[str] = None
is_active: bool