garvit2205 commited on
Commit
4b7a92a
·
verified ·
1 Parent(s): fc53ddd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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 heading and name of topics in summary:"+content,}],
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(days, file):
28
  if file is None:
29
- return "Please upload a valid timetable file."
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 research paper,you have to output a study plan to cover the topics in the paper in provided number of days.Also at last give a motivational quote on studying."},
38
- {"role": "user","content": "The research paper is:" +study_material+" Now prepare a study plan to cover this in "+days+" days.Give the plan topic wise and can also include some important prerequisites for the paper.Also give a inspiring quote on the domain of the paper or realted to working at last in just a single line.",}],
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=[gr.Textbox(label="Enter the number of days"), 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 and input the number of days to get a study plan"
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")