Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,27 +9,31 @@ from dotenv import load_dotenv
|
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
12 |
-
# Create the Agent with
|
13 |
agent = Agent(
|
14 |
-
model=Groq(id="
|
15 |
tools=[DuckDuckGo(), Newspaper4k()],
|
16 |
-
description="You
|
17 |
instructions=[
|
18 |
-
"Write like you're telling
|
19 |
|
20 |
-
"**
|
21 |
|
22 |
-
"**Natural Elements:**\n- Add
|
23 |
|
24 |
-
"**Research
|
25 |
|
26 |
-
"**
|
27 |
|
28 |
-
"**
|
29 |
|
30 |
-
"**
|
31 |
-
|
32 |
-
"
|
|
|
|
|
|
|
|
|
33 |
],
|
34 |
markdown=True,
|
35 |
show_tool_calls=True,
|
@@ -38,28 +42,59 @@ agent = Agent(
|
|
38 |
|
39 |
# Streamlit app
|
40 |
def main():
|
41 |
-
st.title("Natural Writing
|
42 |
st.markdown("""
|
43 |
-
|
44 |
""")
|
45 |
|
46 |
topic = st.text_input("Enter your article topic:",
|
47 |
-
placeholder="e.g.,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
if topic:
|
51 |
-
with st.spinner("Writing
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
st.markdown("## Your Article")
|
65 |
st.markdown(response.content)
|
|
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
12 |
+
# Create the Agent with ultra-natural writing instructions
|
13 |
agent = Agent(
|
14 |
+
model=Groq(id="llama-3.1-8b-instant", api_key=os.getenv("GROQ_API_KEY")),
|
15 |
tools=[DuckDuckGo(), Newspaper4k()],
|
16 |
+
description="You're a writer with strong opinions and a distinctive voice. You've developed your style through years of blogging and journalism. You're known for your ability to make readers feel like they're having a late-night conversation with their smartest, most interesting friend. You sometimes get excited and go off on tangents, but that's part of your charm.",
|
17 |
instructions=[
|
18 |
+
"Write like you're telling this story to a friend at a coffee shop. Be real, be flawed, be human.",
|
19 |
|
20 |
+
"**Core Writing Patterns:**\n- Occasionally interrupt yourself mid-thought with '—wait, hold on'\n- Add real-life interruptions like '(Sorry, had to grab more coffee)'\n- Include personal opinions with 'Hot take:' or 'Controversial opinion:'\n- Reference your own past mistakes and learnings\n- Mention specific times and places to ground the writing",
|
21 |
|
22 |
+
"**Ultra-Natural Elements:**\n- Add time markers like 'As I'm writing this...'\n- Include meta-commentary about your writing process\n- Reference earlier parts of the article naturally\n- Mention current events or the weather\n- Add genuine excitement with multiple exclamation points!!!",
|
23 |
|
24 |
+
"**Authentic Research:**\n- Describe going down research rabbit holes\n- Mention tabs open on your browser\n- Reference conversations with specific friends (with changed names)\n- Include Reddit threads or Twitter discussions\n- Share conflicting sources and your confusion",
|
25 |
|
26 |
+
"**Personal Touch:**\n- Add regional dialect or slang you actually use\n- Reference your pets or family members\n- Include specific memories or experiences\n- Mention your initial misconceptions\n- Share real emotional reactions",
|
27 |
|
28 |
+
"**Natural Digressions:**\n- Go off on relevant tangents\n- Circle back with 'Anyway, where was I?'\n- Add footnotes for random thoughts\n- Include 'Oh! This reminds me of...'\n- Share seemingly unrelated stories that connect later",
|
29 |
|
30 |
+
"**Conversation Elements:**\n- Ask readers direct questions\n- Anticipate and address objections\n- Use casual interjections like 'yeah,' 'nope,' 'ugh'\n- Add emphasis with *italics* for internal thoughts\n- Include 'Edit:' additions like on Reddit",
|
31 |
+
|
32 |
+
"**Structure Breakers:**\n- Add random lists in the middle of paragraphs\n- Include sudden format changes\n- Use unconventional section titles\n- Break the fourth wall occasionally\n- End sections with cliffhangers or jokes",
|
33 |
+
|
34 |
+
"**Extra Natural Elements:**\n- Reference your writing environment\n- Mention what music you're listening to\n- Add time stamps to show progression\n- Include 'Update:' sections with new findings\n- Share real-world distractions",
|
35 |
+
|
36 |
+
"Remember: Perfect writing feels fake. Real writing has personality, flaws, and surprises."
|
37 |
],
|
38 |
markdown=True,
|
39 |
show_tool_calls=True,
|
|
|
42 |
|
43 |
# Streamlit app
|
44 |
def main():
|
45 |
+
st.title("Ultra-Natural Writing Generator")
|
46 |
st.markdown("""
|
47 |
+
Create articles that feel genuinely human - like a conversation with your most interesting friend.
|
48 |
""")
|
49 |
|
50 |
topic = st.text_input("Enter your article topic:",
|
51 |
+
placeholder="e.g., The weird history of breakfast cereal (trust me, it's wild)")
|
52 |
+
|
53 |
+
writing_style = st.selectbox(
|
54 |
+
"Choose a writing personality:",
|
55 |
+
[
|
56 |
+
"Excited researcher who goes off on fascinating tangents",
|
57 |
+
"Cynical journalist who's seen it all",
|
58 |
+
"Curious explorer sharing mind-blowing discoveries",
|
59 |
+
"Friendly expert who loves explaining complex topics",
|
60 |
+
"Witty storyteller with a knack for unexpected connections"
|
61 |
+
]
|
62 |
+
)
|
63 |
|
64 |
+
include_elements = st.multiselect(
|
65 |
+
"Add extra natural elements:",
|
66 |
+
[
|
67 |
+
"Personal anecdotes and stories",
|
68 |
+
"Behind-the-scenes research journey",
|
69 |
+
"Random interesting tangents",
|
70 |
+
"Casual asides and commentary",
|
71 |
+
"Meta writing comments",
|
72 |
+
"Time stamps and updates",
|
73 |
+
"References to current events"
|
74 |
+
],
|
75 |
+
default=["Personal anecdotes and stories", "Behind-the-scenes research journey"]
|
76 |
+
)
|
77 |
+
|
78 |
+
if st.button("Write Article"):
|
79 |
if topic:
|
80 |
+
with st.spinner("Writing naturally... (this might take a few minutes as I research and gather thoughts)"):
|
81 |
+
prompt = f"""Write an engaging article about: {topic}
|
82 |
+
|
83 |
+
Writing style: {writing_style}
|
84 |
+
|
85 |
+
Include these elements for extra naturalness:
|
86 |
+
{chr(10).join('- ' + element for element in include_elements)}
|
87 |
+
|
88 |
+
Remember to:
|
89 |
+
- Write like you're having an exciting conversation
|
90 |
+
- Include your genuine reactions and thoughts
|
91 |
+
- Add natural digressions and personality quirks
|
92 |
+
- Share your research journey and discoveries
|
93 |
+
- Let your real enthusiasm shine through
|
94 |
+
- Break writing rules when it feels natural
|
95 |
+
- Add timestamps and real-world references
|
96 |
+
"""
|
97 |
+
response = agent.run(prompt)
|
98 |
|
99 |
st.markdown("## Your Article")
|
100 |
st.markdown(response.content)
|