update doc SpaceNewsKnowledgeSource code snippet (#2275)

Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
This commit is contained in:
Amine Saihi
2025-03-20 16:06:21 +00:00
committed by GitHub
parent 6e94edb777
commit f8f9df6d1d

View File

@@ -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: