|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
text_generator = pipeline("text-generation", model="nvidia/Llama-3.1-Nemotron-70B-Instruct-HF") |
|
|
|
def generate_blog_post(topic): |
|
|
|
response = text_generator(topic, max_length=300, num_return_sequences=1) |
|
return response[0]['generated_text'] |
|
|
|
|
|
demo = gr.Interface( |
|
fn=generate_blog_post, |
|
inputs=gr.inputs.Textbox(label="Enter the topic for your blog post"), |
|
outputs=gr.outputs.Textbox(label="Generated Blog Post"), |
|
title="Blog Post Generator", |
|
description="Enter a topic and generate a blog post using AI." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|