Spaces:
Running
on
Zero
Running
on
Zero
jedick
commited on
Commit
·
f6e2d8a
1
Parent(s):
7320bf1
Download data during app startup
Browse files- app.py +24 -150
- data.py +59 -0
- retriever.py +5 -2
app.py
CHANGED
|
@@ -1,37 +1,42 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from main import GetChatModel, openai_model, model_id
|
| 3 |
-
from graph import BuildGraph
|
| 4 |
-
from retriever import db_dir
|
| 5 |
-
from util import get_sources, get_start_end_months
|
| 6 |
-
from mods.tool_calling_llm import extract_think
|
| 7 |
-
from huggingface_hub import snapshot_download
|
| 8 |
from langgraph.checkpoint.memory import MemorySaver
|
|
|
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
-
import
|
| 11 |
-
import zipfile
|
| 12 |
-
import shutil
|
| 13 |
import spaces
|
| 14 |
import torch
|
| 15 |
-
|
| 16 |
-
import boto3
|
| 17 |
import uuid
|
| 18 |
import ast
|
| 19 |
import os
|
| 20 |
import re
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Setup environment variables
|
| 23 |
load_dotenv(dotenv_path=".env", override=True)
|
| 24 |
|
| 25 |
# Download model snapshots from Hugging Face Hub
|
| 26 |
-
print(f"Downloading
|
| 27 |
ckpt_dir = snapshot_download(model_id, local_dir_use_symlinks=False)
|
| 28 |
print(f"Using checkpoints from {ckpt_dir}")
|
| 29 |
-
|
| 30 |
-
embedding_model_id = "nomic-ai/nomic-embed-text-v1.5"
|
| 31 |
-
print(f"Downloading/loading checkpoints for {embedding_model_id}...")
|
| 32 |
embedding_ckpt_dir = snapshot_download(embedding_model_id, local_dir_use_symlinks=False)
|
| 33 |
print(f"Using embedding checkpoints from {embedding_ckpt_dir}")
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Global setting for search type
|
| 36 |
search_type = "hybrid"
|
| 37 |
|
|
@@ -39,7 +44,6 @@ search_type = "hybrid"
|
|
| 39 |
# https://www.gradio.app/guides/state-in-blocks
|
| 40 |
graph_instances = {"local": {}, "remote": {}}
|
| 41 |
|
| 42 |
-
|
| 43 |
def cleanup_graph(request: gr.Request):
|
| 44 |
if request.session_hash in graph_instances["local"]:
|
| 45 |
del graph_instances["local"][request.session_hash]
|
|
@@ -91,7 +95,7 @@ def run_workflow(input, history, compute_mode, thread_id, session_hash):
|
|
| 91 |
if compute_mode == "local":
|
| 92 |
gr.Info(
|
| 93 |
f"Please wait for the local model to load",
|
| 94 |
-
duration=
|
| 95 |
title=f"Model loading...",
|
| 96 |
)
|
| 97 |
# Get the chat model and build the graph
|
|
@@ -399,7 +403,7 @@ with gr.Blocks(
|
|
| 399 |
🧠 Thinking is enabled for the answer<br>
|
| 400 |
  🔍 Add **/think** to enable thinking for the query</br>
|
| 401 |
  🚫 Add **/no_think** to disable all thinking</br>
|
| 402 |
-
✨ [
|
| 403 |
🏠 See the project's [GitHub repository](https://github.com/jedick/R-help-chat)
|
| 404 |
"""
|
| 405 |
return status_text
|
|
@@ -459,7 +463,7 @@ with gr.Blocks(
|
|
| 459 |
intro = gr.Markdown(get_intro_text())
|
| 460 |
with gr.Column(scale=1):
|
| 461 |
compute_mode.render()
|
| 462 |
-
with gr.Group(
|
| 463 |
chatbot.render()
|
| 464 |
input.render()
|
| 465 |
# Render textboxes for data loading progress
|
|
@@ -626,136 +630,6 @@ with gr.Blocks(
|
|
| 626 |
api_name=False,
|
| 627 |
)
|
| 628 |
|
| 629 |
-
# ------------
|
| 630 |
-
# Data loading
|
| 631 |
-
# ------------
|
| 632 |
-
|
| 633 |
-
def download():
|
| 634 |
-
"""Download the application data"""
|
| 635 |
-
|
| 636 |
-
def download_file_from_bucket(bucket_name, s3_key, output_file):
|
| 637 |
-
"""Download file from S3 bucket"""
|
| 638 |
-
|
| 639 |
-
# https://thecodinginterface.com/blog/aws-s3-python-boto3
|
| 640 |
-
session = boto3.session.Session(
|
| 641 |
-
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
|
| 642 |
-
aws_secret_access_key=os.getenv("AWS_ACCESS_KEY_SECRET"),
|
| 643 |
-
region_name="us-east-1",
|
| 644 |
-
)
|
| 645 |
-
s3_resource = session.resource("s3")
|
| 646 |
-
bucket = s3_resource.Bucket(bucket_name)
|
| 647 |
-
bucket.download_file(Key=s3_key, Filename=output_file)
|
| 648 |
-
|
| 649 |
-
def download_dropbox_file(shared_url, output_file):
|
| 650 |
-
"""Download file from Dropbox"""
|
| 651 |
-
|
| 652 |
-
# Modify the shared URL to enable direct download
|
| 653 |
-
direct_url = shared_url.replace(
|
| 654 |
-
"www.dropbox.com", "dl.dropboxusercontent.com"
|
| 655 |
-
).replace("?dl=0", "")
|
| 656 |
-
|
| 657 |
-
# Send a GET request to the direct URL
|
| 658 |
-
response = requests.get(direct_url, stream=True)
|
| 659 |
-
|
| 660 |
-
if response.status_code == 200:
|
| 661 |
-
# Write the content to a local file
|
| 662 |
-
with open(output_file, "wb") as file:
|
| 663 |
-
for chunk in response.iter_content(chunk_size=8192):
|
| 664 |
-
file.write(chunk)
|
| 665 |
-
print(f"File downloaded successfully as '{output_file}'")
|
| 666 |
-
else:
|
| 667 |
-
print(
|
| 668 |
-
f"Failed to download file. HTTP Status Code: {response.status_code}"
|
| 669 |
-
)
|
| 670 |
-
|
| 671 |
-
if not os.path.isdir(db_dir) and not os.path.exists("db.zip"):
|
| 672 |
-
# For S3 (need AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_SECRET)
|
| 673 |
-
download_file_from_bucket("r-help-chat", "db.zip", "db.zip")
|
| 674 |
-
## For Dropbox (shared file - key is in URL)
|
| 675 |
-
# shared_link = "https://www.dropbox.com/scl/fi/jx90g5lorpgkkyyzeurtc/db.zip?rlkey=wvqa3p9hdy4rmod1r8yf2am09&st=l9tsam56&dl=0"
|
| 676 |
-
# output_filename = "db.zip"
|
| 677 |
-
# download_dropbox_file(shared_link, output_filename)
|
| 678 |
-
|
| 679 |
-
def extract():
|
| 680 |
-
"""Extract the db.zip file"""
|
| 681 |
-
|
| 682 |
-
if not os.path.isdir(db_dir):
|
| 683 |
-
|
| 684 |
-
file_path = "db.zip"
|
| 685 |
-
extract_to_path = "./"
|
| 686 |
-
try:
|
| 687 |
-
with zipfile.ZipFile(file_path, "r") as zip_ref:
|
| 688 |
-
zip_ref.extractall(extract_to_path)
|
| 689 |
-
except:
|
| 690 |
-
# If there were any errors, remove zip file and db directory
|
| 691 |
-
# to initiate a new download when app is reloaded
|
| 692 |
-
|
| 693 |
-
try:
|
| 694 |
-
os.remove(file_path)
|
| 695 |
-
print(f"{file_path} has been deleted.")
|
| 696 |
-
except FileNotFoundError:
|
| 697 |
-
print(f"{file_path} does not exist.")
|
| 698 |
-
except PermissionError:
|
| 699 |
-
print(f"Permission denied to delete {file_path}.")
|
| 700 |
-
except Exception as e:
|
| 701 |
-
print(f"An error occurred: {e}")
|
| 702 |
-
|
| 703 |
-
directory_path = "./db"
|
| 704 |
-
|
| 705 |
-
try:
|
| 706 |
-
# Forcefully and recursively delete a directory, like rm -rf
|
| 707 |
-
shutil.rmtree(directory_path)
|
| 708 |
-
print(f"Successfully deleted: {directory_path}")
|
| 709 |
-
except FileNotFoundError:
|
| 710 |
-
print(f"Directory not found: {directory_path}")
|
| 711 |
-
except PermissionError:
|
| 712 |
-
print(f"Permission denied: {directory_path}")
|
| 713 |
-
except Exception as e:
|
| 714 |
-
print(f"An error occurred: {e}")
|
| 715 |
-
|
| 716 |
-
def visible_if_data_present():
|
| 717 |
-
"""Make component visible if the database directory is present"""
|
| 718 |
-
visible = os.path.isdir(db_dir)
|
| 719 |
-
return change_visibility(visible)
|
| 720 |
-
|
| 721 |
-
def visible_if_data_missing():
|
| 722 |
-
"""Make component visible if the database directory is missing"""
|
| 723 |
-
visible = not os.path.isdir(db_dir)
|
| 724 |
-
return change_visibility(visible)
|
| 725 |
-
|
| 726 |
-
false = gr.State(False)
|
| 727 |
-
true = gr.State(True)
|
| 728 |
-
|
| 729 |
-
# When app is launched: show "Loading Data" textbox, download and extract
|
| 730 |
-
# data if necessary, make chat interface visible or show error textbox, and
|
| 731 |
-
# update database info
|
| 732 |
-
|
| 733 |
-
# fmt: off
|
| 734 |
-
demo.load(
|
| 735 |
-
change_visibility, [true], [loading_data], api_name=False
|
| 736 |
-
).then(
|
| 737 |
-
visible_if_data_missing, None, [downloading], api_name=False
|
| 738 |
-
).then(
|
| 739 |
-
download, None, [downloading], api_name=False
|
| 740 |
-
).then(
|
| 741 |
-
change_visibility, [false], [downloading], api_name=False
|
| 742 |
-
).then(
|
| 743 |
-
visible_if_data_missing, None, [extracting], api_name=False
|
| 744 |
-
).then(
|
| 745 |
-
extract, None, [extracting], api_name=False
|
| 746 |
-
).then(
|
| 747 |
-
change_visibility, [false], [extracting], api_name=False
|
| 748 |
-
).then(
|
| 749 |
-
change_visibility, [false], [loading_data], api_name=False
|
| 750 |
-
).then(
|
| 751 |
-
visible_if_data_present, None, [chat_interface], api_name=False
|
| 752 |
-
).then(
|
| 753 |
-
visible_if_data_missing, None, [missing_data], api_name=False
|
| 754 |
-
).then(
|
| 755 |
-
get_info_text, None, [info], api_name=False
|
| 756 |
-
)
|
| 757 |
-
# fmt: on
|
| 758 |
-
|
| 759 |
# Clean up graph instances when page is closed/refreshed
|
| 760 |
demo.unload(cleanup_graph)
|
| 761 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from langgraph.checkpoint.memory import MemorySaver
|
| 2 |
+
from huggingface_hub import snapshot_download
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
+
import gradio as gr
|
|
|
|
|
|
|
| 5 |
import spaces
|
| 6 |
import torch
|
|
|
|
|
|
|
| 7 |
import uuid
|
| 8 |
import ast
|
| 9 |
import os
|
| 10 |
import re
|
| 11 |
|
| 12 |
+
# Local modules
|
| 13 |
+
from main import GetChatModel, openai_model, model_id
|
| 14 |
+
from util import get_sources, get_start_end_months
|
| 15 |
+
from retriever import db_dir, embedding_model_id
|
| 16 |
+
from mods.tool_calling_llm import extract_think
|
| 17 |
+
from data import download_data, extract_data
|
| 18 |
+
from graph import BuildGraph
|
| 19 |
+
|
| 20 |
# Setup environment variables
|
| 21 |
load_dotenv(dotenv_path=".env", override=True)
|
| 22 |
|
| 23 |
# Download model snapshots from Hugging Face Hub
|
| 24 |
+
print(f"Downloading checkpoints for {model_id}...")
|
| 25 |
ckpt_dir = snapshot_download(model_id, local_dir_use_symlinks=False)
|
| 26 |
print(f"Using checkpoints from {ckpt_dir}")
|
| 27 |
+
print(f"Downloading checkpoints for {embedding_model_id}...")
|
|
|
|
|
|
|
| 28 |
embedding_ckpt_dir = snapshot_download(embedding_model_id, local_dir_use_symlinks=False)
|
| 29 |
print(f"Using embedding checkpoints from {embedding_ckpt_dir}")
|
| 30 |
|
| 31 |
+
# Download and extract data if data directory is not present
|
| 32 |
+
if not os.path.isdir(db_dir):
|
| 33 |
+
print("Downloading data ... ", end = "")
|
| 34 |
+
download_data()
|
| 35 |
+
print("done!")
|
| 36 |
+
print("Extracting data ... ", end = "")
|
| 37 |
+
extract_data()
|
| 38 |
+
print("done!")
|
| 39 |
+
|
| 40 |
# Global setting for search type
|
| 41 |
search_type = "hybrid"
|
| 42 |
|
|
|
|
| 44 |
# https://www.gradio.app/guides/state-in-blocks
|
| 45 |
graph_instances = {"local": {}, "remote": {}}
|
| 46 |
|
|
|
|
| 47 |
def cleanup_graph(request: gr.Request):
|
| 48 |
if request.session_hash in graph_instances["local"]:
|
| 49 |
del graph_instances["local"][request.session_hash]
|
|
|
|
| 95 |
if compute_mode == "local":
|
| 96 |
gr.Info(
|
| 97 |
f"Please wait for the local model to load",
|
| 98 |
+
duration=8,
|
| 99 |
title=f"Model loading...",
|
| 100 |
)
|
| 101 |
# Get the chat model and build the graph
|
|
|
|
| 403 |
🧠 Thinking is enabled for the answer<br>
|
| 404 |
  🔍 Add **/think** to enable thinking for the query</br>
|
| 405 |
  🚫 Add **/no_think** to disable all thinking</br>
|
| 406 |
+
✨ [{embedding_model_id.split("/")[-1]}](https://huggingface.co/{embedding_model_id}) and [{model_id.split("/")[-1]}](https://huggingface.co/{model_id})<br>
|
| 407 |
🏠 See the project's [GitHub repository](https://github.com/jedick/R-help-chat)
|
| 408 |
"""
|
| 409 |
return status_text
|
|
|
|
| 463 |
intro = gr.Markdown(get_intro_text())
|
| 464 |
with gr.Column(scale=1):
|
| 465 |
compute_mode.render()
|
| 466 |
+
with gr.Group() as chat_interface:
|
| 467 |
chatbot.render()
|
| 468 |
input.render()
|
| 469 |
# Render textboxes for data loading progress
|
|
|
|
| 630 |
api_name=False,
|
| 631 |
)
|
| 632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
# Clean up graph instances when page is closed/refreshed
|
| 634 |
demo.unload(cleanup_graph)
|
| 635 |
|
data.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import zipfile
|
| 3 |
+
import shutil
|
| 4 |
+
import boto3
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
def download_file_from_bucket(bucket_name, s3_key, output_file):
|
| 8 |
+
"""Download file from S3 bucket"""
|
| 9 |
+
|
| 10 |
+
# https://thecodinginterface.com/blog/aws-s3-python-boto3
|
| 11 |
+
session = boto3.session.Session(
|
| 12 |
+
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
|
| 13 |
+
aws_secret_access_key=os.getenv("AWS_ACCESS_KEY_SECRET"),
|
| 14 |
+
region_name="us-east-1",
|
| 15 |
+
)
|
| 16 |
+
s3_resource = session.resource("s3")
|
| 17 |
+
bucket = s3_resource.Bucket(bucket_name)
|
| 18 |
+
bucket.download_file(Key=s3_key, Filename=output_file)
|
| 19 |
+
|
| 20 |
+
def download_dropbox_file(shared_url, output_file):
|
| 21 |
+
"""Download file from Dropbox"""
|
| 22 |
+
|
| 23 |
+
# Modify the shared URL to enable direct download
|
| 24 |
+
direct_url = shared_url.replace(
|
| 25 |
+
"www.dropbox.com", "dl.dropboxusercontent.com"
|
| 26 |
+
).replace("?dl=0", "")
|
| 27 |
+
|
| 28 |
+
# Send a GET request to the direct URL
|
| 29 |
+
response = requests.get(direct_url, stream=True)
|
| 30 |
+
|
| 31 |
+
if response.status_code == 200:
|
| 32 |
+
# Write the content to a local file
|
| 33 |
+
with open(output_file, "wb") as file:
|
| 34 |
+
for chunk in response.iter_content(chunk_size=8192):
|
| 35 |
+
file.write(chunk)
|
| 36 |
+
print(f"File downloaded successfully as '{output_file}'")
|
| 37 |
+
else:
|
| 38 |
+
print(
|
| 39 |
+
f"Failed to download file. HTTP Status Code: {response.status_code}"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
def download_data():
|
| 43 |
+
"""Download the email database"""
|
| 44 |
+
|
| 45 |
+
if not os.path.exists("db.zip"):
|
| 46 |
+
# For S3 (need AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_SECRET)
|
| 47 |
+
download_file_from_bucket("r-help-chat", "db.zip", "db.zip")
|
| 48 |
+
## For Dropbox (shared file - key is in URL)
|
| 49 |
+
# shared_link = "https://www.dropbox.com/scl/fi/jx90g5lorpgkkyyzeurtc/db.zip?rlkey=wvqa3p9hdy4rmod1r8yf2am09&st=l9tsam56&dl=0"
|
| 50 |
+
# output_filename = "db.zip"
|
| 51 |
+
# download_dropbox_file(shared_link, output_filename)
|
| 52 |
+
|
| 53 |
+
def extract_data():
|
| 54 |
+
"""Extract the db.zip file"""
|
| 55 |
+
|
| 56 |
+
file_path = "db.zip"
|
| 57 |
+
extract_to_path = "./"
|
| 58 |
+
with zipfile.ZipFile(file_path, "r") as zip_ref:
|
| 59 |
+
zip_ref.extractall(extract_to_path)
|
retriever.py
CHANGED
|
@@ -29,6 +29,9 @@ from mods.file_system import LocalFileStore
|
|
| 29 |
# Database directory
|
| 30 |
db_dir = "db"
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
def BuildRetriever(
|
| 34 |
compute_mode,
|
|
@@ -145,13 +148,13 @@ def BuildRetrieverDense(compute_mode: str, top_k=6, embedding_ckpt_dir=None):
|
|
| 145 |
if compute_mode == "local":
|
| 146 |
# embedding_function = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en-v1.5", show_progress=True)
|
| 147 |
# https://python.langchain.com/api_reference/community/embeddings/langchain_community.embeddings.huggingface.HuggingFaceBgeEmbeddings.html
|
| 148 |
-
model_name = "nomic-ai/nomic-embed-text-v1.5"
|
| 149 |
-
id_or_dir = embedding_ckpt_dir if embedding_ckpt_dir else model_name
|
| 150 |
model_kwargs = {
|
| 151 |
"device": "cuda",
|
| 152 |
"trust_remote_code": True,
|
| 153 |
}
|
| 154 |
encode_kwargs = {"normalize_embeddings": True}
|
|
|
|
|
|
|
| 155 |
embedding_function = HuggingFaceBgeEmbeddings(
|
| 156 |
model_name=id_or_dir,
|
| 157 |
model_kwargs=model_kwargs,
|
|
|
|
| 29 |
# Database directory
|
| 30 |
db_dir = "db"
|
| 31 |
|
| 32 |
+
# Embedding model
|
| 33 |
+
embedding_model_id = "nomic-ai/nomic-embed-text-v1.5"
|
| 34 |
+
|
| 35 |
|
| 36 |
def BuildRetriever(
|
| 37 |
compute_mode,
|
|
|
|
| 148 |
if compute_mode == "local":
|
| 149 |
# embedding_function = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en-v1.5", show_progress=True)
|
| 150 |
# https://python.langchain.com/api_reference/community/embeddings/langchain_community.embeddings.huggingface.HuggingFaceBgeEmbeddings.html
|
|
|
|
|
|
|
| 151 |
model_kwargs = {
|
| 152 |
"device": "cuda",
|
| 153 |
"trust_remote_code": True,
|
| 154 |
}
|
| 155 |
encode_kwargs = {"normalize_embeddings": True}
|
| 156 |
+
# Use embedding model ID or checkpoint directory if given
|
| 157 |
+
id_or_dir = embedding_ckpt_dir if embedding_ckpt_dir else embedding_model_id
|
| 158 |
embedding_function = HuggingFaceBgeEmbeddings(
|
| 159 |
model_name=id_or_dir,
|
| 160 |
model_kwargs=model_kwargs,
|