Manasa1 commited on
Commit
fc66173
·
verified ·
1 Parent(s): de915f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -18
app.py CHANGED
@@ -10,20 +10,22 @@ from dotenv import load_dotenv
10
  # Load environment variables
11
  load_dotenv()
12
 
13
- # Create the Agent with a Medium-optimized writing style
14
  agent = Agent(
15
  model=Groq(id="llama-3.1-8b-instant", api_key=os.getenv("GROQ_API_KEY")),
16
  tools=[DuckDuckGo(), Newspaper4k()],
17
- description="Write in an engaging, insightful, and well-structured way—like a top Medium writer.",
18
  instructions=[
19
- "Write as if you're a professional Medium writer—engaging, insightful, and structured.",
20
- "Blend storytelling with analysis. Open with an interesting hook or personal anecdote, then lead into the core insights.",
21
- "Use a warm, personal tone but keep the writing polished. Avoid excessive slang or overly casual phrases.",
22
- "Make the article skimmable—use subheadings, bullet points, and occasional bold highlights.",
23
- "Add thoughtful insights, researched points, and real-world examples to support your arguments.",
24
- "Use smooth transitions and natural paragraph breaks. Keep readers engaged without being too rigid.",
25
- "Write with a clear introduction, a well-developed body, and a natural conclusion that leaves readers with a takeaway.",
26
- "Most importantly, make the reader feel like they’ve gained something valuable—whether a new perspective, useful knowledge, or an interesting story.",
 
 
27
  ],
28
  markdown=True,
29
  show_tool_calls=True,
@@ -32,9 +34,9 @@ agent = Agent(
32
 
33
  # Streamlit app
34
  def main():
35
- st.title("📝 Medium-Optimized Article Generator")
36
  st.markdown("""
37
- Generate articles that are engaging, well-structured, and ready for Medium's audience.
38
  """)
39
 
40
  topic = st.text_input(
@@ -44,19 +46,19 @@ def main():
44
 
45
  if st.button("Generate Article"):
46
  if topic:
47
- with st.spinner("Writing your article... (Expect a thoughtful, engaging piece)"):
48
 
49
- # Medium-friendly prompt variations
50
  prompt_variations = [
51
- f"Write a well-structured Medium article about {topic}. Open with an engaging hook, share insights, and conclude with a strong takeaway.",
52
- f"Create a compelling Medium-style article on {topic}. Use storytelling, clear structure, and a warm yet professional tone.",
53
- f"Write an insightful and engaging blog post about {topic}, optimized for Medium. Blend personal storytelling with research-backed insights.",
54
  ]
55
  prompt = random.choice(prompt_variations)
56
 
57
  response = agent.run(prompt)
58
 
59
- st.markdown("## 📝 Your Medium-Ready Article")
60
  st.markdown(response.content)
61
 
62
  # Provide a regeneration option
 
10
  # Load environment variables
11
  load_dotenv()
12
 
13
+ # Create the Agent with a more natural, imperfect human-like writing style
14
  agent = Agent(
15
  model=Groq(id="llama-3.1-8b-instant", api_key=os.getenv("GROQ_API_KEY")),
16
  tools=[DuckDuckGo(), Newspaper4k()],
17
+ description="You write like a real person, not a robot. Your writing is simple, engaging, and casual—like a conversation with a friend.",
18
  instructions=[
19
+ "Write like a real human, not AI. Keep it simple, clear, and natural.",
20
+ "Use everyday language. No fancy words. No robotic structures.",
21
+ "Make sentences short and varied—some are quick, others take their time.",
22
+ "Talk to the reader. Imagine you're chatting with a friend.",
23
+ "Use words like 'honestly,' 'to be fair,' 'you know what I mean?' for a natural feel.",
24
+ "Add a bit of personality—some humor, a quick side note, maybe even a mild complaint.",
25
+ "Don't try too hard to sound smart. Just be real and interesting.",
26
+ "Forget perfect grammar. If a sentence feels better as a fragment, use it.",
27
+ "If something is surprising, react to it. If something is boring, admit it.",
28
+ "Most importantly: Make it sound like something a human actually wrote."
29
  ],
30
  markdown=True,
31
  show_tool_calls=True,
 
34
 
35
  # Streamlit app
36
  def main():
37
+ st.title("📝 Real Human-Like Article Generator")
38
  st.markdown("""
39
+ Get articles that actually sound like a person wrote them—simple, natural, and engaging.
40
  """)
41
 
42
  topic = st.text_input(
 
46
 
47
  if st.button("Generate Article"):
48
  if topic:
49
+ with st.spinner("Writing your article... (Making it sound as real as possible)"):
50
 
51
+ # Human-like prompt variations
52
  prompt_variations = [
53
+ f"Write an article about {topic} that sounds like a real person wrote it. Keep it casual, simple, and engaging.",
54
+ f"Create a natural, fun article on {topic}. Write like you're telling a friend about it.",
55
+ f"Write a casual, human-like article on {topic}. No complex words, no robotic structure—just natural writing.",
56
  ]
57
  prompt = random.choice(prompt_variations)
58
 
59
  response = agent.run(prompt)
60
 
61
+ st.markdown("## 📝 Your Naturally Written Article")
62
  st.markdown(response.content)
63
 
64
  # Provide a regeneration option