Skip to content
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

updating readme for table_create and llama_selector #83

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ai_course_bot/ai-chatbot-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
3. run server `python main.py`

### Configure SQLite Support
1. To enable SQLite support, please set `SQLDB = True` in `ai_course_bot/ai-chatbot-backend/app/core/actions/llama_seletor.py`
1. Download the appropriate `vector0.dylib` and `vss0.dylib` for your machine's hardware from https://github.com/asg017/sqlite-vss/releases. Place `vector0.dylib` and `vss0.dylib` files into the `ai_course_bot/ai-chatbot-backend/app/core/actions/dist/debug` directory.

2. Download the appropriate `vector0.dylib` and `vss0.dylib` for your machine's hardware from https://github.com/asg017/sqlite-vss/releases.
2. To enable SQLite support, please set `SQLDB = True` in `ai_course_bot/ai-chatbot-backend/app/core/actions/llama_seletor.py`

3. Place `vector0.dylib` and `vss0.dylib` files into the `rag/file_conversion_router/embedding/dist/debug` directory.
3. Make sure `current_dir` under `func llama_selector` is set to the correct file path

4. Running python ai_course_bot/ai-chatbot-backend/main.py and launch http://0.0.0.0:8000 in prefered browser
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def local_selector(messages:List[Message],stream=True,rag=True,course=None):
picklefile = "cs61a.pkl"
else:
picklefile = "Berkeley.pkl"
current_dir = "/home/roar-tai-1/charles/roarai/rag/file_conversion_router/embedding"
current_dir = "roarai/rag/file_conversion_router/embedding" # Modify this path to the directory containing the embedding pickle files
query_embed = embedding_model.encode(user_message, return_dense=True, return_sparse=True,
return_colbert_vecs=True)
if SQLDB:
Expand Down
7 changes: 7 additions & 0 deletions rag/file_conversion_router/embedding/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Configure SQLite Support

1. Download the appropriate `vector0.dylib` and `vss0.dylib` for your machine's hardware from https://github.com/asg017/sqlite-vss/releases. Place `vector0.dylib` and `vss0.dylib` files into the `rag/file_conversion_router/embedding/dist/debug` directory.

2. Ensure that `DIRECTORY_PATH` points to the correct directory containing the necessary pickle file.

3. Running `python rag/file_conversion_router/embedding/table_create.py` will create `embeddings.db` and `[picklefile_name].db` under the current running directory.
14 changes: 7 additions & 7 deletions rag/file_conversion_router/embedding/table_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
EXT_VSS_PATH = "rag/file_conversion_router/embedding/dist/debug/vss0"
BGE = True

# Modify this path to the directory containing the embedding pickle files and the database
DIRECTORY_PATH = 'roarai/rag/file_conversion_router/embedding'

# Connect to the SQLite database and load extensions
def connect(path=":memory:"):
Expand Down Expand Up @@ -77,9 +79,8 @@ def get_structure_debug(pickle_data):


def create_embedding_table(pickle_data):
directory_path = '/home/roar-tai-1/charles/roarai/rag/file_conversion_router/embedding'
os.makedirs(directory_path, exist_ok=True)
db_path = os.path.join(directory_path, 'embeddings.db')
os.makedirs(DIRECTORY_PATH, exist_ok=True)
db_path = os.path.join(DIRECTORY_PATH, 'embeddings.db')
db = connect(db_path)
print(db_path)
cur = db.cursor()
Expand Down Expand Up @@ -136,9 +137,8 @@ def create_main_table(filename, pickle_data):
else:
raise ValueError("The provided file does not have a .pkl extension")

directory_path = '/home/roar-tai-1/charles/roarai/rag/file_conversion_router/embedding'
os.makedirs(directory_path, exist_ok=True)
db_path = os.path.join(directory_path, database_name)
os.makedirs(DIRECTORY_PATH, exist_ok=True)
db_path = os.path.join(DIRECTORY_PATH, database_name)
print(db_path)
db = sqlite3.connect(db_path)
cur = db.cursor()
Expand Down Expand Up @@ -183,7 +183,7 @@ def create_main_table(filename, pickle_data):
def main():
ee106b = "rag/file_conversion_router/embedding/eecs106b.pkl"
path_to_pickle = ee106b
# path_to_pickle = "rag/file_conversion_router/embedding/cs61a_7_24.pkl"
# path_to_pickle = "rag/file_conversion_router/embedding/cs61a.pkl"

with open(path_to_pickle, 'rb') as f:
data_loaded = pickle.load(f)
Expand Down
Loading