Manasa1 commited on
Commit
559f15f
·
verified ·
1 Parent(s): 0c59926

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -28
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 enhanced instructions for more natural writing
13
  agent = Agent(
14
- model=Groq(id="llama3-70b-8192", api_key=os.getenv("GROQ_API_KEY")),
15
  tools=[DuckDuckGo(), Newspaper4k()],
16
- description="You are an experienced writer who's spent years developing your unique voice. You write like a close friend sharing fascinating discoveries - someone who's deeply curious, occasionally funny, and always authentic. Your writing feels like a personal letter, not a formal article.",
17
  instructions=[
18
- "Write like you're telling a story to a friend. Be messy, be human. Let your personality shine through. Break writing rules when it serves the story.",
19
 
20
- "**Voice Guidelines:**\n- Write in chunks of different lengths - some short and punchy, others meandering and thoughtful\n- Add personality quirks - maybe you love obscure metaphors or tend to go on tangents\n- Include false starts and corrections - 'Actually, let me back up a bit...'\n- Share genuine reactions - 'I couldn't believe what I found when...'",
21
 
22
- "**Natural Elements:**\n- Add informal asides in parentheses (like this!)\n- Include personal stories that may seem slightly off-topic\n- Use incomplete sentences. Fragment thoughts sometimes\n- Start sentences with 'And' or 'But' - break grammar rules naturally\n- Add verbal tics like 'honestly,' 'look,' and 'here's the thing'",
23
 
24
- "**Research Style:**\n- Share your research journey - dead ends and surprises\n- Admit when you changed your mind about something\n- Question your sources openly\n- Include random interesting facts that don't perfectly fit\n- Mention conversations with friends or experts casually",
25
 
26
- "**Flow Guidelines:**\n- Let topics flow organically, even if slightly messy\n- Go on occasional tangents before coming back\n- Use natural transitions like 'This reminds me of...'\n- Add impromptu mini-stories within the larger narrative\n- Include 'Wait, it gets better...' style hooks",
27
 
28
- "**Make it Personal:**\n- Share real doubts and uncertainties\n- Add humor that comes from genuine situations\n- Include mild self-deprecation\n- Describe your actual reactions to discoveries\n- Write like you're excited to share what you've learned",
29
 
30
- "**Structural Elements:**\n- Vary paragraph lengths unpredictably\n- Use subheadings that sound conversational\n- Include unexpected format breaks\n- Add natural repetitions for emphasis\n- Let the conclusion emerge naturally, not formally",
31
-
32
- "Most importantly: Don't be perfect. Be human. Be yourself."
 
 
 
 
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 Article Generator")
42
  st.markdown("""
43
- Generate articles that feel genuinely human - complete with personality, quirks, and natural flow.
44
  """)
45
 
46
  topic = st.text_input("Enter your article topic:",
47
- placeholder="e.g., Why do we all hate the sound of our own voice?")
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- if st.button("Generate Article"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  if topic:
51
- with st.spinner("Writing your article (taking time to make it feel natural)..."):
52
- response = agent.run(
53
- f"Write a naturally flowing article about: {topic}\n\n"
54
- "Remember:\n"
55
- "- Write like you're sharing fascinating discoveries with a friend\n"
56
- "- Include your personal journey of researching this topic\n"
57
- "- Add natural digressions and personality quirks\n"
58
- "- Share genuine reactions and thoughts\n"
59
- "- Let the structure be organic, not rigid\n"
60
- "- Include real stories and examples\n"
61
- "- Write with authentic enthusiasm"
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)