Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -159,19 +159,43 @@ def summarize_url(url):
|
|
| 159 |
final_answer = summary.split("### Response:")[1].strip()
|
| 160 |
return final_answer
|
| 161 |
|
| 162 |
-
with iface as demo:
|
| 163 |
-
# Define Gradio interface
|
| 164 |
-
demo = gr.Interface(
|
| 165 |
-
fn=summarize_url,
|
| 166 |
-
inputs="text",
|
| 167 |
-
outputs="text",
|
| 168 |
-
title="Website Summary Generator",
|
| 169 |
-
description="Enter a URL to get a one-word topic summary of the website content."
|
| 170 |
-
)
|
| 171 |
-
|
| 172 |
-
# Launch the Gradio app
|
| 173 |
-
# iface.launch()
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
|
|
|
| 176 |
if __name__ == "__main__":
|
| 177 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
final_answer = summary.split("### Response:")[1].strip()
|
| 160 |
return final_answer
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
+
# Create the Gradio interface within a `Blocks` context, like the working example
|
| 164 |
+
with gr.Blocks() as demo:
|
| 165 |
+
|
| 166 |
+
# Add title and description to the interface
|
| 167 |
+
gr.HTML("<h1>Website Summary Generator</h1>")
|
| 168 |
+
gr.HTML("<p>Enter a URL to get a one-word topic summary of the website content..</p>")
|
| 169 |
+
|
| 170 |
+
# Define input and output elements
|
| 171 |
+
with gr.Row():
|
| 172 |
+
prompt = gr.Textbox(label="Enter Website URL", placeholder="https://example.com")
|
| 173 |
+
output_text = gr.Textbox(label="Topic", interactive=False)
|
| 174 |
+
|
| 175 |
+
# Add the button to trigger the function
|
| 176 |
+
submit = gr.Button("Classify")
|
| 177 |
+
|
| 178 |
+
# Define the interaction between inputs and outputs
|
| 179 |
+
submit.click(fn=classify_website, inputs=prompt, outputs=output_text)
|
| 180 |
|
| 181 |
+
# Add the `if __name__ == "__main__":` block to launch the interface
|
| 182 |
if __name__ == "__main__":
|
| 183 |
+
demo.launch()
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
# with gr as demo:
|
| 187 |
+
# # Define Gradio interface
|
| 188 |
+
# demo = demo.Interface(
|
| 189 |
+
# fn=summarize_url,
|
| 190 |
+
# inputs="text",
|
| 191 |
+
# outputs="text",
|
| 192 |
+
# title="Website Summary Generator",
|
| 193 |
+
# description="Enter a URL to get a one-word topic summary of the website content."
|
| 194 |
+
# )
|
| 195 |
+
|
| 196 |
+
# # Launch the Gradio app
|
| 197 |
+
# # iface.launch()
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
# if __name__ == "__main__":
|
| 201 |
+
# demo.launch()
|