Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,13 @@ def upload_pdf(file, use_chapter_split):
|
|
| 18 |
faiss_index, chunk_texts, chunks = build_faiss_index(chunks)
|
| 19 |
return f"✅ Uploaded and indexed {len(chunks)} chunks."
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def set_api_key(api_key):
|
| 22 |
global groq_api_key
|
| 23 |
groq_api_key = api_key
|
|
|
|
| 18 |
faiss_index, chunk_texts, chunks = build_faiss_index(chunks)
|
| 19 |
return f"✅ Uploaded and indexed {len(chunks)} chunks."
|
| 20 |
|
| 21 |
+
|
| 22 |
+
def extract_text_from_pdf(file_path):
|
| 23 |
+
doc = fitz.open(file_path) # file_path is already a string
|
| 24 |
+
pages = [page.get_text() for page in doc]
|
| 25 |
+
return pages
|
| 26 |
+
|
| 27 |
+
|
| 28 |
def set_api_key(api_key):
|
| 29 |
global groq_api_key
|
| 30 |
groq_api_key = api_key
|