File size: 3,138 Bytes
97f86de
 
 
 
 
 
de915f7
97f86de
 
8dcd1e2
97f86de
 
f1e2308
97f86de
a2b9dd7
97f86de
f1e2308
97f86de
f1e2308
 
 
 
 
 
 
 
 
97f86de
 
8dcd1e2
 
97f86de
 
8dcd1e2
97f86de
ec1aebf
f1e2308
de915f7
 
 
 
 
 
8dcd1e2
97f86de
f1e2308
d44fa6f
f1e2308
de915f7
f1e2308
 
 
de915f7
 
 
 
 
fc66173
8ae2ba2
de915f7
f1e2308
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
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()

# Set up the AI agent to generate more natural, human-like writing
agent = Agent(
    model=Groq(id="llama-3.3-70b-specdec", api_key=os.getenv("GROQ_API_KEY")),
    tools=[DuckDuckGo(), Newspaper4k()],
    description="Write in a way that sounds like a real person. No robotic structures, just natural and engaging storytelling.",
    instructions=[
        "Keep it simple and conversational, like you're talking to a friend.",
        "No fancy words or robotic phrasing—just natural language.",
        "Vary sentence lengths, throw in a casual phrase, and keep it real.",
        "If something surprises you, react to it. If it's boring, say so.",
        "Don't force perfect grammar—if a sentence feels better as a fragment, go with it.",
        "Make it fun. A little humor, a tiny rant, or a personal touch goes a long way.",
        "Talk to the reader. Use 'you' and 'we' to make it feel more personal.",
        "If a fact sounds weird, acknowledge it. If a statement is bold, justify it.",
        "Bottom line: Make it sound like something a real person actually wrote.",
    ],
    markdown=True,
    show_tool_calls=True,
    add_datetime_to_instructions=True,
)

# Streamlit app
def main():
    st.title("📝 Human-Like Article Generator")
    st.markdown("Get articles that actually sound like a person wrote them—natural, engaging, and fun.")

    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 on {topic} like you're explaining it to a friend over coffee.",
                    f"Tell a story about {topic}. Keep it casual, engaging, and easy to read.",
                    f"Write a fun, natural article on {topic}—no robotic tone, just real talk.",
                ]
                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()