Spaces:
Sleeping
Sleeping
File size: 3,354 Bytes
97f86de de915f7 97f86de 8dcd1e2 97f86de fc66173 97f86de 16c86bb 97f86de fc66173 97f86de fc66173 97f86de 8dcd1e2 97f86de 8dcd1e2 97f86de fc66173 8dcd1e2 fc66173 8dcd1e2 de915f7 8dcd1e2 97f86de fc66173 d44fa6f fc66173 de915f7 fc66173 de915f7 fc66173 8ae2ba2 de915f7 d44fa6f de915f7 d44fa6f 8dcd1e2 d44fa6f 97f86de 8dcd1e2 97f86de de915f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import streamlit as st
from phi.agent import Agent
from phi.model.groq import Groq
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.newspaper4k import Newspaper4k
import os
import random
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Create the Agent with a more natural, imperfect human-like writing style
agent = Agent(
model=Groq(id="llama-3.3-70b-specdec", api_key=os.getenv("GROQ_API_KEY")),
tools=[DuckDuckGo(), Newspaper4k()],
description="You write like a real person, not a robot. Your writing is simple, engaging, and casual—like a conversation with a friend.",
instructions=[
"Write like a real human, not AI. Keep it simple, clear, and natural.",
"Use everyday language. No fancy words. No robotic structures.",
"Make sentences short and varied—some are quick, others take their time.",
"Talk to the reader. Imagine you're chatting with a friend.",
"Use words like 'honestly,' 'to be fair,' 'you know what I mean?' for a natural feel.",
"Add a bit of personality—some humor, a quick side note, maybe even a mild complaint.",
"Don't try too hard to sound smart. Just be real and interesting.",
"Forget perfect grammar. If a sentence feels better as a fragment, use it.",
"If something is surprising, react to it. If something is boring, admit it.",
"Most importantly: Make it sound like something a human actually wrote."
],
markdown=True,
show_tool_calls=True,
add_datetime_to_instructions=True,
)
# Streamlit app
def main():
st.title("📝 Real Human-Like Article Generator")
st.markdown("""
Get articles that actually sound like a person wrote them—simple, natural, and engaging.
""")
topic = st.text_input(
"Enter your article topic:",
placeholder="e.g., Why do we all hate the sound of our own voice?"
)
if st.button("Generate Article"):
if topic:
with st.spinner("Writing your article... (Making it sound as real as possible)"):
# Human-like prompt variations
prompt_variations = [
f"Write an article about {topic} that sounds like a real person wrote it. Keep it casual, simple, and engaging.",
f"Create a natural, fun article on {topic}. Write like you're telling a friend about it.",
f"Write a casual, human-like article on {topic}. No complex words, no robotic structure—just natural writing.",
]
prompt = random.choice(prompt_variations)
response = agent.run(prompt)
st.markdown("## 📝 Your Naturally Written Article")
st.markdown(response.content)
# Provide a regeneration option
if st.button("Regenerate Article"):
st.experimental_rerun()
# Download option
st.download_button(
label="📥 Download Article (Markdown)",
data=response.content,
file_name=f"{topic.lower().replace(' ', '-')}-article.md",
mime="text/markdown"
)
else:
st.warning("Please enter a topic.")
if __name__ == "__main__":
main()
|