Dejansimic commited on
Commit
f74a1d9
1 Parent(s): bfacafc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Učitaj model za generisanje teksta
5
+ generator = pipeline("text-generation", model="gpt2")
6
+
7
+ def generate_blog_post(topic, keywords):
8
+ prompt = f"Write an SEO-optimized blog post about {topic}. Include keywords: {', '.join(keywords)}."
9
+
10
+ generated = generator(prompt, max_length=500, num_return_sequences=1)
11
+ return generated[0]['generated_text']
12
+
13
+ # Gradio interfejs
14
+ def main():
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("# Blog Post Generator")
17
+ topic_input = gr.Textbox(label="Enter the blog topic", placeholder="e.g. Website Maintenance Tips")
18
+ keywords_input = gr.Textbox(label="Enter keywords (comma-separated)", placeholder="e.g. website maintenance, SEO, content updates")
19
+
20
+ generate_button = gr.Button("Generate Blog Post")
21
+ output_area = gr.Textbox(label="Generated Blog Post", placeholder="Your blog post will appear here...", interactive=False)
22
+
23
+ generate_button.click(
24
+ fn=generate_blog_post,
25
+ inputs=[topic_input, keywords_input],
26
+ outputs=output_area
27
+ )
28
+
29
+ demo.launch()
30
+
31
+ if __name__ == "__main__":
32
+ main()