Spaces:
Build error
Build error
improvements
Browse files- Dockerfile +1 -1
- code/config.yml +1 -1
- code/modules/embedding_model_loader.py +4 -1
- code/modules/helpers.py +4 -1
- code/modules/vector_db.py +12 -6
Dockerfile
CHANGED
|
@@ -26,4 +26,4 @@ RUN mkdir /.cache && chmod -R 777 /.cache
|
|
| 26 |
RUN --mount=type=secret,id=HUGGINGFACEHUB_API_TOKEN,mode=0444,required=true
|
| 27 |
RUN --mount=type=secret,id=OPENAI_API_KEY,mode=0444,required=true
|
| 28 |
|
| 29 |
-
CMD
|
|
|
|
| 26 |
RUN --mount=type=secret,id=HUGGINGFACEHUB_API_TOKEN,mode=0444,required=true
|
| 27 |
RUN --mount=type=secret,id=OPENAI_API_KEY,mode=0444,required=true
|
| 28 |
|
| 29 |
+
CMD python code/modules/vector_db.py && chainlit run code/main.py --host 0.0.0.0 --port 7860
|
code/config.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
embedding_options:
|
| 2 |
-
embedd_files:
|
| 3 |
persist_directory: null # str or None
|
| 4 |
data_path: 'storage/data' # str
|
| 5 |
url_file_path: 'storage/data/urls.txt' # str
|
|
|
|
| 1 |
embedding_options:
|
| 2 |
+
embedd_files: False # bool
|
| 3 |
persist_directory: null # str or None
|
| 4 |
data_path: 'storage/data' # str
|
| 5 |
url_file_path: 'storage/data/urls.txt' # str
|
code/modules/embedding_model_loader.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
from langchain_community.embeddings import OpenAIEmbeddings
|
| 2 |
from langchain.embeddings import HuggingFaceEmbeddings
|
| 3 |
from langchain.embeddings import LlamaCppEmbeddings
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
|
|
|
|
| 1 |
from langchain_community.embeddings import OpenAIEmbeddings
|
| 2 |
from langchain.embeddings import HuggingFaceEmbeddings
|
| 3 |
from langchain.embeddings import LlamaCppEmbeddings
|
| 4 |
+
try:
|
| 5 |
+
from modules.constants import *
|
| 6 |
+
except:
|
| 7 |
+
from constants import *
|
| 8 |
import os
|
| 9 |
|
| 10 |
|
code/modules/helpers.py
CHANGED
|
@@ -4,7 +4,10 @@ from tqdm import tqdm
|
|
| 4 |
from urllib.parse import urlparse
|
| 5 |
import chainlit as cl
|
| 6 |
from langchain import PromptTemplate
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
"""
|
| 10 |
Ref: https://python.plainenglish.io/scraping-the-subpages-on-a-website-ea2d4e3db113
|
|
|
|
| 4 |
from urllib.parse import urlparse
|
| 5 |
import chainlit as cl
|
| 6 |
from langchain import PromptTemplate
|
| 7 |
+
try:
|
| 8 |
+
from modules.constants import *
|
| 9 |
+
except:
|
| 10 |
+
from constants import *
|
| 11 |
|
| 12 |
"""
|
| 13 |
Ref: https://python.plainenglish.io/scraping-the-subpages-on-a-website-ea2d4e3db113
|
code/modules/vector_db.py
CHANGED
|
@@ -1,12 +1,18 @@
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
import yaml
|
| 4 |
-
|
| 5 |
-
from modules.embedding_model_loader import EmbeddingModelLoader
|
| 6 |
from langchain.vectorstores import FAISS
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
from modules.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
class VectorDB:
|
|
@@ -108,7 +114,7 @@ class VectorDB:
|
|
| 108 |
|
| 109 |
|
| 110 |
if __name__ == "__main__":
|
| 111 |
-
with open("config.yml", "r") as f:
|
| 112 |
config = yaml.safe_load(f)
|
| 113 |
print(config)
|
| 114 |
vector_db = VectorDB(config)
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
import yaml
|
|
|
|
|
|
|
| 4 |
from langchain.vectorstores import FAISS
|
| 5 |
+
|
| 6 |
+
try:
|
| 7 |
+
from modules.embedding_model_loader import EmbeddingModelLoader
|
| 8 |
+
from modules.data_loader import DataLoader
|
| 9 |
+
from modules.constants import *
|
| 10 |
+
from modules.helpers import *
|
| 11 |
+
except:
|
| 12 |
+
from embedding_model_loader import EmbeddingModelLoader
|
| 13 |
+
from data_loader import DataLoader
|
| 14 |
+
from constants import *
|
| 15 |
+
from helpers import *
|
| 16 |
|
| 17 |
|
| 18 |
class VectorDB:
|
|
|
|
| 114 |
|
| 115 |
|
| 116 |
if __name__ == "__main__":
|
| 117 |
+
with open("code/config.yml", "r") as f:
|
| 118 |
config = yaml.safe_load(f)
|
| 119 |
print(config)
|
| 120 |
vector_db = VectorDB(config)
|