kolzchut-ragbot 1.4.1__py3-none-any.whl → 1.4.2__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 CHANGED
@@ -21,11 +21,12 @@ 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
+
24
25
  def create_mapping():
25
26
  """
26
27
  Creates a mapping for the model in Elasticsearch.
27
28
  """
28
- vector_fields = {f"{name}_{semantic_model}_vectors": {"type": "dense_vector", "dims": 1024}
29
+ vector_fields = {f'{semantic_model}_{name}_vectors': {"type": "dense_vector", "dims": 1024}
29
30
  for name, semantic_model in definitions_singleton.models.items()}
30
31
 
31
32
  data_fields = {}
@@ -47,6 +48,7 @@ def create_mapping():
47
48
  }
48
49
  return mappings
49
50
 
51
+
50
52
  class Model:
51
53
  """
52
54
  Represents the model for creating, updating, and searching documents in Elasticsearch.
@@ -80,15 +82,16 @@ class Model:
80
82
  if custom_result_selection_function is not None:
81
83
  self.custom_result_selection_function = custom_result_selection_function
82
84
 
83
- def create_index(self):
85
+ def create_index(self, index_name):
84
86
  """
85
87
  Creates an index for the model in Elasticsearch.
86
88
  """
87
89
  mapping = create_mapping()
88
- if not self.es_client.indices.exists(index=os.getenv("ES_EMBEDDING_INDEX")):
90
+ if not self.es_client.indices.exists(index=index_name):
89
91
  self.es_client.indices.create(
90
- index=os.getenv("ES_EMBEDDING_INDEX"),
91
- mappings=mapping)
92
+ index=index_name,
93
+ mappings=mapping
94
+ )
92
95
 
93
96
  def create_or_update_documents(self, paragraphs_dicts: list[dict], update=False):
94
97
  """
@@ -118,9 +121,9 @@ class Model:
118
121
 
119
122
  except Exception as e:
120
123
  logging.error(f"Error while searching for existing document: {e}")
121
-
124
+ self.create_index(index)
122
125
  for i, doc_dict in enumerate(paragraphs_dicts):
123
- print(f"saving paragraph {i}")
126
+ print(f"saving paragraph {i + 1} / {len(paragraphs_dicts)}")
124
127
  doc = {
125
128
  "last_update": datetime.datetime.now(),
126
129
  **doc_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kolzchut-ragbot
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: A search engine using machine learning models and Elasticsearch for advanced document retrieval.
5
5
  Home-page: https://github.com/shmuelrob/rag-bot
6
6
  Author: Shmuel Robinov
@@ -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=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,,
7
+ kolzchut_ragbot/model.py,sha256=M7i9B-zzwa-ATblY-5c7gmbkOXKwS8wWmYMP8l0HE40,6502
8
+ kolzchut_ragbot-1.4.2.dist-info/METADATA,sha256=YctMSApfbXBBvx7d0APy28lDWmulO3cfHJKjKOZ_LYQ,2024
9
+ kolzchut_ragbot-1.4.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
10
+ kolzchut_ragbot-1.4.2.dist-info/top_level.txt,sha256=NTZoY4GGw3v_7jm0MgcdHw8simoZ78PsR7Meqmkgd_Q,16
11
+ kolzchut_ragbot-1.4.2.dist-info/RECORD,,