wholewhale
commited on
Commit
•
0611094
1
Parent(s):
30a372e
error
Browse files
app.py
CHANGED
@@ -18,12 +18,10 @@ def loading_pdf():
|
|
18 |
return "Working on the upload. Also, pondering the usefulness of sporks..."
|
19 |
|
20 |
def pdf_changes(pdf_doc):
|
21 |
-
|
22 |
if pdf_doc is None:
|
23 |
return "No PDF uploaded."
|
24 |
|
25 |
-
loader = OnlinePDFLoader(pdf_doc.name)
|
26 |
-
documents = loader.load()
|
27 |
loader = OnlinePDFLoader(pdf_doc.name)
|
28 |
documents = loader.load()
|
29 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
@@ -32,15 +30,17 @@ def pdf_changes(pdf_doc):
|
|
32 |
global db
|
33 |
db = Chroma.from_documents(texts, embeddings)
|
34 |
retriever = db.as_retriever()
|
35 |
-
global qa
|
36 |
qa = ConversationalRetrievalChain.from_llm(
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
return "Ready"
|
41 |
except Exception as e:
|
42 |
return f"Error loading PDF: {e}"
|
43 |
|
|
|
44 |
def clear_data():
|
45 |
global qa, db
|
46 |
qa = None
|
|
|
18 |
return "Working on the upload. Also, pondering the usefulness of sporks..."
|
19 |
|
20 |
def pdf_changes(pdf_doc):
|
21 |
+
try:
|
22 |
if pdf_doc is None:
|
23 |
return "No PDF uploaded."
|
24 |
|
|
|
|
|
25 |
loader = OnlinePDFLoader(pdf_doc.name)
|
26 |
documents = loader.load()
|
27 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
|
|
30 |
global db
|
31 |
db = Chroma.from_documents(texts, embeddings)
|
32 |
retriever = db.as_retriever()
|
33 |
+
global qa
|
34 |
qa = ConversationalRetrievalChain.from_llm(
|
35 |
+
llm=OpenAI(temperature=0.2, model_name="gpt-3.5-turbo", max_tokens=-1, n=2),
|
36 |
+
retriever=retriever,
|
37 |
+
return_source_documents=False
|
38 |
+
)
|
39 |
return "Ready"
|
40 |
except Exception as e:
|
41 |
return f"Error loading PDF: {e}"
|
42 |
|
43 |
+
|
44 |
def clear_data():
|
45 |
global qa, db
|
46 |
qa = None
|