Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ from langchain.chains import VectorDBQA
|
|
| 8 |
from huggingface_hub import snapshot_download
|
| 9 |
from langchain import OpenAI
|
| 10 |
from langchain import PromptTemplate
|
|
|
|
| 11 |
|
| 12 |
ns = SimpleNamespace(counter=0)
|
| 13 |
|
|
@@ -27,9 +28,6 @@ with st.sidebar:
|
|
| 27 |
st.title(f"Talk2Book: {BOOK_NAME}")
|
| 28 |
st.markdown(f"#### Have a conversation with {BOOK_NAME} by {AUTHOR_NAME} π")
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
##### functionss ####
|
| 34 |
@st.experimental_singleton(show_spinner=False)
|
| 35 |
def load_vectorstore():
|
|
@@ -171,14 +169,15 @@ if ask:
|
|
| 171 |
st.write(f"**{BOOK_NAME}:** Whoops looks like you forgot your API key buddy")
|
| 172 |
st.stop()
|
| 173 |
else:
|
| 174 |
-
if ns.counter:
|
| 175 |
-
msg = "Um... excuse me but... this can take about a minute for your first question because some stuff have to be downloaded π₯Ίππ»ππ»"
|
| 176 |
-
ns.counter = 1
|
| 177 |
-
else:
|
| 178 |
msg = "Just one sec"
|
|
|
|
|
|
|
|
|
|
| 179 |
with st.spinner(msg):
|
| 180 |
try:
|
| 181 |
answer, pages, extract = get_answer(question=user_input)
|
|
|
|
| 182 |
except Exception as exc:
|
| 183 |
st.write(f"**{BOOK_NAME}:**: {exc}")
|
| 184 |
st.stop()
|
|
|
|
| 8 |
from huggingface_hub import snapshot_download
|
| 9 |
from langchain import OpenAI
|
| 10 |
from langchain import PromptTemplate
|
| 11 |
+
from loguru import logger
|
| 12 |
|
| 13 |
ns = SimpleNamespace(counter=0)
|
| 14 |
|
|
|
|
| 28 |
st.title(f"Talk2Book: {BOOK_NAME}")
|
| 29 |
st.markdown(f"#### Have a conversation with {BOOK_NAME} by {AUTHOR_NAME} π")
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
##### functionss ####
|
| 32 |
@st.experimental_singleton(show_spinner=False)
|
| 33 |
def load_vectorstore():
|
|
|
|
| 169 |
st.write(f"**{BOOK_NAME}:** Whoops looks like you forgot your API key buddy")
|
| 170 |
st.stop()
|
| 171 |
else:
|
| 172 |
+
if ns.counter:
|
|
|
|
|
|
|
|
|
|
| 173 |
msg = "Just one sec"
|
| 174 |
+
else:
|
| 175 |
+
msg = "Um... excuse me but... this can take about a minute for your first question because some stuff have to be downloaded π₯Ίππ»ππ»"
|
| 176 |
+
ns.counter = 1
|
| 177 |
with st.spinner(msg):
|
| 178 |
try:
|
| 179 |
answer, pages, extract = get_answer(question=user_input)
|
| 180 |
+
logger.info(f"answer: {answer}")
|
| 181 |
except Exception as exc:
|
| 182 |
st.write(f"**{BOOK_NAME}:**: {exc}")
|
| 183 |
st.stop()
|