Spaces:
Runtime error
Runtime error
save cache
Browse files- app.py +14 -3
- chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/data_level0.bin +3 -0
- chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/header.bin +3 -0
- chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/length.bin +3 -0
- chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/link_lists.bin +0 -0
- chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/data_level0.bin +3 -0
- chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/header.bin +3 -0
- chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/length.bin +3 -0
- chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/link_lists.bin +0 -0
app.py
CHANGED
|
@@ -491,7 +491,13 @@ def prepare_compression_and_rag(combined_text, retrieval_slider_value, global_lo
|
|
| 491 |
target_token_size = 0
|
| 492 |
past_key_values = FinchCache()
|
| 493 |
compressed_length = past_key_values.get_seq_length()
|
| 494 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
# Use the precomputed rag_index from state.
|
| 497 |
collection_name = state.get("rag_index", None)
|
|
@@ -505,7 +511,7 @@ def prepare_compression_and_rag(combined_text, retrieval_slider_value, global_lo
|
|
| 505 |
rag_index = create_rag_index(collection_name, rag_text)
|
| 506 |
|
| 507 |
state.update({
|
| 508 |
-
"compressed_cache":
|
| 509 |
"compressed_length": compressed_length,
|
| 510 |
"rag_index": collection_name,
|
| 511 |
"target_token_size": target_token_size,
|
|
@@ -526,7 +532,12 @@ def chat_response_stream(message: str, history: list, state: dict):
|
|
| 526 |
Returns a simple string (not a list of message dicts) for ChatInterface.
|
| 527 |
"""
|
| 528 |
user_message = message
|
| 529 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
compressed_length = past_key_values.get_seq_length()
|
| 531 |
collection_name = state["rag_index"]
|
| 532 |
retrieval_slider_value = state["retrieval_slider"]
|
|
|
|
| 491 |
target_token_size = 0
|
| 492 |
past_key_values = FinchCache()
|
| 493 |
compressed_length = past_key_values.get_seq_length()
|
| 494 |
+
|
| 495 |
+
cache_name = "default_cache_" + uuid.uuid4().hex[:6]
|
| 496 |
+
cache_name = "default_cache_" + uuid.uuid4().hex[:6] + ".pt"
|
| 497 |
+
save_dir = "./cache_dir"
|
| 498 |
+
os.makedirs(save_dir, exist_ok=True)
|
| 499 |
+
save_path = os.path.join(save_dir, cache_name)
|
| 500 |
+
past_key_values.save(save_path)
|
| 501 |
|
| 502 |
# Use the precomputed rag_index from state.
|
| 503 |
collection_name = state.get("rag_index", None)
|
|
|
|
| 511 |
rag_index = create_rag_index(collection_name, rag_text)
|
| 512 |
|
| 513 |
state.update({
|
| 514 |
+
"compressed_cache": save_path,
|
| 515 |
"compressed_length": compressed_length,
|
| 516 |
"rag_index": collection_name,
|
| 517 |
"target_token_size": target_token_size,
|
|
|
|
| 532 |
Returns a simple string (not a list of message dicts) for ChatInterface.
|
| 533 |
"""
|
| 534 |
user_message = message
|
| 535 |
+
save_path = state["compressed_cache"]
|
| 536 |
+
past_key_values = FinchCache.load(save_path, device=model.device)
|
| 537 |
+
try:
|
| 538 |
+
os.remove(save_path)
|
| 539 |
+
except Exception as e:
|
| 540 |
+
print(f"Error removing cache file: {e}")
|
| 541 |
compressed_length = past_key_values.get_seq_length()
|
| 542 |
collection_name = state["rag_index"]
|
| 543 |
retrieval_slider_value = state["retrieval_slider"]
|
chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/data_level0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95042e844cfb77b20e578cf65635282a99d7c4dd20e589ac062f38bc389f8e58
|
| 3 |
+
size 4236000
|
chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/header.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fcc596bc1909f7cc610d5839236c90513b4fbad06776c253fa1b21bfd712e940
|
| 3 |
+
size 100
|
chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/length.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6e902f1c1fadd234656c661646122d8f7fd9dcf9988b046a0e5b7be886e77c29
|
| 3 |
+
size 4000
|
chroma_db/0f6ffa1c-1cc6-4993-bdb7-4bf497c593bb/link_lists.bin
ADDED
|
File without changes
|
chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/data_level0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95042e844cfb77b20e578cf65635282a99d7c4dd20e589ac062f38bc389f8e58
|
| 3 |
+
size 4236000
|
chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/header.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fcc596bc1909f7cc610d5839236c90513b4fbad06776c253fa1b21bfd712e940
|
| 3 |
+
size 100
|
chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/length.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:707925f820f4e8cba99037d1116d2601037be2b1a92a68df99cb47393c6a8616
|
| 3 |
+
size 4000
|
chroma_db/9f7c3d0f-8107-441e-9db6-b53a36071e34/link_lists.bin
ADDED
|
File without changes
|