SHAMIL SHAHBAZ AWAN commited on
Commit
c31642a
Β·
verified Β·
1 Parent(s): f2eb88d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -160,25 +160,33 @@ def educational_resources_agent():
160
  Retrieves and formats a list of high-quality educational resources on astronomy and space science.
161
  Uses Tavily search to find trusted sources such as NASA, ESA, and other reputable platforms.
162
 
163
- Args:
164
- state (AgentState): The current agent state, containing user input.
165
-
166
  Returns:
167
- dict: A dictionary containing a list of educational resources with titles, descriptions, and clickable links.
168
-
169
  Raises:
170
  Exception: If an error occurs while retrieving the resources or formatting the response.
171
  """
172
  try:
173
  # Use Tavily search to retrieve educational resources based on the query
174
- resources = search.invoke({"query": "Provide a curated list of high-quality educational resources on astronomy and space science, from trusted sources like NASA, ESA, and reputable educational platforms."})
 
 
175
  if not resources:
176
  return {"output": "No educational resources found. Please try again."}
177
 
 
178
  formatted_resources = "\n\n".join(
179
- [f"πŸ“˜ {r.get('title', 'Untitled Resource')}\nπŸ”— {r.get('url', 'No URL provided')}" for r in resources]
180
  )
181
- return {"output": f"πŸŽ“ Educational Resources Agent:\n\n{formatted_resources}"}
 
 
 
 
 
 
 
 
 
182
  except Exception as e:
183
  return {"output": f"Educational Resources Agent Error: {str(e)}"}
184
 
 
160
  Retrieves and formats a list of high-quality educational resources on astronomy and space science.
161
  Uses Tavily search to find trusted sources such as NASA, ESA, and other reputable platforms.
162
 
 
 
 
163
  Returns:
164
+ dict: A dictionary containing an informative summary and a list of educational resources with titles, descriptions, and clickable links.
 
165
  Raises:
166
  Exception: If an error occurs while retrieving the resources or formatting the response.
167
  """
168
  try:
169
  # Use Tavily search to retrieve educational resources based on the query
170
+ resources = search.invoke({
171
+ "query": "Provide a curated list of high-quality educational resources on astronomy and space science, from trusted sources like NASA, ESA, and reputable educational platforms."
172
+ })
173
  if not resources:
174
  return {"output": "No educational resources found. Please try again."}
175
 
176
+ # Format each resource as a clickable link along with a description
177
  formatted_resources = "\n\n".join(
178
+ [f"πŸ“˜ **{r.get('title', 'Untitled Resource')}**\nπŸ”— [Visit Resource]({r.get('url', 'No URL provided')})" for r in resources]
179
  )
180
+
181
+ # Add an informative introduction generated by LLM or manually written text
182
+ informative_text = (
183
+ "Based on your query, here is a curated list of high-quality educational resources on astronomy and space science. "
184
+ "These resources have been carefully selected from trusted institutions such as NASA, ESA, and reputable academic platforms. "
185
+ "They provide a wealth of knowledge on various space topics, including recent discoveries, research articles, and interactive educational materials."
186
+ )
187
+
188
+ full_response = f"πŸŽ“ **Educational Resources Agent:**\n\n{informative_text}\n\n{formatted_resources}"
189
+ return {"output": full_response}
190
  except Exception as e:
191
  return {"output": f"Educational Resources Agent Error: {str(e)}"}
192