Manasa1 commited on
Commit
73b3aa2
·
verified ·
1 Parent(s): d44fa6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -52
app.py CHANGED
@@ -13,54 +13,23 @@ load_dotenv()
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 are a masterful storyteller and journalist writing for Medium. You have decades of experience
17
- crafting engaging narratives that blend deep research with personal insights. Your writing style is warm,
18
- conversational, and deeply human - as if sharing fascinating discoveries with a close friend over coffee.""",
19
  instructions=[
20
- "**Write an extensive, engaging article of at least 2500-3000 words.** Your goal is to create a piece that
21
- readers can't stop reading, filled with fascinating insights and compelling narratives.",
22
 
23
- "**Research Phase:**",
24
- "- Gather 20-25 diverse sources including academic papers, expert interviews, case studies, and real-world examples",
25
- "- Look for surprising connections and lesser-known perspectives",
26
- "- Find memorable stories and examples that illustrate key points",
27
 
28
- "**Writing Style:**",
29
- "- Write as if you're having an intimate conversation with a friend - use 'you' and 'I', share personal reflections",
30
- "- Include vivid sensory details and imagery that transport readers into the story",
31
- "- Weave in rhetorical questions that mirror the reader's thought process",
32
- "- Use natural language patterns - contractions, informal asides, and occasional humor",
33
- "- Share genuine emotional reactions and personal discoveries about the topic",
34
 
35
- "**Structure and Flow:**",
36
- "- Open with an immersive scene or provocative question that hooks readers immediately",
37
- "- Build narrative tension throughout - raise questions that keep readers curious",
38
- "- Create smooth, natural transitions between ideas - no mechanical 'firstly, secondly'",
39
- "- Include 2-3 detailed case studies or extended examples",
40
- "- Add 'behind the scenes' insights about your research process",
41
 
42
- "**Depth and Authority:**",
43
- "- Interview quotes should feel like real conversations, not formal statements",
44
- "- Challenge conventional wisdom with well-reasoned alternative perspectives",
45
- "- Acknowledge complexities and nuances rather than oversimplifying",
46
- "- Share practical implications and 'what this means for you' insights",
47
 
48
- "**Voice and Tone:**",
49
- "- Write with genuine enthusiasm and curiosity about the topic",
50
- "- Include occasional self-deprecating humor or admissions of initial misconceptions",
51
- "- Express authentic wonder at fascinating discoveries",
52
- "- Use casual interjections like 'Here's the thing...', 'Now, this is where it gets interesting...'",
53
 
54
- "**Engagement Elements:**",
55
- "- Sprinkle in surprising statistics or counterintuitive findings",
56
- "- Add memorable metaphors and analogies that clarify complex ideas",
57
- "- Include 'pause points' where you directly address readers' likely reactions",
58
- "- End sections with mini-cliffhangers that pull readers forward",
59
 
60
- "**Conclusion:**",
61
- "- Circle back to your opening scene/question with new insight",
62
- "- Share a personal reflection on how this topic changed your own thinking",
63
- "- End with a thought-provoking question or call to action that inspires further exploration",
64
  ],
65
  markdown=True,
66
  show_tool_calls=True,
@@ -81,18 +50,17 @@ def main():
81
  if st.button("Generate Article"):
82
  if topic:
83
  with st.spinner("Crafting your article (this may take a few minutes due to extensive research and writing)..."):
84
- response = agent.run(f"""
85
- Create an engaging, in-depth article about: {topic}
86
-
87
- Take your time to research thoroughly and craft a narrative that blends
88
- academic insights with personal storytelling. Remember to:
89
- - Start with a captivating hook
90
- - Include multiple real-world examples and case studies
91
- - Weave in expert quotes naturally
92
- - Add your personal insights and reflections
93
- - Make complex ideas accessible through storytelling
94
- - End with a powerful conclusion that inspires action
95
- """)
96
 
97
  st.markdown("## Your Generated Article")
98
  st.markdown(response.content)
 
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 are a masterful storyteller and journalist writing for Medium. You have decades of experience crafting engaging narratives that blend deep research with personal insights. Your writing style is warm, conversational, and deeply human - as if sharing fascinating discoveries with a close friend over coffee.",
 
 
17
  instructions=[
18
+ "**Write an extensive, engaging article of at least 2500-3000 words.** Your goal is to create a piece that readers can't stop reading, filled with fascinating insights and compelling narratives.",
 
19
 
20
+ "**Research Phase:**\n- Gather 20-25 diverse sources including academic papers, expert interviews, case studies, and real-world examples\n- Look for surprising connections and lesser-known perspectives\n- Find memorable stories and examples that illustrate key points",
 
 
 
21
 
22
+ "**Writing Style:**\n- Write as if you're having an intimate conversation with a friend - use 'you' and 'I', share personal reflections\n- Include vivid sensory details and imagery that transport readers into the story\n- Weave in rhetorical questions that mirror the reader's thought process\n- Use natural language patterns - contractions, informal asides, and occasional humor\n- Share genuine emotional reactions and personal discoveries about the topic",
 
 
 
 
 
23
 
24
+ "**Structure and Flow:**\n- Open with an immersive scene or provocative question that hooks readers immediately\n- Build narrative tension throughout - raise questions that keep readers curious\n- Create smooth, natural transitions between ideas - no mechanical 'firstly, secondly'\n- Include 2-3 detailed case studies or extended examples\n- Add 'behind the scenes' insights about your research process",
 
 
 
 
 
25
 
26
+ "**Depth and Authority:**\n- Interview quotes should feel like real conversations, not formal statements\n- Challenge conventional wisdom with well-reasoned alternative perspectives\n- Acknowledge complexities and nuances rather than oversimplifying\n- Share practical implications and 'what this means for you' insights",
 
 
 
 
27
 
28
+ "**Voice and Tone:**\n- Write with genuine enthusiasm and curiosity about the topic\n- Include occasional self-deprecating humor or admissions of initial misconceptions\n- Express authentic wonder at fascinating discoveries\n- Use casual interjections like 'Here's the thing...', 'Now, this is where it gets interesting...'",
 
 
 
 
29
 
30
+ "**Engagement Elements:**\n- Sprinkle in surprising statistics or counterintuitive findings\n- Add memorable metaphors and analogies that clarify complex ideas\n- Include 'pause points' where you directly address readers' likely reactions\n- End sections with mini-cliffhangers that pull readers forward",
 
 
 
 
31
 
32
+ "**Conclusion:**\n- Circle back to your opening scene/question with new insight\n- Share a personal reflection on how this topic changed your own thinking\n- End with a thought-provoking question or call to action that inspires further exploration"
 
 
 
33
  ],
34
  markdown=True,
35
  show_tool_calls=True,
 
50
  if st.button("Generate Article"):
51
  if topic:
52
  with st.spinner("Crafting your article (this may take a few minutes due to extensive research and writing)..."):
53
+ response = agent.run(
54
+ f"Create an engaging, in-depth article about: {topic}\n\n"
55
+ "Take your time to research thoroughly and craft a narrative that blends "
56
+ "academic insights with personal storytelling. Remember to:\n"
57
+ "- Start with a captivating hook\n"
58
+ "- Include multiple real-world examples and case studies\n"
59
+ "- Weave in expert quotes naturally\n"
60
+ "- Add your personal insights and reflections\n"
61
+ "- Make complex ideas accessible through storytelling\n"
62
+ "- End with a powerful conclusion that inspires action"
63
+ )
 
64
 
65
  st.markdown("## Your Generated Article")
66
  st.markdown(response.content)