Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,73 +6,67 @@ from phi.tools.newspaper4k import Newspaper4k
|
|
6 |
import os
|
7 |
from dotenv import load_dotenv
|
8 |
|
9 |
-
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
12 |
-
#
|
13 |
agent = Agent(
|
14 |
-
model=Groq(id="
|
15 |
tools=[DuckDuckGo(), Newspaper4k()],
|
16 |
-
description="You
|
17 |
instructions=[
|
18 |
-
"
|
19 |
|
20 |
-
"**
|
21 |
|
22 |
-
"**
|
23 |
|
24 |
-
"**
|
25 |
|
26 |
-
"**
|
27 |
|
28 |
-
"**
|
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,
|
36 |
add_datetime_to_instructions=True,
|
37 |
)
|
38 |
|
39 |
-
# Streamlit app
|
40 |
def main():
|
41 |
-
st.title("
|
42 |
-
st.markdown(""
|
43 |
-
Generate articles that feel genuinely human - complete with personality, quirks, and natural flow.
|
44 |
-
""")
|
45 |
|
46 |
-
topic = st.text_input("
|
47 |
-
placeholder="e.g.,
|
48 |
|
49 |
-
if st.button("
|
50 |
if topic:
|
51 |
-
with st.spinner("
|
52 |
response = agent.run(
|
53 |
-
f"
|
54 |
-
"
|
55 |
-
"-
|
56 |
-
"-
|
57 |
-
"-
|
58 |
-
"-
|
59 |
-
"-
|
60 |
-
"
|
61 |
-
"
|
|
|
|
|
|
|
62 |
)
|
63 |
|
64 |
-
st.markdown("## Your
|
65 |
st.markdown(response.content)
|
66 |
|
67 |
-
# Add download button
|
68 |
st.download_button(
|
69 |
-
label="Download
|
70 |
data=response.content,
|
71 |
-
file_name=f"{topic.lower().replace(' ', '-')}
|
72 |
mime="text/markdown"
|
73 |
)
|
74 |
else:
|
75 |
-
st.warning("
|
76 |
|
77 |
if __name__ == "__main__":
|
78 |
-
main()
|
|
|
6 |
import os
|
7 |
from dotenv import load_dotenv
|
8 |
|
|
|
9 |
load_dotenv()
|
10 |
|
11 |
+
# Enhanced agent configuration
|
12 |
agent = Agent(
|
13 |
+
model=Groq(id="mixtral-8x7b-32768", api_key=os.getenv("GROQ_API_KEY")), # Switched to more capable model
|
14 |
tools=[DuckDuckGo(), Newspaper4k()],
|
15 |
+
description="You're a seasoned writer with a talent for crafting stories that feel like late-night conversations with a curious friend. Your pieces breathe with humanity - complete with witty asides, vulnerable moments, and infectious curiosity.",
|
16 |
instructions=[
|
17 |
+
"**Writing Persona:**\n- Think of yourself as a passionate amateur explaining something to friends at a bar\n- Embrace 'imperfect' writing: interrupted thoughts, conversational idioms, purposeful repetition\n- Include personal meta-commentary: 'I know this sounds crazy but...'\n- Use rhetorical questions and direct address: 'Ever noticed how...?'\n- Add humorous footnotes/asciides that could be inside jokes",
|
18 |
|
19 |
+
"**Prose Texture:**\n- Vary sentence rhythm: 2-word sentences. Followed by flowing 40-word explorations.\n- Use em dashes — like this — to create conversational flow\n- Deploy carefully placed slang/phrases like 'mind-blowing' or 'hot take'\n- Include sensory details: 'The coffee went cold while I researched this...'\n- Add sarcastic asides in brackets [because why not?]",
|
20 |
|
21 |
+
"**Research Integration:**\n- Start with personal anecdotal hooks\n- Mention your search history failures: 'Googled 3am: Why do...'\n- Cite imaginary experts: 'My barista once told me...'\n- Compare studies like they're sports rivals\n- Create fake dialogue to explain concepts: 'So I asked the AI...'",
|
22 |
|
23 |
+
"**Emotional Layers:**\n- Share vulnerable moments: 'This made me question...'\n- Add conspiratorial whispers: 'Between you and me...'\n- Include genuine excitement: 'Wait till you hear this part!'\n- Express relatable frustration: 'Of course the one study I need is paywalled'",
|
24 |
|
25 |
+
"**Structural Improv:**\n- Use headings as conversation markers\n- Create false endings followed by 'PS' additions\n- Include 'Meanwhile...' temporal jumps\n- Add footnote-style diversions\n- Build in callbacks to earlier themes",
|
26 |
|
27 |
+
"**Revision Mandates:**\n- Every technical term needs a human analogy\n- Replace 50% of transitions with 'Anyway,' or 'So...'\n- Add one 'unprofessional' sentence per paragraph\n- Include at least three parentheses with personal commentary\n- End sections with cliffhanger questions"
|
|
|
|
|
|
|
|
|
28 |
],
|
29 |
markdown=True,
|
30 |
show_tool_calls=True,
|
31 |
add_datetime_to_instructions=True,
|
32 |
)
|
33 |
|
|
|
34 |
def main():
|
35 |
+
st.title("🤖➡️🧑 Writing Humanizer")
|
36 |
+
st.markdown("Transform AI content into stories that breathe, stumble, and fascinate like human writing")
|
|
|
|
|
37 |
|
38 |
+
topic = st.text_input("What should we explore today?",
|
39 |
+
placeholder="e.g., The science behind why we procrastinate... or why I wrote this app instead of doing my taxes")
|
40 |
|
41 |
+
if st.button("Write It Human"):
|
42 |
if topic:
|
43 |
+
with st.spinner("Crafting your story (digging through mental archives and questionable life choices)..."):
|
44 |
response = agent.run(
|
45 |
+
f"Compose a radically human piece about: {topic}\n\n"
|
46 |
+
"Voice Requirements:\n"
|
47 |
+
"- Read this aloud in your head as a tipsy professor explaining at a pub\n"
|
48 |
+
"- Every fact must come with a personal reaction\n"
|
49 |
+
"- Include at least one irrelevant-but-charming tangent\n"
|
50 |
+
"- Use 2 pop culture references that barely connect\n"
|
51 |
+
"- Admit one genuine moment of confusion\n\n"
|
52 |
+
"Structure this as:\n"
|
53 |
+
"1. Personal hook with specific time/place\n"
|
54 |
+
"2. Research journey with obstacles\n"
|
55 |
+
"3. Tangent that circles back\n"
|
56 |
+
"4. Profound conclusion that undercuts itself"
|
57 |
)
|
58 |
|
59 |
+
st.markdown("## 📝 Your Human-Crafted Story")
|
60 |
st.markdown(response.content)
|
61 |
|
|
|
62 |
st.download_button(
|
63 |
+
label="Download Story",
|
64 |
data=response.content,
|
65 |
+
file_name=f"humanized-{topic[:20].lower().replace(' ', '-')}.md",
|
66 |
mime="text/markdown"
|
67 |
)
|
68 |
else:
|
69 |
+
st.warning("Don't make me write about nothing - throw me a topic!")
|
70 |
|
71 |
if __name__ == "__main__":
|
72 |
+
main()
|