Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -9,9 +9,20 @@ model = LlamaForCausalLM.from_pretrained(model_name)
|
|
| 9 |
# Initialize the text generation pipeline
|
| 10 |
llm_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
|
|
|
|
| 9 |
# Initialize the text generation pipeline
|
| 10 |
llm_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 11 |
|
| 12 |
+
import fitz # PyMuPDF
|
| 13 |
+
|
| 14 |
+
# Function to extract text from PDF
|
| 15 |
+
def extract_text_from_pdf(pdf_path):
|
| 16 |
+
document = fitz.open(pdf_path)
|
| 17 |
+
text = ""
|
| 18 |
+
for page_num in range(document.page_count):
|
| 19 |
+
page = document.load_page(page_num)
|
| 20 |
+
text += page.get_text()
|
| 21 |
+
return text
|
| 22 |
+
|
| 23 |
+
# Load the prompt from the PDF file
|
| 24 |
+
pdf_path = 'landon_Hotel.pdf'
|
| 25 |
+
prompt = extract_text_from_pdf(pdf_path)
|
| 26 |
|
| 27 |
|
| 28 |
|