sarim commited on
Commit
0e1f166
·
1 Parent(s): 1cd8371

testing summary text

Browse files
Files changed (2) hide show
  1. app.py +16 -9
  2. requirements.txt +2 -0
app.py CHANGED
@@ -5,6 +5,8 @@ from pydantic_ai import Agent
5
  from pydantic_ai.models.groq import GroqModel
6
  import nest_asyncio
7
  import pdfplumber
 
 
8
  import os
9
  import presentation as customClass
10
 
@@ -15,9 +17,14 @@ last_message = ''
15
 
16
 
17
 
18
-
19
  model = GroqModel('llama-3.1-70b-versatile', api_key = api_key)
20
 
 
 
 
 
 
21
  def split_long_string(long_string, chunk_size=3500):
22
  string_data = "".join(long_string)
23
  words = string_data.split()
@@ -43,10 +50,7 @@ async def ppt_content(data):
43
  "1. Title : title of the slide ",
44
  "2. Text: he detailed description or narrative content of the slide. This should include key information, explanations, or supporting arguments. Keep it concise yet informative to avoid overwhelming the audience.",
45
  "3. Bullet point: A list of bullet points summarizing key information on the slide. Each bullet point should be detail, long, and highlight a specific aspect of the slide's topic. ideally, limit to 3-5 points.",
46
- "4. Image Suggestion: A prompt for generating an image to complement the slide content. Describe the desired visual in detail, including elements, style, and relevance to the topic. Ensure the prompt is actionable for AI tools.",
47
-
48
-
49
-
50
  ))
51
  listOfString = split_long_string(data)
52
  for i, chunk in enumerate(listOfString):
@@ -58,13 +62,16 @@ async def ppt_content(data):
58
 
59
 
60
 
61
- result_1 = agent.run_sync(user_prompt = listOfString[0])
62
- result_2 = agent.run_sync(user_prompt = listOfString[1],message_history=result_1.new_messages())
63
 
64
- print(result_2.data)
65
 
66
 
67
  def ai_ppt(data):
 
 
 
68
  asyncio.run(ppt_content(data=data))
69
 
70
 
@@ -87,7 +94,7 @@ def main():
87
  uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
88
  if uploaded_file is not None:
89
  extract_data(uploaded_file)
90
- if st.button("Search"):
91
  ai_ppt(data)
92
 
93
  if __name__ == '__main__':
 
5
  from pydantic_ai.models.groq import GroqModel
6
  import nest_asyncio
7
  import pdfplumber
8
+ from transformers import pipeline
9
+ import torch
10
  import os
11
  import presentation as customClass
12
 
 
17
 
18
 
19
 
20
+ # to generate ppt
21
  model = GroqModel('llama-3.1-70b-versatile', api_key = api_key)
22
 
23
+
24
+ # to summarize
25
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
26
+
27
+
28
  def split_long_string(long_string, chunk_size=3500):
29
  string_data = "".join(long_string)
30
  words = string_data.split()
 
50
  "1. Title : title of the slide ",
51
  "2. Text: he detailed description or narrative content of the slide. This should include key information, explanations, or supporting arguments. Keep it concise yet informative to avoid overwhelming the audience.",
52
  "3. Bullet point: A list of bullet points summarizing key information on the slide. Each bullet point should be detail, long, and highlight a specific aspect of the slide's topic. ideally, limit to 3-5 points.",
53
+ "4. Image Suggestion: A prompt for generating an image to complement the slide content. Describe the desired visual in detail, including elements, style, and relevance to the topic. Ensure the prompt is actionable for AI tools.",
 
 
 
54
  ))
55
  listOfString = split_long_string(data)
56
  for i, chunk in enumerate(listOfString):
 
62
 
63
 
64
 
65
+ result_1 = agent.run_sync(user_prompt = data)
66
+ #result_2 = agent.run_sync(user_prompt = listOfString[1],message_history=result_1.new_messages())
67
 
68
+ print(result_1.data)
69
 
70
 
71
  def ai_ppt(data):
72
+ #call summerizer to summerize pdf
73
+ summary = summarizer(data, max_length=130, min_length=30, do_sample=False)
74
+ print(summary)
75
  asyncio.run(ppt_content(data=data))
76
 
77
 
 
94
  uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
95
  if uploaded_file is not None:
96
  extract_data(uploaded_file)
97
+ if st.button("Make PPT"):
98
  ai_ppt(data)
99
 
100
  if __name__ == '__main__':
requirements.txt CHANGED
@@ -4,4 +4,6 @@ pdfplumber
4
  streamlit_pdf_viewer
5
  pydantic_ai
6
  nest_asyncio
 
 
7
  #pydantic_ai.models.groq
 
4
  streamlit_pdf_viewer
5
  pydantic_ai
6
  nest_asyncio
7
+ torch==2.2.2
8
+ transformers==4.39.1
9
  #pydantic_ai.models.groq