Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,28 @@ import streamlit as st
|
|
14 |
from PIL import Image
|
15 |
import time
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
image = Image.open('Wipro logo.png')
|
18 |
st.image(image)
|
19 |
|
@@ -40,26 +62,8 @@ with st.form("my_form"):
|
|
40 |
submitted = st.form_submit_button("Ask question")
|
41 |
if submitted:
|
42 |
st.write("AI is looking for the answer...It will take atleast 2 mintutes... Answers will appear below....")
|
|
|
|
|
43 |
|
44 |
-
if myurl:
|
45 |
-
index = None
|
46 |
-
loader1 = PyPDFLoader(myurl)
|
47 |
-
langchainembeddings = OpenAIEmbeddings(deployment="textembedding", chunk_size=1)
|
48 |
|
49 |
-
index = VectorstoreIndexCreator(
|
50 |
-
# split the documents into chunks
|
51 |
-
text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0),
|
52 |
-
# select which embeddings we want to use
|
53 |
-
embedding=langchainembeddings,
|
54 |
-
# use Chroma as the vectorestore to index and search embeddings
|
55 |
-
vectorstore_cls=Chroma
|
56 |
-
).from_loaders([loader1])
|
57 |
-
|
58 |
-
st.write("indexed PDF...AI finding answer....please wait")
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
if yourquestion:
|
63 |
-
answer = index.query(llm=llmgpt3, question=yourquestion, chain_type="map_reduce")
|
64 |
-
st.subheader(answer)
|
65 |
|
|
|
14 |
from PIL import Image
|
15 |
import time
|
16 |
|
17 |
+
def findanswer(Nand_url, Nand_question):
|
18 |
+
if True:
|
19 |
+
if Nand_url:
|
20 |
+
index = None
|
21 |
+
loader1 = PyPDFLoader(Nand_url)
|
22 |
+
langchainembeddings = OpenAIEmbeddings(deployment="textembedding", chunk_size=1)
|
23 |
+
|
24 |
+
index = VectorstoreIndexCreator(
|
25 |
+
# split the documents into chunks
|
26 |
+
text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0),
|
27 |
+
# select which embeddings we want to use
|
28 |
+
embedding=langchainembeddings,
|
29 |
+
# use Chroma as the vectorestore to index and search embeddings
|
30 |
+
vectorstore_cls=Chroma
|
31 |
+
).from_loaders([loader1])
|
32 |
+
# st.write("indexed PDF...AI finding answer....please wait")
|
33 |
+
if Nand_question:
|
34 |
+
answer = index.query(llm=llmgpt3, question=yourquestion, chain_type="map_reduce")
|
35 |
+
return answer
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
image = Image.open('Wipro logo.png')
|
40 |
st.image(image)
|
41 |
|
|
|
62 |
submitted = st.form_submit_button("Ask question")
|
63 |
if submitted:
|
64 |
st.write("AI is looking for the answer...It will take atleast 2 mintutes... Answers will appear below....")
|
65 |
+
Nandanswer = findanswer(myurl, yourquestion )
|
66 |
+
st.write(Nandanswer)
|
67 |
|
|
|
|
|
|
|
|
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|