Update rag.py
Browse files
rag.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
|
3 |
from langchain.callbacks import get_openai_callback
|
4 |
from langchain.chains import LLMChain, RetrievalQA
|
@@ -38,16 +38,21 @@ RAG_CHAIN_PROMPT = PromptTemplate(
|
|
38 |
input_variables = ["context", "question"],
|
39 |
template = os.environ["RAG_TEMPLATE"])
|
40 |
|
|
|
|
|
|
|
41 |
def load_documents():
|
42 |
docs = []
|
43 |
|
44 |
# PDF
|
45 |
loader = PyPDFLoader(PDF_URL)
|
46 |
docs.extend(loader.load())
|
|
|
47 |
|
48 |
# Web
|
49 |
loader = WebBaseLoader(WEB_URL)
|
50 |
docs.extend(loader.load())
|
|
|
51 |
|
52 |
# YouTube
|
53 |
loader = GenericLoader(
|
@@ -56,6 +61,7 @@ def load_documents():
|
|
56 |
YOUTUBE_DIR),
|
57 |
OpenAIWhisperParser())
|
58 |
docs.extend(loader.load())
|
|
|
59 |
|
60 |
return docs
|
61 |
|
|
|
1 |
+
import logging, os, sys
|
2 |
|
3 |
from langchain.callbacks import get_openai_callback
|
4 |
from langchain.chains import LLMChain, RetrievalQA
|
|
|
38 |
input_variables = ["context", "question"],
|
39 |
template = os.environ["RAG_TEMPLATE"])
|
40 |
|
41 |
+
logging.basicConfig(stream = sys.stdout, level = logging.DEBUG)
|
42 |
+
logging.getLogger().addHandler(logging.StreamHandler(stream = sys.stdout))
|
43 |
+
|
44 |
def load_documents():
|
45 |
docs = []
|
46 |
|
47 |
# PDF
|
48 |
loader = PyPDFLoader(PDF_URL)
|
49 |
docs.extend(loader.load())
|
50 |
+
#print("docs = " + str(len(docs)))
|
51 |
|
52 |
# Web
|
53 |
loader = WebBaseLoader(WEB_URL)
|
54 |
docs.extend(loader.load())
|
55 |
+
#print("docs = " + str(len(docs)))
|
56 |
|
57 |
# YouTube
|
58 |
loader = GenericLoader(
|
|
|
61 |
YOUTUBE_DIR),
|
62 |
OpenAIWhisperParser())
|
63 |
docs.extend(loader.load())
|
64 |
+
#print("docs = " + str(len(docs)))
|
65 |
|
66 |
return docs
|
67 |
|