Spaces:
Sleeping
Sleeping
Agent output
Browse files- src/streamlit_app.py +34 -0
src/streamlit_app.py
CHANGED
|
@@ -182,3 +182,37 @@ async def run_research_process(topic: str):
|
|
| 182 |
enhanced_report= elaboration_result.final_output
|
| 183 |
|
| 184 |
return enhanced report
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
enhanced_report= elaboration_result.final_output
|
| 183 |
|
| 184 |
return enhanced report
|
| 185 |
+
|
| 186 |
+
## Main Research Process
|
| 187 |
+
|
| 188 |
+
if st.button("Start Research", disabled= not (openai_api_key and firecrawl_api_key and research_topic)):
|
| 189 |
+
if not openai_api_key or not firecrawl_api_key:
|
| 190 |
+
st.warning("Please enter both API keys to start the research!")
|
| 191 |
+
elif not research_topic:
|
| 192 |
+
st.warning("No topic provided! Please enter a research topic")
|
| 193 |
+
else:
|
| 194 |
+
try:
|
| 195 |
+
## create a placeholder for final report
|
| 196 |
+
report_placeholder= st.empty()
|
| 197 |
+
|
| 198 |
+
# Run the research process
|
| 199 |
+
enhanced_report = asyncio.run(run_research_process(research_topic))
|
| 200 |
+
|
| 201 |
+
# Display the results
|
| 202 |
+
report_placeholder.markdown(f"## {research_topic} Report")
|
| 203 |
+
report_placeholder.markdown(enhanced_report)
|
| 204 |
+
## Add a download button
|
| 205 |
+
st.download_button(
|
| 206 |
+
"Download Report",
|
| 207 |
+
enhanced_report,
|
| 208 |
+
filename= f"{research_topic.replace(' ','_')}_report.md",
|
| 209 |
+
mime= "text/markdown"
|
| 210 |
+
)
|
| 211 |
+
except Exception as e:
|
| 212 |
+
st.error(f"An error occurred: {str(e)}")
|
| 213 |
+
|
| 214 |
+
## Footer
|
| 215 |
+
|
| 216 |
+
st.markdown("----------")
|
| 217 |
+
st.markdown("Powered by OpenAI SDK and Firecrawl")
|
| 218 |
+
|