mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-25 16:18:13 +00:00
Update docs for new knowledge
This commit is contained in:
@@ -159,12 +159,12 @@ class SpaceNewsKnowledgeSource(BaseKnowledgeSource):
|
|||||||
formatted = "Space News Articles:\n\n"
|
formatted = "Space News Articles:\n\n"
|
||||||
for article in articles:
|
for article in articles:
|
||||||
formatted += f"""
|
formatted += f"""
|
||||||
Title: {article['title']}
|
Title: {article['title']}
|
||||||
Published: {article['published_at']}
|
Published: {article['published_at']}
|
||||||
Summary: {article['summary']}
|
Summary: {article['summary']}
|
||||||
News Site: {article['news_site']}
|
News Site: {article['news_site']}
|
||||||
URL: {article['url']}
|
URL: {article['url']}
|
||||||
-------------------"""
|
-------------------"""
|
||||||
return formatted
|
return formatted
|
||||||
|
|
||||||
def add(self) -> None:
|
def add(self) -> None:
|
||||||
@@ -174,17 +174,12 @@ URL: {article['url']}
|
|||||||
chunks = self._chunk_text(text)
|
chunks = self._chunk_text(text)
|
||||||
self.chunks.extend(chunks)
|
self.chunks.extend(chunks)
|
||||||
|
|
||||||
self.save_documents(metadata={
|
self.save_documents()
|
||||||
"source": "space_news_api",
|
|
||||||
"timestamp": datetime.now().isoformat(),
|
|
||||||
"article_count": self.limit
|
|
||||||
})
|
|
||||||
|
|
||||||
# Create knowledge source
|
# Create knowledge source
|
||||||
recent_news = SpaceNewsKnowledgeSource(
|
recent_news = SpaceNewsKnowledgeSource(
|
||||||
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles",
|
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles",
|
||||||
limit=10,
|
limit=10,
|
||||||
metadata={"category": "recent_news", "source": "spaceflight_news"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create specialized agent
|
# Create specialized agent
|
||||||
@@ -250,7 +245,7 @@ The latest developments in space exploration, based on recent space news article
|
|||||||
- Implements three key methods:
|
- Implements three key methods:
|
||||||
- `load_content()`: Fetches articles from the API
|
- `load_content()`: Fetches articles from the API
|
||||||
- `_format_articles()`: Structures the articles into readable text
|
- `_format_articles()`: Structures the articles into readable text
|
||||||
- `add()`: Processes and stores the content with metadata
|
- `add()`: Processes and stores the content
|
||||||
|
|
||||||
2. **Agent Configuration**:
|
2. **Agent Configuration**:
|
||||||
- Specialized role as a Space News Analyst
|
- Specialized role as a Space News Analyst
|
||||||
@@ -284,14 +279,12 @@ You can customize the API query by modifying the endpoint URL:
|
|||||||
recent_news = SpaceNewsKnowledgeSource(
|
recent_news = SpaceNewsKnowledgeSource(
|
||||||
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles",
|
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles",
|
||||||
limit=20, # Increase the number of articles
|
limit=20, # Increase the number of articles
|
||||||
metadata={"category": "recent_news"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add search parameters
|
# Add search parameters
|
||||||
recent_news = SpaceNewsKnowledgeSource(
|
recent_news = SpaceNewsKnowledgeSource(
|
||||||
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles?search=NASA", # Search for NASA news
|
api_endpoint="https://api.spaceflightnewsapi.net/v4/articles?search=NASA", # Search for NASA news
|
||||||
limit=10,
|
limit=10,
|
||||||
metadata={"category": "nasa_news"}
|
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -299,14 +292,12 @@ recent_news = SpaceNewsKnowledgeSource(
|
|||||||
|
|
||||||
<AccordionGroup>
|
<AccordionGroup>
|
||||||
<Accordion title="Content Organization">
|
<Accordion title="Content Organization">
|
||||||
- Use descriptive metadata for better filtering
|
|
||||||
- Keep chunk sizes appropriate for your content type
|
- Keep chunk sizes appropriate for your content type
|
||||||
- Consider content overlap for context preservation
|
- Consider content overlap for context preservation
|
||||||
- Organize related information into separate knowledge sources
|
- Organize related information into separate knowledge sources
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
<Accordion title="Performance Tips">
|
<Accordion title="Performance Tips">
|
||||||
- Use metadata filtering to narrow search scope
|
|
||||||
- Adjust chunk sizes based on content complexity
|
- Adjust chunk sizes based on content complexity
|
||||||
- Configure appropriate embedding models
|
- Configure appropriate embedding models
|
||||||
- Consider using local embedding providers for faster processing
|
- Consider using local embedding providers for faster processing
|
||||||
|
|||||||
Reference in New Issue
Block a user