vector-vault 3.3.8__tar.gz → 3.4.0__tar.gz

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.
Files changed (21) hide show
  1. {vector_vault-3.3.8 → vector_vault-3.4.0}/PKG-INFO +1 -1
  2. {vector_vault-3.3.8 → vector_vault-3.4.0}/setup.py +1 -1
  3. {vector_vault-3.3.8 → vector_vault-3.4.0}/vector_vault.egg-info/PKG-INFO +1 -1
  4. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/cloudmanager.py +5 -2
  5. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/vault.py +28 -32
  6. {vector_vault-3.3.8 → vector_vault-3.4.0}/LICENSE +0 -0
  7. {vector_vault-3.3.8 → vector_vault-3.4.0}/README.md +0 -0
  8. {vector_vault-3.3.8 → vector_vault-3.4.0}/setup.cfg +0 -0
  9. {vector_vault-3.3.8 → vector_vault-3.4.0}/vector_vault.egg-info/SOURCES.txt +0 -0
  10. {vector_vault-3.3.8 → vector_vault-3.4.0}/vector_vault.egg-info/dependency_links.txt +0 -0
  11. {vector_vault-3.3.8 → vector_vault-3.4.0}/vector_vault.egg-info/requires.txt +0 -0
  12. {vector_vault-3.3.8 → vector_vault-3.4.0}/vector_vault.egg-info/top_level.txt +0 -0
  13. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/__init__.py +0 -0
  14. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/ai.py +0 -0
  15. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/cloud_api.py +0 -0
  16. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/creds.py +0 -0
  17. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/download.py +0 -0
  18. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/itemize.py +0 -0
  19. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/tools_gpt.py +0 -0
  20. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/vecreq.py +0 -0
  21. {vector_vault-3.3.8 → vector_vault-3.4.0}/vectorvault/wrap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vector_vault
3
- Version: 3.3.8
3
+ Version: 3.4.0
4
4
  Summary: Quickly create ChatGPT RAG apps and Unleash the full potential of generative AI with Vector Vault
5
5
  Home-page: https://github.com/John-Rood/VectorVault
6
6
  Author: VectorVault.io
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="vector_vault",
5
- version="3.3.8",
5
+ version="3.4.0",
6
6
  packages=find_packages(),
7
7
  author="VectorVault.io",
8
8
  author_email="john@johnrood.com",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vector-vault
3
- Version: 3.3.8
3
+ Version: 3.4.0
4
4
  Summary: Quickly create ChatGPT RAG apps and Unleash the full potential of generative AI with Vector Vault
5
5
  Home-page: https://github.com/John-Rood/VectorVault
6
6
  Author: VectorVault.io
@@ -42,8 +42,11 @@ class CloudManager:
42
42
  directories = set()
43
43
  for blob in blobs:
44
44
  parts = blob.name.split('/')
45
- if len(parts) > 2 and not parts[1][0].isdigit():
46
- directories.add(parts[1])
45
+ if len(parts) == 2:
46
+ vault_name = parts[1]
47
+ if vault_name.endswith('.ann'):
48
+ clean_vault_name = vault_name.replace('.ann', '')
49
+ directories.add(clean_vault_name)
47
50
  return list(directories)
48
51
 
49
52
  def upload_to_cloud(self, vault_name, content):
@@ -111,14 +111,14 @@ class Vault:
111
111
  self.check_index()
112
112
  return self.vectors.get_n_items()
113
113
 
114
- def get_tokens(self, text):
114
+ def get_tokens(self, text: str):
115
115
  '''
116
116
  Returns the distance between two vectors - item ids are needed to compare 916-324-7308
117
117
  '''
118
118
  self.load_ai()
119
119
  return self.ai.get_tokens(text)
120
120
 
121
- def get_distance(self, id1, id2):
121
+ def get_distance(self, id1: int, id2: int):
122
122
  '''
123
123
  Returns the distance between two vectors - item ids are needed to compare
124
124
  '''
@@ -150,7 +150,7 @@ class Vault:
150
150
  self.ai = AI(personality_message, main_prompt)
151
151
  self.ai_loaded = True
152
152
 
153
- def save_personality_message(self, personality_message):
153
+ def save_personality_message(self, personality_message: str):
154
154
  '''
155
155
  Saves personality_message to the vault and use it by default from now on
156
156
  '''
@@ -165,7 +165,7 @@ class Vault:
165
165
  '''
166
166
  return self.cloud_manager.download_text_from_cloud(f'{self.vault}/prompt')
167
167
 
168
- def save_custom_prompt(self, prompt):
168
+ def save_custom_prompt(self, prompt: str):
169
169
  '''
170
170
  Saves custom_prompt to the vault and use it by default from now on
171
171
  '''
@@ -174,7 +174,7 @@ class Vault:
174
174
  if self.verbose:
175
175
  print(f"Custom prompt saved")
176
176
 
177
- def save(self, trees=16):
177
+ def save(self, trees: int = 16):
178
178
  '''
179
179
  Saves all the data added locally to the Cloud. All Vault references are Cloud references.
180
180
  To add data to your Vault and access it later, you must first call add(), then get_vectors(), and finally save().
@@ -226,7 +226,7 @@ class Vault:
226
226
  self.map[str(i)] = self.map[str(i + 1)]
227
227
  self.map.popitem()
228
228
 
229
- def delete_items(self, item_ids : Union[int, List[int]], trees = 16) -> None:
229
+ def delete_items(self, item_ids : List[int], trees: int = 16) -> None:
230
230
  '''
231
231
  Deletes one or more items from item_id(s) passed in.
232
232
  item_ids is an int or a list of integers
@@ -259,7 +259,7 @@ class Vault:
259
259
  if self.verbose:
260
260
  print(f'Item {item_id} deleted')
261
261
 
262
- def edit_item(self, item_id : int, new_text : str, metadata : dict = None, trees = 16) -> None:
262
+ def edit_item(self, item_id : int, new_text : str, metadata : dict = None, trees: int = 16) -> None:
263
263
  '''
264
264
  Edits any item. Enter the new text and new vectors will automatically be created.
265
265
  New data and vectors will be uploaded and the old data will be deleted
@@ -373,7 +373,7 @@ class Vault:
373
373
  self.vecs_loaded = False
374
374
  self.saved_already = False
375
375
 
376
- def split_text(self, text, min_threshold=1000, max_threshold=16000):
376
+ def split_text(self, text: str, min_threshold: int = 1000, max_threshold: int = 16000):
377
377
  '''
378
378
  Internal function
379
379
  Splits the given text into chunks of sentences such that each chunk's length
@@ -420,7 +420,7 @@ class Vault:
420
420
 
421
421
  return segments
422
422
 
423
- def get_items(self, ids: list = [], include_total=False) -> list:
423
+ def get_items(self, ids: List[int] = [], include_total: bool = False) -> list:
424
424
  '''
425
425
  Get one or more items from the database.
426
426
  Input the item id(s) in a list. -> Returns the items
@@ -457,7 +457,7 @@ class Vault:
457
457
  return results
458
458
 
459
459
 
460
- def get_items_by_vector(self, vector, n: int = 4, include_distances=False):
460
+ def get_items_by_vector(self, vector: list, n: int = 4, include_distances: bool = False):
461
461
  '''
462
462
  Internal function that returns vector similar items. Requires input vector, returns similar items
463
463
  '''
@@ -495,7 +495,7 @@ class Vault:
495
495
  except:
496
496
  return [{'data': 'No data has been added', 'metadata': {'no meta': 'No metadata has been added'}}]
497
497
 
498
- def get_similar_local(self, text, n: int = 4, include_distances=False, model="text-embedding-ada-002"):
498
+ def get_similar_local(self, text: str, n: int = 4, include_distances: bool = False, model: str = "text-embedding-ada-002"):
499
499
  '''
500
500
  Returns similar items from the Vault as the one you entered, but locally
501
501
  (saves a few milliseconds and is sometimes used on production builds)
@@ -503,7 +503,7 @@ class Vault:
503
503
  vector = self.process_batch([text], never_stop=False, loop_timeout=180, model=model)[0]
504
504
  return self.get_items_by_vector(vector, n, include_distances=include_distances)
505
505
 
506
- def get_similar(self, text, n: int = 4, include_distances=False):
506
+ def get_similar(self, text: str, n: int = 4, include_distances: bool = False):
507
507
  '''
508
508
  Returns similar items from the Vault as the text you enter.
509
509
  Sample return when called:
@@ -533,7 +533,7 @@ class Vault:
533
533
  self.items.append(new_item)
534
534
  self.add_to_map()
535
535
 
536
- def add(self, text: str, meta: dict = None, name: str = None, split=False, split_size=1000, max_threshold=16000):
536
+ def add(self, text: str, meta: dict = None, name: str = None, split: bool = False, split_size: int = 1000, max_threshold: int = 16000):
537
537
  """
538
538
  If your text length is greater than 4000 tokens, Vault.split_text(your_text)
539
539
  will automatically be added
@@ -594,7 +594,7 @@ class Vault:
594
594
  raise TimeoutError("Loop timed out")
595
595
  return [record.embedding for record in res.data]
596
596
 
597
- def get_vectors(self, batch_size: int = 32, never_stop: bool = False, loop_timeout: int = 777, model="text-embedding-ada-002"):
597
+ def get_vectors(self, batch_size: int = 32, never_stop: bool = False, loop_timeout: int = 777, model: str = "text-embedding-ada-002"):
598
598
  '''
599
599
  Takes text data added to the vault, and gets vectors for them
600
600
  '''
@@ -625,7 +625,10 @@ class Vault:
625
625
  print("get vectors time --- %s seconds ---" % (time.time() - start_time))
626
626
 
627
627
 
628
- def get_chat(self, text: str = None, history: str = None, summary: bool = False, get_context = False, n_context = 4, return_context = False, smart_history_search = False, model='gpt-3.5-turbo', include_context_meta=False, custom_prompt=False, local=False, temperature=0, timeout=45):
628
+ def get_chat(self, text: str = None, history: str = None, summary: bool = False, get_context: bool = False,
629
+ n_context: int = 4, return_context: bool = False, smart_history_search: bool = False,
630
+ model: str = 'gpt-3.5-turbo', include_context_meta: bool = False, custom_prompt: bool = False,
631
+ local: bool =False, temperature: int = 0, timeout: int = 45):
629
632
  '''
630
633
  Chat get response from OpenAI's ChatGPT.
631
634
  Models: ChatGPT = "gpt-3.5-turbo" • GPT4 = "gpt-4"
@@ -711,13 +714,7 @@ class Vault:
711
714
  history = ''
712
715
 
713
716
  if text:
714
- if not self.ai.within_context_window(text, model):
715
- if summary:
716
- inputs = self.split_text(text, self.ai.model_token_limits.get(model, 15000) * 3)
717
- else:
718
- inputs = text[-(self.ai.model_token_limits.get(model, 15000) * 3):]
719
- else:
720
- inputs = [text]
717
+ inputs = [text]
721
718
  else:
722
719
  if not custom_prompt:
723
720
  raise ValueError("No input text provided. Please enter text to proceed.")
@@ -741,12 +738,12 @@ class Vault:
741
738
 
742
739
  if include_context_meta:
743
740
  context = self.get_similar(search_input, n=n_context) if not local else self.get_similar_local(search_input, n=n_context)
744
- input_ = str(context)
741
+ input_ = str(context) # all of the metadata included
745
742
  else:
746
743
  context = self.get_similar(search_input, n=n_context) if not local else self.get_similar_local(search_input, n=n_context)
747
744
  input_ = ''
748
745
  for text in context:
749
- input_ += text['data']
746
+ input_ += text['data'] # just the text data, no metadata
750
747
  response = self.ai.llm_w_context(segment, input_, history, model=model, custom_prompt=custom_prompt, temperature=temperature, timeout=timeout)
751
748
  else: # Custom prompt only
752
749
  if inputs[0] == 0:
@@ -775,7 +772,12 @@ class Vault:
775
772
  elif return_context:
776
773
  return {'response': response, 'context': context}
777
774
 
778
- def get_chat_stream(self, text: str = None, history: str = None, summary: bool = False, get_context = False, n_context = 4, return_context = False, smart_history_search = False, model='gpt-3.5-turbo', include_context_meta=False, metatag=False, metatag_prefixes=False, metatag_suffixes=False, custom_prompt=False, local=False, temperature=0, timeout=45):
775
+
776
+ def get_chat_stream(self, text: str = None, history: str = None, summary: bool = False, get_context: bool = False,
777
+ n_context: int = 4, return_context: bool = False, smart_history_search: bool = False,
778
+ model: str ='gpt-3.5-turbo', include_context_meta: bool = False, metatag: bool = False,
779
+ metatag_prefixes: bool = False, metatag_suffixes: bool = False, custom_prompt: bool = False,
780
+ local: bool = False, temperature: int = 0, timeout: int = 45):
779
781
  '''
780
782
  Always use this get_chat_stream() wrapped by either print_stream(), or cloud_stream().
781
783
  cloud_stream() is for cloud functions, like a flask app serving a front end elsewhere.
@@ -848,13 +850,7 @@ class Vault:
848
850
  history = ''
849
851
 
850
852
  if text:
851
- if not self.ai.within_context_window(text, model):
852
- if summary:
853
- inputs = self.split_text(text, self.ai.model_token_limits.get(model, 15000) * 3)
854
- else:
855
- inputs = text[-(self.ai.model_token_limits.get(model, 15000) * 3):]
856
- else:
857
- inputs = [text]
853
+ inputs = [text]
858
854
  else:
859
855
  if not custom_prompt:
860
856
  raise ValueError("No input text provided. Please enter text to proceed.")
File without changes
File without changes
File without changes