Ani14 commited on
Commit
bc0e336
·
verified ·
1 Parent(s): f7fc82d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -73,12 +73,6 @@ def autonomous_research_agent(topic):
73
  web = search_duckduckgo(topic)
74
  images = get_image_urls(topic)
75
 
76
- image_md = ""
77
- if images:
78
- for img in images:
79
- image_md += f"![Image]({img}) "
80
- image_md += "\n\n"
81
-
82
  arxiv_md = ""
83
  for p in arxiv:
84
  arxiv_md += f"- [{p['title']}]({p['url']})\n> {p['summary'][:300]}...\n\n"
@@ -94,8 +88,6 @@ def autonomous_research_agent(topic):
94
  prompt = f"""
95
  # Research Topic: {topic}
96
 
97
- {image_md}
98
-
99
  ## ArXiv:
100
  {arxiv_md}
101
 
@@ -121,7 +113,7 @@ Now synthesize this information into:
121
  if web_md:
122
  response += "**Web:**\n" + web_md
123
 
124
- return response
125
 
126
  # --- Streamlit UI ---
127
  st.set_page_config("Autonomous Research Assistant", layout="wide")
@@ -134,10 +126,17 @@ topic = st.text_input("Enter a research topic:")
134
  if st.button("Run Research Agent"):
135
  with st.spinner("Gathering sources & thinking..."):
136
  try:
137
- result = autonomous_research_agent(topic)
 
 
 
 
 
 
 
138
  st.session_state.chat_history.append({"role": "user", "content": topic})
139
- st.session_state.chat_history.append({"role": "assistant", "content": result})
140
- st.markdown(result)
141
  except Exception as e:
142
  st.error(f"Failed: {e}")
143
 
 
73
  web = search_duckduckgo(topic)
74
  images = get_image_urls(topic)
75
 
 
 
 
 
 
 
76
  arxiv_md = ""
77
  for p in arxiv:
78
  arxiv_md += f"- [{p['title']}]({p['url']})\n> {p['summary'][:300]}...\n\n"
 
88
  prompt = f"""
89
  # Research Topic: {topic}
90
 
 
 
91
  ## ArXiv:
92
  {arxiv_md}
93
 
 
113
  if web_md:
114
  response += "**Web:**\n" + web_md
115
 
116
+ return response, images
117
 
118
  # --- Streamlit UI ---
119
  st.set_page_config("Autonomous Research Assistant", layout="wide")
 
126
  if st.button("Run Research Agent"):
127
  with st.spinner("Gathering sources & thinking..."):
128
  try:
129
+ response, images = autonomous_research_agent(topic)
130
+
131
+ # Display images
132
+ if images:
133
+ st.subheader("🖼️ Relevant Images")
134
+ st.image(images, width=300)
135
+
136
+ # Display markdown response
137
  st.session_state.chat_history.append({"role": "user", "content": topic})
138
+ st.session_state.chat_history.append({"role": "assistant", "content": response})
139
+ st.markdown(response)
140
  except Exception as e:
141
  st.error(f"Failed: {e}")
142