-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified the Structure of the project
- Loading branch information
Showing
29 changed files
with
571 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.env | ||
FlagEmbedding-1.2.10/ | ||
rag/ | ||
testing.py | ||
t.py | ||
s.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from langchain_community.vectorstores import Chroma | ||
from langchain.text_splitter import RecursiveCharacterTextSplitter | ||
from langchain_community.document_loaders import PyPDFDirectoryLoader | ||
from langchain.schema.document import Document | ||
import os | ||
from src.data_processing.get_embeddings import get_embeddings | ||
from dotenv import load_dotenv | ||
|
||
|
||
load_dotenv() | ||
|
||
""" | ||
Initializating the APIs and setting up the environment variables | ||
""" | ||
|
||
api_key = os.getenv("COHERE_API_KEY") | ||
|
||
CHROMA_PATH = "data/processed/chroma" | ||
DATA_PATH = "data" | ||
|
||
|
||
def load_documents(): | ||
document_loader = PyPDFDirectoryLoader("data/") | ||
print("Loading documents...") | ||
return document_loader.load() | ||
|
||
|
||
def split_documents(documents): | ||
text_splitter = RecursiveCharacterTextSplitter( | ||
chunk_size=500, | ||
chunk_overlap=100, | ||
length_function=len, | ||
is_separator_regex=False, | ||
) | ||
docs = [] | ||
print("Splitting documents...") | ||
for document in documents: | ||
for chunk in text_splitter.split_text(document.page_content): | ||
docs.append(Document(page_content=chunk, metadata={"source": document.metadata["source"]})) | ||
print("Documents split successfully.") | ||
return docs | ||
|
||
|
||
def embed_and_store_documents(chunks): | ||
chroma_db = Chroma( | ||
persist_directory=CHROMA_PATH, embedding_function=get_embeddings() | ||
) | ||
print("Storing documents...") | ||
chroma_db.add_documents(chunks, persist_directory=CHROMA_PATH,embeddings=get_embeddings()) | ||
chroma_db.persist() | ||
print("Documents stored successfully.") | ||
|
File renamed without changes.
File renamed without changes.
Binary file renamed
BIN
+3.91 KB
...b4-2400-4375-8363-fca32070ff78/length.bin → ...0f-70b1-487f-afee-13fec0ce30f7/length.bin
Binary file not shown.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.