Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,7 @@ def markdown_to_html(md_content):
|
|
18 |
return markdown.markdown(md_content)
|
19 |
|
20 |
|
|
|
21 |
def predict(input, images = []):
|
22 |
client = Client("https://roboflow-gemini.hf.space/--replicas/bkd57/")
|
23 |
result = client.predict(
|
@@ -53,17 +54,17 @@ def generate_predictions(book_name, author, language_choice, detail_options=[]):
|
|
53 |
query_template = detail_queries.get(option).format(book_name=book_name, author=author) + '. Answer in ' + language_choice[3:]
|
54 |
try:
|
55 |
response = predict(query_template)
|
56 |
-
details += f"\n\n**{option}**:\n{response
|
57 |
except:
|
58 |
time.sleep(2)
|
59 |
try:
|
60 |
response = predict(query_template)
|
61 |
-
details += f"\n\n**{option}**:\n{response
|
62 |
except:
|
63 |
pass
|
64 |
|
65 |
summary = fetch_summary(book_name, author, language_choice[3:])
|
66 |
-
combined_summary = summary
|
67 |
try:
|
68 |
telegraph_url = post_to_telegraph(f"Summary of {book_name} by {author}", combined_summary)
|
69 |
except requests.exceptions.ConnectionError:
|
@@ -80,10 +81,9 @@ with gr.Blocks(title="π BookMindAI", theme=gr.themes.Base()).queue() as demo:
|
|
80 |
author_name_input = gr.Textbox(placeholder="Enter Author Name", label="Author Name")
|
81 |
language_input = gr.Dropdown(choices=languages, label="Language")
|
82 |
detail_options_input = gr.CheckboxGroup(choices=list(detail_queries.keys()), label="Details to Include", visible=True)
|
83 |
-
run_button_summarize = gr.Button(
|
84 |
|
85 |
with gr.Column():
|
86 |
-
book_cover_output = gr.Gallery(label="Book Cover", visible=True)
|
87 |
telegraph_link_output = gr.Markdown(label="View on Telegraph", visible=True)
|
88 |
with gr.Row():
|
89 |
summary_output = gr.Markdown(label="Parsed Content", visible=True)
|
@@ -109,7 +109,7 @@ with gr.Blocks(title="π BookMindAI", theme=gr.themes.Base()).queue() as demo:
|
|
109 |
def chat_response(message, history):
|
110 |
for i in range(len(message)):
|
111 |
response = predict(message)
|
112 |
-
yield response
|
113 |
|
114 |
chat_interface = gr.ChatInterface(chat_response, examples=chat_examples, title='Talk with Gemini PRO about any book.')
|
115 |
|
|
|
18 |
return markdown.markdown(md_content)
|
19 |
|
20 |
|
21 |
+
|
22 |
def predict(input, images = []):
|
23 |
client = Client("https://roboflow-gemini.hf.space/--replicas/bkd57/")
|
24 |
result = client.predict(
|
|
|
54 |
query_template = detail_queries.get(option).format(book_name=book_name, author=author) + '. Answer in ' + language_choice[3:]
|
55 |
try:
|
56 |
response = predict(query_template)
|
57 |
+
details += f"\n\n**{option}**:\n{response}"
|
58 |
except:
|
59 |
time.sleep(2)
|
60 |
try:
|
61 |
response = predict(query_template)
|
62 |
+
details += f"\n\n**{option}**:\n{response}"
|
63 |
except:
|
64 |
pass
|
65 |
|
66 |
summary = fetch_summary(book_name, author, language_choice[3:])
|
67 |
+
combined_summary = summary + details
|
68 |
try:
|
69 |
telegraph_url = post_to_telegraph(f"Summary of {book_name} by {author}", combined_summary)
|
70 |
except requests.exceptions.ConnectionError:
|
|
|
81 |
author_name_input = gr.Textbox(placeholder="Enter Author Name", label="Author Name")
|
82 |
language_input = gr.Dropdown(choices=languages, label="Language")
|
83 |
detail_options_input = gr.CheckboxGroup(choices=list(detail_queries.keys()), label="Details to Include", visible=True)
|
84 |
+
run_button_summarize = gr.Button("Run", visible=True)
|
85 |
|
86 |
with gr.Column():
|
|
|
87 |
telegraph_link_output = gr.Markdown(label="View on Telegraph", visible=True)
|
88 |
with gr.Row():
|
89 |
summary_output = gr.Markdown(label="Parsed Content", visible=True)
|
|
|
109 |
def chat_response(message, history):
|
110 |
for i in range(len(message)):
|
111 |
response = predict(message)
|
112 |
+
yield response
|
113 |
|
114 |
chat_interface = gr.ChatInterface(chat_response, examples=chat_examples, title='Talk with Gemini PRO about any book.')
|
115 |
|