Skip to content

Commit

Permalink
Edit main device _type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoudkhorshed-Queens committed May 20, 2024
1 parent 521dd71 commit 3c6c222
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
7 changes: 6 additions & 1 deletion ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def load_faiss_index(index_path, metadata_path):


def main(device_type):
print(f"Running on device: {device_type}")
# Load documents and split in chunks
logging.info(f"Loading documents from {SOURCE_DIRECTORY}")
documents = load_documents(SOURCE_DIRECTORY)
Expand Down Expand Up @@ -224,9 +225,13 @@ def main(device_type):
client_settings=CHROMA_SETTINGS,
)

import argparse

if __name__ == "__main__":
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(filename)s:%(lineno)s - %(message)s", level=logging.INFO
)
main()
parser = argparse.ArgumentParser(description="Ingest script for localGPT")
parser.add_argument("--device_type", type=str, required=True, help="Device type (cpu or gpu)")
args = parser.parse_args()
main(args.device_type)
23 changes: 14 additions & 9 deletions run_localGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,24 @@ def retrieval_qa_pipline(device_type, use_history, promptTemplate_type="llama"):
# embedding_function=embeddings,
# client_settings=CHROMA_SETTINGS)

# print(embeddings)

# Initialize the FAISS index
# faiss_index = faiss.IndexFlatL2(embeddings)
faiss_index = faiss.IndexFlatL2(embeddings.embed())

# # Initialize the docstore
# docstore = InMemoryDocstore()
docstore = InMemoryDocstore()
# # Initialize the index_to_docstore_id
# index_to_docstore_id = {}
index_to_docstore_id = {}
# Add the embeddings to the index
faiss_index.add(embeddings)

# db = FAISS(
# embedding_function=embeddings,
# index=faiss_index,
# docstore=docstore,
# index_to_docstore_id=index_to_docstore_id
# )
db = FAISS(
embedding_function=embeddings,
index=faiss_index,
docstore=docstore,
index_to_docstore_id=index_to_docstore_id
)

# # Add documents and their embeddings to the FAISS index and the docstore
# for i, (text, embedding) in enumerate(zip(df['Text'].tolist(), embeddings)):
Expand Down

0 comments on commit 3c6c222

Please sign in to comment.