gnumanth commited on
Commit
56b6fef
1 Parent(s): 6b28bec
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import google.generativeai as palm
4
+
5
+ palm.configure(api_key=os.environ.get('API_KEY'))
6
+
7
+ BOOK_SUMMARY = """Summarize the book {place_holder} in a clear and concise way.
8
+
9
+ The summary should be no more than 1,000 words.
10
+ The summary should be written in a formal style.
11
+ The summary should include the following information:
12
+ The main plot points of the book.
13
+ The characters in the book and their roles.
14
+ The themes of the book.
15
+ The author's message.
16
+ Examples of desired output format:
17
+
18
+ "The book {place_holder} is about a young woman who goes on a journey to find herself. Along the way, she meets a variety of characters who help her to learn and grow. The book explores the themes of self-discovery, friendship, and love."
19
+
20
+ "{place_holder} is a classic novel that tells the story of a family's struggle to survive during the Great Depression. The book is full of memorable characters and powerful imagery. It is a must-read for anyone interested in American history."
21
+
22
+ Leading words and phrases:
23
+
24
+ The book {place_holder} is about...
25
+ The main plot points of the book are...
26
+ The characters in the book include...
27
+ The themes of the book are...
28
+ The author's message is...
29
+
30
+ Avoid vague or imprecise language:
31
+
32
+ Do not use words like "good" or "bad" to describe the book. Instead, be specific about what you liked or disliked about the book.
33
+ Do not use phrases like "it was a great book" or "it was a terrible book." Instead, explain why you thought the book was great or terrible.
34
+ Provide guidance on what should be done instead:
35
+
36
+ Instead of saying "do not include spoilers," say "please summarize the book without giving away any spoilers."
37
+ Instead of saying "do not use your own opinions," say "please provide a neutral summary of the book.
38
+ """ ""
39
+
40
+ def get_book_summary(bookname):
41
+ response = palm.chat(messages=[BOOK_SUMMARY.format(place_holder=bookname)])
42
+ return response.last
43
+
44
+ interface = gr.Interface(fn=get_book_summary, inputs="text", outputs="text")
45
+
46
+ interface.launch()