kolzchut-ragbot 1.4.0__py3-none-any.whl → 1.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kolzchut_ragbot/model.py +27 -14
- {kolzchut_ragbot-1.4.0.dist-info → kolzchut_ragbot-1.4.1.dist-info}/METADATA +1 -1
- {kolzchut_ragbot-1.4.0.dist-info → kolzchut_ragbot-1.4.1.dist-info}/RECORD +5 -5
- {kolzchut_ragbot-1.4.0.dist-info → kolzchut_ragbot-1.4.1.dist-info}/WHEEL +0 -0
- {kolzchut_ragbot-1.4.0.dist-info → kolzchut_ragbot-1.4.1.dist-info}/top_level.txt +0 -0
kolzchut_ragbot/model.py
CHANGED
@@ -21,6 +21,31 @@ def index_from_page_id(page_id: int):
|
|
21
21
|
index_postfix = round(page_id / 1000)
|
22
22
|
return EMBEDDING_INDEX + "_" + str(index_postfix)
|
23
23
|
|
24
|
+
def create_mapping():
|
25
|
+
"""
|
26
|
+
Creates a mapping for the model in Elasticsearch.
|
27
|
+
"""
|
28
|
+
vector_fields = {f"{name}_{semantic_model}_vectors": {"type": "dense_vector", "dims": 1024}
|
29
|
+
for name, semantic_model in definitions_singleton.models.items()}
|
30
|
+
|
31
|
+
data_fields = {}
|
32
|
+
for field in definitions_singleton.saved_fields.keys():
|
33
|
+
field_type = definitions_singleton.saved_fields[field]
|
34
|
+
field_mapping = {"type": field_type}
|
35
|
+
if field_type == "date":
|
36
|
+
field_mapping["format"] = "yyyyMMddHHmmss"
|
37
|
+
data_fields[f"{field}"] = field_mapping
|
38
|
+
|
39
|
+
mappings = {
|
40
|
+
"properties": {
|
41
|
+
"last_update": {
|
42
|
+
"type": "date",
|
43
|
+
},
|
44
|
+
**vector_fields,
|
45
|
+
**data_fields,
|
46
|
+
}
|
47
|
+
}
|
48
|
+
return mappings
|
24
49
|
|
25
50
|
class Model:
|
26
51
|
"""
|
@@ -59,23 +84,11 @@ class Model:
|
|
59
84
|
"""
|
60
85
|
Creates an index for the model in Elasticsearch.
|
61
86
|
"""
|
87
|
+
mapping = create_mapping()
|
62
88
|
if not self.es_client.indices.exists(index=os.getenv("ES_EMBEDDING_INDEX")):
|
63
|
-
vector_fields = {f"{name}_{semantic_model}_vectors": {"type": "dense_vector", "dims": 1024}
|
64
|
-
for name, semantic_model in definitions_singleton.models.items()}
|
65
|
-
data_fields = {f"{field}": {"type": definitions_singleton.saved_fields[field]}
|
66
|
-
for field in definitions_singleton.saved_fields.keys()}
|
67
|
-
|
68
89
|
self.es_client.indices.create(
|
69
90
|
index=os.getenv("ES_EMBEDDING_INDEX"),
|
70
|
-
mappings=
|
71
|
-
"properties": {
|
72
|
-
"last_update": {
|
73
|
-
"type": "date"
|
74
|
-
},
|
75
|
-
**vector_fields,
|
76
|
-
**data_fields,
|
77
|
-
}
|
78
|
-
})
|
91
|
+
mappings=mapping)
|
79
92
|
|
80
93
|
def create_or_update_documents(self, paragraphs_dicts: list[dict], update=False):
|
81
94
|
"""
|
@@ -4,8 +4,8 @@ kolzchut_ragbot/__init__.py,sha256=KKAc2xjCl5Aui2Cj0FWyvJ51nmnFv7MspLMqOYb-QHA,2
|
|
4
4
|
kolzchut_ragbot/config.py,sha256=pcKVJVJ8P2YximjTrmVlrocHXSmzmNu_DFzNoPLa22E,138
|
5
5
|
kolzchut_ragbot/engine.py,sha256=V8WUWyqvBWbGt-rRRf8G6BEyD-4GjsmtJrxBb6aPon8,10154
|
6
6
|
kolzchut_ragbot/llm_client.py,sha256=q_cUZq645P7i1PliYzpJRTWlsoSECVIhE-y9wU5eRtQ,352
|
7
|
-
kolzchut_ragbot/model.py,sha256=
|
8
|
-
kolzchut_ragbot-1.4.
|
9
|
-
kolzchut_ragbot-1.4.
|
10
|
-
kolzchut_ragbot-1.4.
|
11
|
-
kolzchut_ragbot-1.4.
|
7
|
+
kolzchut_ragbot/model.py,sha256=Nd3_0KXMfyajQTyreKpkb2hsqpkA6_P994laoRKF2iU,6452
|
8
|
+
kolzchut_ragbot-1.4.1.dist-info/METADATA,sha256=oI7PoQRz2ddDIRUtVmVAa0FF8YSlAjQFPzLhC0lq81A,2024
|
9
|
+
kolzchut_ragbot-1.4.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
10
|
+
kolzchut_ragbot-1.4.1.dist-info/top_level.txt,sha256=NTZoY4GGw3v_7jm0MgcdHw8simoZ78PsR7Meqmkgd_Q,16
|
11
|
+
kolzchut_ragbot-1.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|