Spaces:
Running on Zero
Running on Zero
atakan commited on
Commit ·
d08774c
1
Parent(s): 1f68b63
fix: Make pypdf lazy import and use requirements.txt in Colab Step 1
Browse files
ControlAI_Colab_Demo.ipynb
CHANGED
|
@@ -28,10 +28,11 @@
|
|
| 28 |
"metadata": {},
|
| 29 |
"outputs": [],
|
| 30 |
"source": [
|
|
|
|
| 31 |
"!git clone https://github.com/atakankahya/controlai-agent.git\n",
|
| 32 |
"%cd controlai-agent\n",
|
| 33 |
-
"\n",
|
| 34 |
-
"
|
| 35 |
]
|
| 36 |
},
|
| 37 |
{
|
|
|
|
| 28 |
"metadata": {},
|
| 29 |
"outputs": [],
|
| 30 |
"source": [
|
| 31 |
+
"# Clone repo & install all required dependencies\n",
|
| 32 |
"!git clone https://github.com/atakankahya/controlai-agent.git\n",
|
| 33 |
"%cd controlai-agent\n",
|
| 34 |
+
"!pip install -q -r requirements.txt pypdf\n",
|
| 35 |
+
"print(\"Dependencies installed successfully!\")"
|
| 36 |
]
|
| 37 |
},
|
| 38 |
{
|
controlai_rag/document_loader.py
CHANGED
|
@@ -6,9 +6,6 @@ import json
|
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import Any
|
| 8 |
|
| 9 |
-
from pypdf import PdfReader
|
| 10 |
-
|
| 11 |
-
|
| 12 |
class Document:
|
| 13 |
def __init__(self, content: str, source_path: str, metadata: dict[str, Any] | None = None) -> None:
|
| 14 |
self.content = content
|
|
@@ -26,6 +23,7 @@ class Document:
|
|
| 26 |
def load_pdf(path: Path) -> list[Document]:
|
| 27 |
docs = []
|
| 28 |
try:
|
|
|
|
| 29 |
reader = PdfReader(str(path))
|
| 30 |
for idx, page in enumerate(reader.pages, 1):
|
| 31 |
text = page.extract_text() or ""
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import Any
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
class Document:
|
| 10 |
def __init__(self, content: str, source_path: str, metadata: dict[str, Any] | None = None) -> None:
|
| 11 |
self.content = content
|
|
|
|
| 23 |
def load_pdf(path: Path) -> list[Document]:
|
| 24 |
docs = []
|
| 25 |
try:
|
| 26 |
+
from pypdf import PdfReader
|
| 27 |
reader = PdfReader(str(path))
|
| 28 |
for idx, page in enumerate(reader.pages, 1):
|
| 29 |
text = page.extract_text() or ""
|