Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ def extract_text_from_pdf(pdf_file):
|
|
| 15 |
client = Groq(api_key=api,)
|
| 16 |
chat_completion=client.chat.completions.create(
|
| 17 |
messages=[{"role": "system", "content": "Summarize the page and mainly keep the headings and topic names intact in the short summary."},
|
| 18 |
-
{"role": "user","content": "Summarize and mainly keep the
|
| 19 |
model="llama3-8b-8192",
|
| 20 |
)
|
| 21 |
text += chat_completion.choices[0].message.content
|
|
@@ -24,9 +24,9 @@ def extract_text_from_pdf(pdf_file):
|
|
| 24 |
|
| 25 |
from groq import Groq
|
| 26 |
import os
|
| 27 |
-
def study_planner(
|
| 28 |
if file is None:
|
| 29 |
-
return "Please upload a valid
|
| 30 |
|
| 31 |
try:
|
| 32 |
study_material = extract_text_from_pdf(file.name)
|
|
@@ -34,8 +34,8 @@ def study_planner(days, file):
|
|
| 34 |
client = Groq(api_key=api,)
|
| 35 |
|
| 36 |
chat_completion = client.chat.completions.create(
|
| 37 |
-
messages=[{"role": "system", "content": "Provided a
|
| 38 |
-
{"role": "user","content": "The
|
| 39 |
model="llama3-70b-8192",
|
| 40 |
)
|
| 41 |
study_plan = chat_completion.choices[0].message.content
|
|
@@ -48,10 +48,10 @@ def study_planner(days, file):
|
|
| 48 |
import gradio as gr
|
| 49 |
demo = gr.Interface(
|
| 50 |
fn=study_planner,
|
| 51 |
-
inputs=
|
| 52 |
outputs=gr.Textbox(label="Optimum study plan"),
|
| 53 |
title="Research Paper Study Planner",
|
| 54 |
-
description="Upload the research paper
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share="True")
|
|
|
|
| 15 |
client = Groq(api_key=api,)
|
| 16 |
chat_completion=client.chat.completions.create(
|
| 17 |
messages=[{"role": "system", "content": "Summarize the page and mainly keep the headings and topic names intact in the short summary."},
|
| 18 |
+
{"role": "user","content": "Summarize and mainly keep the headings and name of topics in summary:"+content,}],
|
| 19 |
model="llama3-8b-8192",
|
| 20 |
)
|
| 21 |
text += chat_completion.choices[0].message.content
|
|
|
|
| 24 |
|
| 25 |
from groq import Groq
|
| 26 |
import os
|
| 27 |
+
def study_planner(file):
|
| 28 |
if file is None:
|
| 29 |
+
return "Please upload a valid file."
|
| 30 |
|
| 31 |
try:
|
| 32 |
study_material = extract_text_from_pdf(file.name)
|
|
|
|
| 34 |
client = Groq(api_key=api,)
|
| 35 |
|
| 36 |
chat_completion = client.chat.completions.create(
|
| 37 |
+
messages=[{"role": "system", "content": "Provided a short summary or precisely,a list of topics and headings present in the paper,give a study plan to study the paper effectively.You should include essential prerequisites for the topics also in the plan."},
|
| 38 |
+
{"role": "user","content": "The summary or list of headings in the paper is:"+study_material+".Now give the desiered study plan with essential prerequisites.",}],
|
| 39 |
model="llama3-70b-8192",
|
| 40 |
)
|
| 41 |
study_plan = chat_completion.choices[0].message.content
|
|
|
|
| 48 |
import gradio as gr
|
| 49 |
demo = gr.Interface(
|
| 50 |
fn=study_planner,
|
| 51 |
+
inputs=gr.File(label="Upload the research paper (PDF)"),
|
| 52 |
outputs=gr.Textbox(label="Optimum study plan"),
|
| 53 |
title="Research Paper Study Planner",
|
| 54 |
+
description="Upload the research paper to get a study plan"
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share="True")
|