Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,7 @@ llm = ChatGroq(
|
|
| 16 |
model_name="llama3-8b-8192"
|
| 17 |
)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
def blog_generator(Blog_Topic, Blog_Keyword, Blog_Tone, Blog_Numberofwords, Blog_Target_audiance):
|
| 21 |
"""Generate a blog using Groq AI"""
|
| 22 |
system_prompt = f"""
|
| 23 |
You are an expert blog writer. Follow these instructions:
|
|
@@ -25,32 +24,31 @@ def blog_generator(Blog_Topic, Blog_Keyword, Blog_Tone, Blog_Numberofwords, Blog
|
|
| 25 |
2. Include keywords: {Blog_Keyword}.
|
| 26 |
3. Use tone: {Blog_Tone}.
|
| 27 |
4. Limit to {Blog_Numberofwords} words.
|
| 28 |
-
5. Target audience: {
|
| 29 |
"""
|
| 30 |
|
| 31 |
-
user_prompt = f"Write a blog on {Blog_Topic}, with keywords {Blog_Keyword}, tone {Blog_Tone}, {Blog_Numberofwords} words, for audience {
|
| 32 |
|
| 33 |
response = llm.invoke([SystemMessage(content=system_prompt), HumanMessage(content=user_prompt)])
|
| 34 |
return response.content
|
| 35 |
|
| 36 |
-
|
| 37 |
# Gradio Interface
|
| 38 |
-
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown("# 📝 AI Blog Generator")
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
-
topic = gr.Textbox(label="Blog Topic")
|
| 43 |
-
keyword = gr.Textbox(label="Keywords (comma-separated)")
|
| 44 |
|
| 45 |
with gr.Row():
|
| 46 |
-
tone = gr.Dropdown(["Formal", "Casual", "Professional"], label="Blog Tone")
|
| 47 |
-
words = gr.Slider(100, 1000, step=50, label="Number of Words")
|
| 48 |
|
| 49 |
-
audience = gr.
|
| 50 |
|
| 51 |
-
generate_btn = gr.Button("Generate Blog")
|
| 52 |
-
output = gr.Textbox(label="Generated Blog", lines=10)
|
| 53 |
|
| 54 |
generate_btn.click(blog_generator, inputs=[topic, keyword, tone, words, audience], outputs=output)
|
| 55 |
|
| 56 |
-
demo.launch()
|
|
|
|
| 16 |
model_name="llama3-8b-8192"
|
| 17 |
)
|
| 18 |
|
| 19 |
+
def blog_generator(Blog_Topic, Blog_Keyword, Blog_Tone, Blog_Numberofwords, Blog_Target_audience):
|
|
|
|
| 20 |
"""Generate a blog using Groq AI"""
|
| 21 |
system_prompt = f"""
|
| 22 |
You are an expert blog writer. Follow these instructions:
|
|
|
|
| 24 |
2. Include keywords: {Blog_Keyword}.
|
| 25 |
3. Use tone: {Blog_Tone}.
|
| 26 |
4. Limit to {Blog_Numberofwords} words.
|
| 27 |
+
5. Target audience: {Blog_Target_audience}.
|
| 28 |
"""
|
| 29 |
|
| 30 |
+
user_prompt = f"Write a blog on {Blog_Topic}, with keywords {Blog_Keyword}, tone {Blog_Tone}, {Blog_Numberofwords} words, for audience {Blog_Target_audience}."
|
| 31 |
|
| 32 |
response = llm.invoke([SystemMessage(content=system_prompt), HumanMessage(content=user_prompt)])
|
| 33 |
return response.content
|
| 34 |
|
|
|
|
| 35 |
# Gradio Interface
|
| 36 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 37 |
gr.Markdown("# 📝 AI Blog Generator")
|
| 38 |
|
| 39 |
with gr.Row():
|
| 40 |
+
topic = gr.Textbox(label="Blog Topic", placeholder="Enter the topic of your blog...")
|
| 41 |
+
keyword = gr.Textbox(label="Keywords (comma-separated)", placeholder="e.g., AI, Blogging, Technology")
|
| 42 |
|
| 43 |
with gr.Row():
|
| 44 |
+
tone = gr.Dropdown(["Formal", "Casual", "Professional"], label="Blog Tone", value="Professional")
|
| 45 |
+
words = gr.Slider(100, 1000, step=50, label="Number of Words", value=500)
|
| 46 |
|
| 47 |
+
audience = gr.Dropdown(["General Public", "Tech Enthusiasts", "Business Professionals", "Students"], label="Target Audience", value="General Public")
|
| 48 |
|
| 49 |
+
generate_btn = gr.Button("Generate Blog", variant="primary")
|
| 50 |
+
output = gr.Textbox(label="Generated Blog", lines=10, placeholder="Your generated blog will appear here...")
|
| 51 |
|
| 52 |
generate_btn.click(blog_generator, inputs=[topic, keyword, tone, words, audience], outputs=output)
|
| 53 |
|
| 54 |
+
demo.launch()
|