Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +34 -5
src/streamlit_app.py
CHANGED
|
@@ -6,14 +6,13 @@ from agents import set_default_openai_key
|
|
| 6 |
from firecrawl import FirecrawlApp
|
| 7 |
from agents.tool import function_tool
|
| 8 |
|
| 9 |
-
#Setup page configuration using streamlit
|
| 10 |
st.set_page_config(
|
| 11 |
-
page_title = "OpenAI based
|
| 12 |
-
page_icon = "",
|
| 13 |
layout = "wide"
|
| 14 |
)
|
| 15 |
|
| 16 |
-
|
| 17 |
# Initialize session state for API Key if don't exist
|
| 18 |
if "openai_api_key" not in st.session_state:
|
| 19 |
st.session_state.openai_api_key = ""
|
|
@@ -121,4 +120,34 @@ elaboration_agent = Agent(
|
|
| 121 |
4. Preserve the original structure while making it more comprehensive
|
| 122 |
5. Ensure all additions are relevant and valuable to the topic.
|
| 123 |
"""
|
| 124 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from firecrawl import FirecrawlApp
|
| 7 |
from agents.tool import function_tool
|
| 8 |
|
| 9 |
+
# Setup the page configuration (done using streamlit)
|
| 10 |
st.set_page_config(
|
| 11 |
+
page_title = "OpenAI based Deep Research Agent",
|
| 12 |
+
page_icon = "📚",
|
| 13 |
layout = "wide"
|
| 14 |
)
|
| 15 |
|
|
|
|
| 16 |
# Initialize session state for API Key if don't exist
|
| 17 |
if "openai_api_key" not in st.session_state:
|
| 18 |
st.session_state.openai_api_key = ""
|
|
|
|
| 120 |
4. Preserve the original structure while making it more comprehensive
|
| 121 |
5. Ensure all additions are relevant and valuable to the topic.
|
| 122 |
"""
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
async def run_research_process(topic : str):
|
| 126 |
+
"""Run the complete research process"""
|
| 127 |
+
# Step 1 - Intial Research
|
| 128 |
+
with st.spinner("Conducting initial research..."):
|
| 129 |
+
research_results = await Runner.run(research_agent, topic)
|
| 130 |
+
initial_report = research_results.final_output
|
| 131 |
+
# Display initial report
|
| 132 |
+
with st.expander("View Initial Research Report"):
|
| 133 |
+
st.markdown(initial_report)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
# Step 2 - Enhance the report
|
| 137 |
+
with st.spinner("Enhancing the report with additional information..."):
|
| 138 |
+
elaboration_input = f"""
|
| 139 |
+
RESEARCH_TOPIC = {topic}
|
| 140 |
+
INITIAL RESEARCH REPORT:
|
| 141 |
+
{initial_report}
|
| 142 |
+
Please enhance this research report with additional information,
|
| 143 |
+
examples, case studies, and deeper insights while maintaining its
|
| 144 |
+
academic rigor and factual accuracy.
|
| 145 |
+
"""
|
| 146 |
+
|
| 147 |
+
elaboration_results = await Runner.run(elaboration_agent, elaboration_input)
|
| 148 |
+
enhanced_report = elaboration_results.final_output
|
| 149 |
+
|
| 150 |
+
return enhanced_report
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|