Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -94,6 +94,22 @@ with gr.Blocks(title="📚 BookMindAI", theme=gr.themes.Base()).queue() as demo:
|
|
94 |
]
|
95 |
gr.Examples(examples=examples, inputs=[api_token_input, book_name_input, author_name_input, language_input, detail_options_input])
|
96 |
with gr.Tab("Talk about book🎓"):
|
97 |
-
|
98 |
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
]
|
95 |
gr.Examples(examples=examples, inputs=[api_token_input, book_name_input, author_name_input, language_input, detail_options_input])
|
96 |
with gr.Tab("Talk about book🎓"):
|
97 |
+
api_token_input_chat = gr.Textbox(placeholder="Enter Bard API Token", label="Bard API Token")
|
98 |
|
99 |
+
def chat_response(api_token, message, history):
|
100 |
+
bard = Bard(token=api_token, language='en') # Set default language to English
|
101 |
+
for i in range(len(message)):
|
102 |
+
response = bard.get_answer(message)
|
103 |
+
yield response['content']
|
104 |
+
|
105 |
+
examples_chat = [
|
106 |
+
"How do the underlying themes of a book reflect the societal values and beliefs of its time?",
|
107 |
+
"In what ways do the characters' personal journeys mirror the broader human experience?",
|
108 |
+
"How does the author's use of symbolism and allegory provide insight into the deeper truths of our existence?",
|
109 |
+
"To what extent does the narrative structure of the book challenge or reinforce our understanding of reality?"
|
110 |
+
]
|
111 |
+
|
112 |
+
chat_interface = gr.ChatInterface(chat_response, examples=examples_chat, inputs=[api_token_input_chat], title ='Talk with Palm 2 about any book.')
|
113 |
+
|
114 |
+
|
115 |
+
demo.launch()
|