vector-vault 7.3.3__tar.gz → 7.3.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.
- {vector_vault-7.3.3 → vector_vault-7.3.4}/PKG-INFO +1 -1
- {vector_vault-7.3.3 → vector_vault-7.3.4}/setup.py +1 -1
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vector_vault.egg-info/PKG-INFO +1 -1
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/ai.py +30 -2
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/vault.py +85 -2
- {vector_vault-7.3.3 → vector_vault-7.3.4}/LICENSE +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/README.md +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/setup.cfg +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vector_vault.egg-info/SOURCES.txt +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vector_vault.egg-info/dependency_links.txt +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vector_vault.egg-info/requires.txt +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vector_vault.egg-info/top_level.txt +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/__init__.py +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/cloud_api.py +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/cloudmanager.py +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/credentials_manager.py +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/itemize.py +0 -0
- {vector_vault-7.3.3 → vector_vault-7.3.4}/vectorvault/utils.py +0 -0
|
@@ -1158,7 +1158,7 @@ class LLMClient:
|
|
|
1158
1158
|
|
|
1159
1159
|
return {'text': text, 'history': history, 'context': context}
|
|
1160
1160
|
|
|
1161
|
-
def
|
|
1161
|
+
def text_llm(self, user_input: str = '', history: str = '', model=None, custom_prompt=False, temperature=0, timeout=None, max_retries=5):
|
|
1162
1162
|
timeout = self.timeout if not timeout else timeout
|
|
1163
1163
|
prompt_template = custom_prompt if custom_prompt else self.prompt
|
|
1164
1164
|
|
|
@@ -1205,7 +1205,35 @@ class LLMClient:
|
|
|
1205
1205
|
)
|
|
1206
1206
|
else:
|
|
1207
1207
|
# Otherwise use regular text LLM
|
|
1208
|
-
return self.
|
|
1208
|
+
return self.text_llm(
|
|
1209
|
+
user_input=user_input,
|
|
1210
|
+
history=history,
|
|
1211
|
+
model=model,
|
|
1212
|
+
custom_prompt=custom_prompt,
|
|
1213
|
+
temperature=temperature,
|
|
1214
|
+
timeout=timeout,
|
|
1215
|
+
max_retries=max_retries
|
|
1216
|
+
)
|
|
1217
|
+
|
|
1218
|
+
def llm(self, user_input: str = '', history: str = '', model=None, custom_prompt=False, temperature=0, timeout=None, max_retries=5, image_path=None, image_url=None):
|
|
1219
|
+
"""
|
|
1220
|
+
Smart LLM method that automatically switches between text-only LLM and image inference
|
|
1221
|
+
based on whether image parameters are provided.
|
|
1222
|
+
"""
|
|
1223
|
+
# If image parameters are provided, use image inference
|
|
1224
|
+
if image_path or image_url:
|
|
1225
|
+
return self.image_inference(
|
|
1226
|
+
image_path=image_path,
|
|
1227
|
+
image_url=image_url,
|
|
1228
|
+
user_text=user_input,
|
|
1229
|
+
model=model,
|
|
1230
|
+
stream=False,
|
|
1231
|
+
temperature=temperature,
|
|
1232
|
+
timeout=timeout
|
|
1233
|
+
)
|
|
1234
|
+
else:
|
|
1235
|
+
# Otherwise use regular text LLM
|
|
1236
|
+
return self.text_llm(
|
|
1209
1237
|
user_input=user_input,
|
|
1210
1238
|
history=history,
|
|
1211
1239
|
model=model,
|
|
@@ -124,6 +124,64 @@ class Vault:
|
|
|
124
124
|
Question: {content}
|
|
125
125
|
"""
|
|
126
126
|
self.personality_message = personality_message if personality_message else ""
|
|
127
|
+
|
|
128
|
+
# Async prefetch for custom prompts and personality message
|
|
129
|
+
self._prefetch_executor = ThreadPoolExecutor(max_workers=3)
|
|
130
|
+
self._personality_future = None
|
|
131
|
+
self._custom_prompt_future = None
|
|
132
|
+
self._custom_prompt_no_context_future = None
|
|
133
|
+
|
|
134
|
+
# Start async prefetch if user and api_key are provided
|
|
135
|
+
if user and api_key:
|
|
136
|
+
self._start_prefetch()
|
|
137
|
+
|
|
138
|
+
def _start_prefetch(self):
|
|
139
|
+
"""Start async prefetch of personality message and custom prompts"""
|
|
140
|
+
try:
|
|
141
|
+
# Submit async tasks to prefetch data
|
|
142
|
+
self._personality_future = self._prefetch_executor.submit(self._fetch_personality_from_cloud)
|
|
143
|
+
self._custom_prompt_future = self._prefetch_executor.submit(self._fetch_custom_prompt_from_cloud, True)
|
|
144
|
+
self._custom_prompt_no_context_future = self._prefetch_executor.submit(self._fetch_custom_prompt_from_cloud, False)
|
|
145
|
+
except Exception as e:
|
|
146
|
+
if self.verbose:
|
|
147
|
+
print(f"Could not start prefetch: {e}")
|
|
148
|
+
|
|
149
|
+
def prefetch_prompts(self):
|
|
150
|
+
"""
|
|
151
|
+
Manually trigger prefetch of personality message and custom prompts.
|
|
152
|
+
Useful if you want to explicitly control when the async fetch begins.
|
|
153
|
+
"""
|
|
154
|
+
if not self._personality_future or not self._custom_prompt_future:
|
|
155
|
+
self._start_prefetch()
|
|
156
|
+
if self.verbose:
|
|
157
|
+
print("Prefetch started for personality and custom prompts")
|
|
158
|
+
elif self.verbose:
|
|
159
|
+
print("Prefetch already in progress")
|
|
160
|
+
|
|
161
|
+
def __del__(self):
|
|
162
|
+
"""Cleanup executor on deletion"""
|
|
163
|
+
try:
|
|
164
|
+
if hasattr(self, '_prefetch_executor'):
|
|
165
|
+
self._prefetch_executor.shutdown(wait=False)
|
|
166
|
+
except:
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
def _fetch_personality_from_cloud(self):
|
|
170
|
+
"""Internal method to fetch personality message from cloud"""
|
|
171
|
+
try:
|
|
172
|
+
return self.cloud_manager.download_text_from_cloud(f'{self.vault}/personality_message')
|
|
173
|
+
except:
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
def _fetch_custom_prompt_from_cloud(self, context=True):
|
|
177
|
+
"""Internal method to fetch custom prompt from cloud"""
|
|
178
|
+
try:
|
|
179
|
+
if context:
|
|
180
|
+
return self.cloud_manager.download_text_from_cloud(f'{self.vault}/prompt')
|
|
181
|
+
else:
|
|
182
|
+
return self.cloud_manager.download_text_from_cloud(f'{self.vault}/no_context_prompt')
|
|
183
|
+
except:
|
|
184
|
+
return None
|
|
127
185
|
|
|
128
186
|
@property
|
|
129
187
|
def cloud_manager(self):
|
|
@@ -364,8 +422,20 @@ class Vault:
|
|
|
364
422
|
|
|
365
423
|
def fetch_personality_message(self):
|
|
366
424
|
'''
|
|
367
|
-
Retrieves personality_message from the vault if it is there or else use the defualt
|
|
425
|
+
Retrieves personality_message from the vault if it is there or else use the defualt.
|
|
426
|
+
Uses prefetched result if available for faster access.
|
|
368
427
|
'''
|
|
428
|
+
# Check if we have a prefetch future and get the result
|
|
429
|
+
if self._personality_future is not None:
|
|
430
|
+
try:
|
|
431
|
+
personality_message = self._personality_future.result(timeout=10)
|
|
432
|
+
if personality_message is not None:
|
|
433
|
+
return personality_message
|
|
434
|
+
except Exception as e:
|
|
435
|
+
if self.verbose:
|
|
436
|
+
print(f"Could not retrieve prefetched personality: {e}")
|
|
437
|
+
|
|
438
|
+
# Fallback to synchronous fetch
|
|
369
439
|
try:
|
|
370
440
|
personality_message = self.cloud_manager.download_text_from_cloud(f'{self.vault}/personality_message')
|
|
371
441
|
except:
|
|
@@ -390,8 +460,21 @@ class Vault:
|
|
|
390
460
|
def fetch_custom_prompt(self, context=True):
|
|
391
461
|
'''
|
|
392
462
|
Retrieves custom_prompt from the vault if there or eles use defualt - (used for get_context = True responses)
|
|
393
|
-
context == False will return custom prompt for not context situations
|
|
463
|
+
context == False will return custom prompt for not context situations.
|
|
464
|
+
Uses prefetched result if available for faster access.
|
|
394
465
|
'''
|
|
466
|
+
# Check if we have a prefetch future and get the result
|
|
467
|
+
future = self._custom_prompt_future if context else self._custom_prompt_no_context_future
|
|
468
|
+
if future is not None:
|
|
469
|
+
try:
|
|
470
|
+
prompt = future.result(timeout=10)
|
|
471
|
+
if prompt is not None:
|
|
472
|
+
return prompt
|
|
473
|
+
except Exception as e:
|
|
474
|
+
if self.verbose:
|
|
475
|
+
print(f"Could not retrieve prefetched custom prompt: {e}")
|
|
476
|
+
|
|
477
|
+
# Fallback to synchronous fetch
|
|
395
478
|
try:
|
|
396
479
|
prompt = self.cloud_manager.download_text_from_cloud(f'{self.vault}/prompt') if context else self.cloud_manager.download_text_from_cloud(f'{self.vault}/no_context_prompt')
|
|
397
480
|
except:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|