Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -80,10 +80,10 @@ class PDFAnalytics:
|
|
80 |
# Define a conversation between system and user
|
81 |
conversation = [
|
82 |
{"role": "system", "content": "You are a Summarizer"},
|
83 |
-
{"role": "user", "content": f"""summarize the following text delimited by triple backticks.Output must in english.
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
```{self.extracted_text}```
|
88 |
"""}
|
89 |
]
|
@@ -101,7 +101,7 @@ class PDFAnalytics:
|
|
101 |
elif model == "Mixtral":
|
102 |
task = "summary"
|
103 |
# Generate answer using Mixtral model
|
104 |
-
prompt = f"""<s>[INST] summarize the following text delimited by triple backticks.Output must in english.
|
105 |
In two format of Outputs given below:
|
106 |
Abstractive Summary:
|
107 |
Extractive Summary:
|
@@ -422,13 +422,14 @@ class PDFAnalytics:
|
|
422 |
overall_topics = "\n"
|
423 |
for i in range(num_loops):
|
424 |
self._extract_text_from_pdfs(f"extracted_text_part_{i}.txt")
|
425 |
-
|
|
|
426 |
summary = self.generate_summary(model)
|
427 |
overall_summary += text + summary +"\n\n"
|
428 |
important_sentences = self.generate_important_sentences(model)
|
429 |
-
important_sent_text = f"{i+1} 20 pages Important Sentence:\n\n"
|
430 |
overall_important_sentences += important_sent_text + important_sentences + "\n\n"
|
431 |
-
topics_text = f"{i+1} 20 pages Topics:\n\n"
|
432 |
topics = self.generate_topics(model)
|
433 |
overall_topics += topics_text + topics + "\n\n"
|
434 |
|
@@ -447,7 +448,7 @@ class PDFAnalytics:
|
|
447 |
return "", "", ""
|
448 |
|
449 |
def file_show_status(self,filepath):
|
450 |
-
return
|
451 |
|
452 |
def gradio_interface(self):
|
453 |
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
|
|
|
80 |
# Define a conversation between system and user
|
81 |
conversation = [
|
82 |
{"role": "system", "content": "You are a Summarizer"},
|
83 |
+
{"role": "user", "content": f"""summarize the following text delimited by triple backticks.Output must in english.give me a detailed summary.extractive summary working br like extract sentences from given text to return as summary,abstractive summary working be like summary of what about the given text.don't make bullet points write like a passage.
|
84 |
+
In two format of Outputs given below:
|
85 |
+
Abstractive Summary:
|
86 |
+
Extractive Summary:
|
87 |
```{self.extracted_text}```
|
88 |
"""}
|
89 |
]
|
|
|
101 |
elif model == "Mixtral":
|
102 |
task = "summary"
|
103 |
# Generate answer using Mixtral model
|
104 |
+
prompt = f"""<s>[INST] summarize the following text delimited by triple backticks.Output must in english.give me a detailed summary.extractive summary working br like extract sentences from given text to return as summary,abstractive summary working be like summary of what about the given text.don't make bullet points write like a passage.
|
105 |
In two format of Outputs given below:
|
106 |
Abstractive Summary:
|
107 |
Extractive Summary:
|
|
|
422 |
overall_topics = "\n"
|
423 |
for i in range(num_loops):
|
424 |
self._extract_text_from_pdfs(f"extracted_text_part_{i}.txt")
|
425 |
+
ordinal_suffix = "th" if 11 <= (i+1) % 100 <= 13 else {1: "st", 2: "nd", 3: "rd"}.get((i+1) % 10, "th")
|
426 |
+
text = f"{i+1}{ordinal_suffix} 20 pages Summary:\n\n"
|
427 |
summary = self.generate_summary(model)
|
428 |
overall_summary += text + summary +"\n\n"
|
429 |
important_sentences = self.generate_important_sentences(model)
|
430 |
+
important_sent_text = f"{i+1}{ordinal_suffix} 20 pages Important Sentence:\n\n"
|
431 |
overall_important_sentences += important_sent_text + important_sentences + "\n\n"
|
432 |
+
topics_text = f"{i+1}{ordinal_suffix} 20 pages Topics:\n\n"
|
433 |
topics = self.generate_topics(model)
|
434 |
overall_topics += topics_text + topics + "\n\n"
|
435 |
|
|
|
448 |
return "", "", ""
|
449 |
|
450 |
def file_show_status(self,filepath):
|
451 |
+
return "File Uploaded Successfully"
|
452 |
|
453 |
def gradio_interface(self):
|
454 |
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
|