-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to load memories into the vector DB *enhancement* #20
Comments
Thanks, I tried this, and It works, I modified it for separating at triple lines instead. I named this script (It will split the segment right before "I just compiled")
import re
import json
import pathlib
from extensions.long_term_memory.core.memory_database import LtmDatabase
# === Internal constants (don't change these without good reason) ===
_CONFIG_PATH = "./extensions/long_term_memory/ltm_config.json"
_MIN_ROWS_TILL_RESPONSE = 5
_LAST_BOT_MESSAGE_INDEX = -3
_LTM_STATS_TEMPLATE = """{num_memories_seen_by_bot} memories are loaded in the bot
{num_memories_in_ram} memories are loaded in RAM
{num_memories_on_disk} memories are saved to disk"""
with open(_CONFIG_PATH, "rt") as handle:
_CONFIG = json.load(handle)
memory_database = LtmDatabase(
pathlib.Path("./extensions/long_term_memory/user_data/bot_memories/"),
num_memories_to_fetch=_CONFIG["ltm_reads"]["num_memories_to_fetch"],
)
with open('Text.txt', 'r', encoding='utf-8') as file:
paragraphs = file.read().split('\n\n') # Split by triple newline
for paragraph in paragraphs:
paragraph = paragraph.strip() # stripping leading/trailing whitespace
pattern = r'[^\w\s;-]' # Remove problematic characters using regular expression # .,!?
paragraph = re.sub(pattern, '', paragraph)
if not paragraph: # Skip empty paragraphs
continue
memory_database.add("Assistant", paragraph)
print("num_memories_on_disk:", memory_database.disk_embeddings.shape[0]) I used the one click installer, so I entered the enviornment with
Hope this is helpful, you can then verify that the 0.0 binary embedding file has increased in size, and your .db file has new raw text added, by using an online viewer like https://sqliteviewer.app/ to view if your text has separated properly. |
I just lunch "cmd_linux.sh" with terminal, and cd text-generation-webui and python convert2vectorDB.py. It's works perfectly! |
I am wondering, would it be possible with windows? and how would you go about doing it? My apologies as this is my first time with this! |
I wrote a quick script to load memories into the vector DB.
The text was updated successfully, but these errors were encountered: