suhas2924 commited on
Commit
dd41a44
·
verified ·
1 Parent(s): 574af4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
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
- doc = fitz.open(uploaded_file)
 
 
 
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()