Final part
Browse files- src/streamlit_app.py +31 -0
src/streamlit_app.py
CHANGED
@@ -154,3 +154,34 @@ async def run_research_process(topic : str):
|
|
154 |
|
155 |
return enhanced_report
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
return enhanced_report
|
156 |
|
157 |
+
# Main Research Process
|
158 |
+
if st.button("Start Research", disabled = not (openai_api_key and firecrawl_api_key and research_topic)):
|
159 |
+
if not openai_api_key or not firecrawl_api_key:
|
160 |
+
st.warning("Please enter both the API Key to start the research!!")
|
161 |
+
elif not research_topic:
|
162 |
+
st.warning("No topic provided! Please enter a research topic!!")
|
163 |
+
else:
|
164 |
+
try:
|
165 |
+
# Create a placeholder for final report
|
166 |
+
report_placeholder = st.empty()
|
167 |
+
|
168 |
+
# Run the research process
|
169 |
+
enhanced_report = asyncio.run(run_research_process(research_topic))
|
170 |
+
|
171 |
+
# Display the results
|
172 |
+
report_placeholder.markdown(f"## {research_topic} Report")
|
173 |
+
report_placeholder.markdown(enhanced_report)
|
174 |
+
|
175 |
+
# Add download button
|
176 |
+
st.download_button(
|
177 |
+
"Download Report",
|
178 |
+
enhanced_report,
|
179 |
+
file_name = f"{research_topic.replace(' ', '_')}_report.md",
|
180 |
+
mime = "text/markdown"
|
181 |
+
)
|
182 |
+
except Exception as e:
|
183 |
+
st.error(f"An error occured: {str(e)}")
|
184 |
+
|
185 |
+
# Footer
|
186 |
+
st.markdown("---------------")
|
187 |
+
st.markdown("Powered by OpenAI Agents SDK and Firecrawl")
|