Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import os
|
2 |
|
3 |
os.system('pip install auto_gptq-0.4.1+cu118-cp310-cp310-linux_x86_64.whl')
|
|
|
4 |
|
5 |
import streamlit as st
|
6 |
import torch
|
7 |
from auto_gptq import AutoGPTQForCausalLM
|
|
|
8 |
from transformers import AutoTokenizer, TextStreamer, pipeline
|
9 |
from langchain_community.document_loaders import PyPDFLoader
|
10 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
@@ -23,6 +25,8 @@ if "initialized" not in st.session_state:
|
|
23 |
st.session_state.initialized = False
|
24 |
|
25 |
if not st.session_state.initialized:
|
|
|
|
|
26 |
# Load PDF
|
27 |
loader = PyPDFLoader("Medical_Book.pdf")
|
28 |
docs = loader.load()
|
@@ -125,7 +129,7 @@ if st.button("Submit"):
|
|
125 |
answer = result["result"]
|
126 |
st.session_state.history.append({"question": user_input, "answer": answer})
|
127 |
# Clear input text after submission
|
128 |
-
st.
|
129 |
|
130 |
# Scroll to the bottom to display the latest message
|
131 |
st.markdown(
|
|
|
1 |
import os
|
2 |
|
3 |
os.system('pip install auto_gptq-0.4.1+cu118-cp310-cp310-linux_x86_64.whl')
|
4 |
+
os.system('sudo apt-get install -y poppler-utils')
|
5 |
|
6 |
import streamlit as st
|
7 |
import torch
|
8 |
from auto_gptq import AutoGPTQForCausalLM
|
9 |
+
from pdf2image import convert_from_path
|
10 |
from transformers import AutoTokenizer, TextStreamer, pipeline
|
11 |
from langchain_community.document_loaders import PyPDFLoader
|
12 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
|
|
25 |
st.session_state.initialized = False
|
26 |
|
27 |
if not st.session_state.initialized:
|
28 |
+
meta_images = convert_from_path("Medical_Book.pdf", dpi=88)
|
29 |
+
|
30 |
# Load PDF
|
31 |
loader = PyPDFLoader("Medical_Book.pdf")
|
32 |
docs = loader.load()
|
|
|
129 |
answer = result["result"]
|
130 |
st.session_state.history.append({"question": user_input, "answer": answer})
|
131 |
# Clear input text after submission
|
132 |
+
st.experimental_rerun()
|
133 |
|
134 |
# Scroll to the bottom to display the latest message
|
135 |
st.markdown(
|