Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,16 +17,9 @@ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-rw-1b", trust_remote
|
|
17 |
# Function to generate blog content
|
18 |
def generate_blog(topic, keywords):
|
19 |
prompt_template = f"""
|
20 |
-
You are a
|
21 |
Topic: {topic}
|
22 |
-
|
23 |
-
Make sure the blog covers the following sections:
|
24 |
-
1. Introduction
|
25 |
-
2. Detailed Explanation
|
26 |
-
3. Examples
|
27 |
-
4. Conclusion
|
28 |
-
|
29 |
-
Blog:
|
30 |
"""
|
31 |
input_ids = tokenizer(prompt_template, return_tensors="pt", max_length=512, truncation=True)
|
32 |
outputs = model.generate(input_ids["input_ids"], max_length=800, num_return_sequences=1)
|
@@ -38,12 +31,11 @@ def generate_blog(topic, keywords):
|
|
38 |
iface = gr.Interface(
|
39 |
fn=generate_blog,
|
40 |
inputs=[
|
41 |
-
gr.Textbox(lines=2, placeholder="Enter the
|
42 |
-
gr.Textbox(lines=2, placeholder="Enter keywords (comma-separated)", label="Keywords")
|
43 |
],
|
44 |
-
outputs=gr.Textbox(label="Generated
|
45 |
-
title="
|
46 |
-
description="Generate a
|
47 |
)
|
48 |
|
49 |
if __name__ == "__main__":
|
|
|
17 |
# Function to generate blog content
|
18 |
def generate_blog(topic, keywords):
|
19 |
prompt_template = f"""
|
20 |
+
You are a content writer. Write a poem of a maximum of 10 sentences on the following topic.
|
21 |
Topic: {topic}
|
22 |
+
Poem:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
"""
|
24 |
input_ids = tokenizer(prompt_template, return_tensors="pt", max_length=512, truncation=True)
|
25 |
outputs = model.generate(input_ids["input_ids"], max_length=800, num_return_sequences=1)
|
|
|
31 |
iface = gr.Interface(
|
32 |
fn=generate_blog,
|
33 |
inputs=[
|
34 |
+
gr.Textbox(lines=2, placeholder="Enter the poem topic", label="Blog Topic"),
|
|
|
35 |
],
|
36 |
+
outputs=gr.Textbox(label="Generated Poem"),
|
37 |
+
title="Poem Generator",
|
38 |
+
description="Generate a poem based on the providing a topic."
|
39 |
)
|
40 |
|
41 |
if __name__ == "__main__":
|