Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
from together import Together
|
| 3 |
import os
|
| 4 |
import re
|
|
|
|
| 5 |
import fitz # PyMuPDF for PDF text extraction
|
| 6 |
|
| 7 |
API_KEY = os.getenv("TOGETHER_API_KEY")
|
|
@@ -20,7 +21,10 @@ st.title("DeepSeek R1 Chatbot")
|
|
| 20 |
|
| 21 |
# Function to extract text from a PDF file
|
| 22 |
def extract_pdf_text(uploaded_file):
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
text = ""
|
| 25 |
for page in doc:
|
| 26 |
text += page.get_text()
|
|
|
|
| 2 |
from together import Together
|
| 3 |
import os
|
| 4 |
import re
|
| 5 |
+
import io
|
| 6 |
import fitz # PyMuPDF for PDF text extraction
|
| 7 |
|
| 8 |
API_KEY = os.getenv("TOGETHER_API_KEY")
|
|
|
|
| 21 |
|
| 22 |
# Function to extract text from a PDF file
|
| 23 |
def extract_pdf_text(uploaded_file):
|
| 24 |
+
# Convert the uploaded file into a byte stream
|
| 25 |
+
pdf_bytes = uploaded_file.read()
|
| 26 |
+
# Open the byte stream as a PDF document
|
| 27 |
+
doc = fitz.open(io.BytesIO(pdf_bytes))
|
| 28 |
text = ""
|
| 29 |
for page in doc:
|
| 30 |
text += page.get_text()
|