vector-vault 7.2.2__tar.gz → 7.2.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vector_vault
3
- Version: 7.2.2
3
+ Version: 7.2.4
4
4
  Summary: Quickly create RAG apps, Agents, and Unleash the full power of 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="7.2.2",
5
+ version="7.2.4",
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: 7.2.2
3
+ Version: 7.2.4
4
4
  Summary: Quickly create RAG apps, Agents, and Unleash the full power of AI with Vector Vault
5
5
  Home-page: https://github.com/John-Rood/VectorVault
6
6
  Author: VectorVault.io
@@ -312,6 +312,10 @@ class OpenAIPlatform(LLMPlatform):
312
312
  return None
313
313
 
314
314
  def model_check(self, token_count, model):
315
+ # Handle 'default' model - return the actual default model name
316
+ if model == 'default':
317
+ return self.model_token_limits['default']
318
+
315
319
  if model not in self.model_token_limits.keys():
316
320
  return model
317
321
  else:
@@ -119,10 +119,25 @@ def get_time_statement(now, message_time):
119
119
  return human_readable_time
120
120
 
121
121
  def load_json(json_object):
122
- def load_json_from_string(string):
122
+ """
123
+ Loads a JSON object from either a string (potentially double-wrapped) or a direct object.
124
+ Handles cases where the JSON might be escaped inside a string by attempting multiple parses.
125
+ """
126
+ def parse_json(string):
123
127
  try:
124
128
  return json.loads(string)
125
129
  except json.JSONDecodeError:
126
130
  raise ValueError("Invalid JSON string provided.")
127
-
128
- return load_json_from_string(json_object) if isinstance(json_object, str) else json_object
131
+
132
+ # If it's not a string, return as is
133
+ if not isinstance(json_object, str):
134
+ return json_object
135
+
136
+ # Initial parse
137
+ result = parse_json(json_object)
138
+
139
+ # If the result is still a string (double-wrapped), parse again
140
+ if isinstance(result, str):
141
+ result = parse_json(result)
142
+
143
+ return result
@@ -1101,7 +1101,7 @@ class Vault:
1101
1101
 
1102
1102
  return json.dumps(results)
1103
1103
 
1104
-
1104
+
1105
1105
  def upload_database_from_json(self, json_data: Union[str, dict]):
1106
1106
  """
1107
1107
  Replace your entire vault from a JSON string or dictionary.
@@ -1115,7 +1115,37 @@ class Vault:
1115
1115
  vault.upload_database_from_json(json_string_or_dict)
1116
1116
 
1117
1117
  """
1118
- items_dict = load_json(json_data)
1118
+ def parse_json(string):
1119
+ try:
1120
+ return json.loads(string)
1121
+ except json.JSONDecodeError:
1122
+ print("Warning: JSON decoding failed. Attempting to clean and retry...") if self.verbose else 0
1123
+ # Attempt to clean: strip outer quotes if present
1124
+ cleaned = string.strip().strip('"')
1125
+ try:
1126
+ return json.loads(cleaned)
1127
+ except json.JSONDecodeError:
1128
+ print("Error: Failed to parse JSON after cleaning attempt. Skipping upload.") if self.verbose else 0
1129
+ return {} # Return empty dict to adapt and continue without raising
1130
+
1131
+ # Load the JSON data with robust parsing
1132
+ if not isinstance(json_data, str):
1133
+ items_dict = json_data # Already a dict, use as is
1134
+ else:
1135
+ # Initial parse for string input
1136
+ result = parse_json(json_data)
1137
+
1138
+ # If the result is still a string (double-wrapped), parse again
1139
+ if isinstance(result, str):
1140
+ result = parse_json(result)
1141
+
1142
+ # After parsing, ensure it's a dict
1143
+ if not isinstance(result, dict):
1144
+ print("Warning: Parsed result is not a dictionary. Using empty dict to continue.") if self.verbose else 0
1145
+ items_dict = {}
1146
+ else:
1147
+ items_dict = result
1148
+
1119
1149
  print('Loaded json items') if self.verbose else 0
1120
1150
  print('Deleting cloud items') if self.verbose else 0
1121
1151
 
@@ -1124,7 +1154,7 @@ class Vault:
1124
1154
  items_added = 0
1125
1155
  for item_number, item_data in sorted(items_dict.items()):
1126
1156
  if 'data' not in item_data:
1127
- print(f"Skipping item {item_number}: Invalid format")
1157
+ print(f"Skipping item {item_number}: Invalid format") if self.verbose else 0
1128
1158
  continue
1129
1159
 
1130
1160
  self.add_item(text=item_data['data'], meta=item_data.get('metadata', None))
File without changes
File without changes
File without changes