-
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.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from langchain.document_loaders import PyPDFLoader | ||
from langchain.text_splitter import RecursiveCharacterTextSplitter | ||
from langchain.embeddings import SentenceTransformerEmbeddings #HuggingFaceInstructEmbeddings | ||
from langchain.vectorstores import FAISS | ||
import os | ||
import copy | ||
import time | ||
import pprint | ||
#import google.generativeai as palm | ||
from langchain.llms import GooglePalm | ||
from langchain import PromptTemplate | ||
from langchain.chains import RetrievalQA | ||
|
||
import streamlit | ||
import streamlit.web.cli as stcli | ||
|
||
import os,sys | ||
import subprocess | ||
import sentence_transformers | ||
import nltk | ||
import warnings | ||
warnings.filterwarnings("ignore") | ||
|
||
def resolve_path(path): | ||
resolved_path = os.path.abspath(os.path.join(os.getcwd(), path)) | ||
return resolved_path | ||
|
||
|
||
|
||
while True: | ||
choice=input(f"{'>>'*10} \n Choose : 0-> Ingest ; 1->Query ; 2->Exit \n : ") | ||
if choice=='0': | ||
from ingest import INGESTER | ||
print(f"\n\n{'>>'*10}INGESTING!{'<<'*10}\n") | ||
print("(NOTE: It may take sometime depending on the documents in the data folder. Wait for it to end, it'll inform you of the status.)\n") | ||
print(f"{'###'*20}") | ||
try: | ||
print(f"\n\n{'>>>'*7} Ingesting Files: \n\n") | ||
INGESTER() | ||
print(f"\n\n{'>>'*7}INGESTED! Database ready for query!{'<<'*7}\n\n") | ||
except: | ||
print(f"\n\n{'>>'*7}ERROR OCCURED! Database not created!{'<<'*7}\n\n") | ||
elif choice=='1': | ||
#from docquery import EXTRACT | ||
print("\nSTARTING QUERYING!\n") | ||
try: | ||
sys.argv = [ | ||
"streamlit", | ||
"run", | ||
resolve_path("DocChat.py"), | ||
"--global.developmentMode=false", | ||
] | ||
sys.exit(stcli.main()) | ||
except: | ||
print("\n\nERROR WHILE INITIATING QUERYING!\n\n") | ||
#EXTRACT() | ||
elif choice=='2': | ||
print("Exiting!") | ||
break | ||
else: | ||
print("Invalid choice!") |