Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,52 @@ def generate_response(topic, length):
|
|
100 |
st.error("⚠️ Agents are not initialized. Please check the system or restart the app.")
|
101 |
return {"response": "Error: Agents not initialized."}
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
|
106 |
# Define Tabs
|
|
|
100 |
st.error("⚠️ Agents are not initialized. Please check the system or restart the app.")
|
101 |
return {"response": "Error: Agents not initialized."}
|
102 |
|
103 |
+
# Refined prompt for better essay generation
|
104 |
+
refined_prompt = f"""
|
105 |
+
Write a well-structured, engaging, and informative essay on "{topic}". The essay should be approximately {length} words and follow this structured format:
|
106 |
+
|
107 |
+
## 1. Title
|
108 |
+
- Generate a compelling, creative, and relevant title that encapsulates the theme of the essay.
|
109 |
+
|
110 |
+
## 2. Introduction (100-150 words)
|
111 |
+
- Clearly define the topic and its importance in the broader context.
|
112 |
+
- Provide a strong **thesis statement** that outlines the essay’s key argument.
|
113 |
+
- Briefly mention the **key themes** that will be explored in the body.
|
114 |
+
- Engage the reader with a thought-provoking fact, quote, or question.
|
115 |
+
|
116 |
+
## 3. Main Body (Ensure clear organization and logical transitions)
|
117 |
+
Each section should:
|
118 |
+
- **Have a distinct, engaging subheading**.
|
119 |
+
- **Begin with a topic sentence** introducing the section’s main idea.
|
120 |
+
- **Include real-world examples, historical references, or statistical data**.
|
121 |
+
- **Maintain smooth transitions** between sections for cohesive reading.
|
122 |
+
|
123 |
+
### Suggested Sections (Modify as Needed)
|
124 |
+
- **Historical Context**: Trace the origins and evolution of the topic over time.
|
125 |
+
- **Key Aspects**: Break down essential components (e.g., cultural, political, economic influences).
|
126 |
+
- **Modern Challenges & Debates**: Discuss **contemporary issues** and **conflicting viewpoints**.
|
127 |
+
- **Impact & Future Trends**: Examine how the topic influences the present and future.
|
128 |
+
|
129 |
+
## 4. Conclusion (100-150 words)
|
130 |
+
- Concisely summarize key insights and arguments.
|
131 |
+
- Reinforce the essay’s thesis in light of the discussion.
|
132 |
+
- End with a **thought-provoking final statement**, such as:
|
133 |
+
- A **rhetorical question**.
|
134 |
+
- A **call to action**.
|
135 |
+
- A **broader reflection** on the topic’s long-term significance.
|
136 |
+
|
137 |
+
## 5. Writing & Formatting Guidelines
|
138 |
+
- Maintain **formal, engaging, and precise** language.
|
139 |
+
- Ensure **clear paragraph structure and logical progression**.
|
140 |
+
- Avoid redundancy; keep insights sharp and impactful.
|
141 |
+
- Use **examples, expert opinions, or historical events** to strengthen arguments.
|
142 |
+
- Provide **citations or references** when possible.
|
143 |
+
"""
|
144 |
+
|
145 |
+
response = app.graph.invoke(input={"topic": topic, "length": length, "prompt": refined_prompt})
|
146 |
+
|
147 |
+
return response
|
148 |
+
|
149 |
|
150 |
|
151 |
# Define Tabs
|