mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
update doc SpaceNewsKnowledgeSource code snippet (#2275)
Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
This commit is contained in:
@@ -460,12 +460,12 @@ class SpaceNewsKnowledgeSource(BaseKnowledgeSource):
|
|||||||
data = response.json()
|
data = response.json()
|
||||||
articles = data.get('results', [])
|
articles = data.get('results', [])
|
||||||
|
|
||||||
formatted_data = self._format_articles(articles)
|
formatted_data = self.validate_content(articles)
|
||||||
return {self.api_endpoint: formatted_data}
|
return {self.api_endpoint: formatted_data}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"Failed to fetch space news: {str(e)}")
|
raise ValueError(f"Failed to fetch space news: {str(e)}")
|
||||||
|
|
||||||
def _format_articles(self, articles: list) -> str:
|
def validate_content(self, articles: list) -> str:
|
||||||
"""Format articles into readable text."""
|
"""Format articles into readable text."""
|
||||||
formatted = "Space News Articles:\n\n"
|
formatted = "Space News Articles:\n\n"
|
||||||
for article in articles:
|
for article in articles:
|
||||||
|
|||||||
Reference in New Issue
Block a user