Dejansimic commited on
Commit
13c4a3f
1 Parent(s): f444e89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -24
app.py CHANGED
@@ -1,32 +1,23 @@
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()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Inicijalizuj model za generisanje teksta
5
+ text_generator = pipeline("text-generation", model="gpt-2") # Možeš promeniti model ako želiš
6
 
7
+ def generate_blog_post(topic):
8
+ # Generiši tekst na osnovu zadatog teme
9
+ response = text_generator(topic, max_length=300, num_return_sequences=1)
10
+ return response[0]['generated_text']
 
11
 
12
  # Gradio interfejs
13
+ demo = gr.Interface(
14
+ fn=generate_blog_post,
15
+ inputs=gr.inputs.Textbox(label="Enter the topic for your blog post"),
16
+ outputs=gr.outputs.Textbox(label="Generated Blog Post"),
17
+ title="Blog Post Generator",
18
+ description="Enter a topic and generate a blog post using AI."
19
+ )
 
 
 
 
 
 
 
 
 
20
 
21
+ # Pokreni aplikaciju
22
  if __name__ == "__main__":
23
+ demo.launch()