forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elizaOS#1248 from ileana-pr/news-plugin
feat: news-plugin
- Loading branch information
Showing
12 changed files
with
468 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
|
||
!dist/** | ||
!package.json | ||
!readme.md | ||
!tsup.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
# @elizaos/plugin-news | ||
|
||
A plugin for fetching and handling real-time news data through NewsAPI integration. | ||
|
||
## Overview | ||
|
||
This plugin provides functionality to: | ||
- Fetch latest news articles from NewsAPI | ||
- Search news by specific topics or keywords | ||
- Get article summaries including titles, descriptions, and URLs | ||
- Limit results to most recent and relevant content | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @elizaos/plugin-news | ||
``` | ||
|
||
## Configuration | ||
|
||
The plugin requires the following environment variable: | ||
|
||
```env | ||
NEWS_API_KEY=your_newsapi_key # Required for accessing NewsAPI | ||
``` | ||
|
||
## Usage | ||
|
||
Import and register the plugin in your Eliza configuration: | ||
|
||
```typescript | ||
import { newsPlugin } from "@elizaos/plugin-news"; | ||
|
||
export default { | ||
plugins: [newsPlugin], | ||
// ... other configuration | ||
}; | ||
``` | ||
|
||
## Features | ||
|
||
### Current News Action | ||
|
||
The plugin provides a `CURRENT_NEWS` action that responds to various news-related queries: | ||
|
||
```typescript | ||
// Example queries the action responds to: | ||
"what's the latest news about <searchTerm>?" | ||
"can you show me the latest news about <searchTerm>?" | ||
"what's in the <searchTerm> news today?" | ||
"show me current events about <searchTerm>?" | ||
"what's going on in the world of <searchTerm>?" | ||
"give me the latest headlines about <searchTerm>?" | ||
"show me news updates about <searchTerm>?" | ||
"what are today's top stories about <searchTerm>?" | ||
``` | ||
|
||
The action returns up to 5 recent articles, including: | ||
- Article title | ||
- Description | ||
- URL | ||
- Content preview (up to 1000 characters) | ||
|
||
## Development | ||
|
||
### Building | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
### Development Mode | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
### Linting | ||
|
||
```bash | ||
npm run lint | ||
``` | ||
|
||
### Project Structure | ||
|
||
``` | ||
plugin-news/ | ||
├── src/ | ||
│ ├── actions/ # Action implementations | ||
│ │ ├── news.ts # Current news action | ||
│ │ └── index.ts # Action exports | ||
│ └── index.ts # Main plugin export | ||
├── package.json | ||
└── tsconfig.json | ||
``` | ||
|
||
## Dependencies | ||
|
||
- `@ai16z/eliza`: Core Eliza framework | ||
- `tsup`: Build tool for TypeScript packages | ||
- Other standard dependencies listed in package.json | ||
|
||
## API Reference | ||
|
||
### Actions | ||
|
||
- `CURRENT_NEWS`: Main action for fetching news | ||
- Aliases: `["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"]` | ||
- Automatically extracts search terms from user messages | ||
- Returns formatted news articles with titles, descriptions, and URLs | ||
|
||
### Response Format | ||
|
||
```typescript | ||
interface NewsResponse { | ||
title: string; | ||
description: string; | ||
url: string; | ||
content: string; // Limited to 1000 characters | ||
} | ||
``` | ||
|
||
## Future Enhancements | ||
|
||
1. **Additional News Sources** | ||
- Integration with multiple news APIs | ||
- RSS feed support | ||
- Social media news aggregation | ||
|
||
2. **Content Analysis** | ||
- Sentiment analysis of news articles | ||
- Topic categorization | ||
- Trend detection | ||
- Fact-checking integration | ||
|
||
3. **Customization Options** | ||
- User preferences for news sources | ||
- Custom filtering rules | ||
- Personalized news feeds | ||
- Language preferences | ||
|
||
4. **Advanced Search** | ||
- Date range filtering | ||
- Source filtering | ||
- Category-based search | ||
- Advanced query syntax | ||
|
||
5. **Performance Improvements** | ||
- Caching layer | ||
- Rate limiting optimization | ||
- Response compression | ||
- Batch processing | ||
|
||
We welcome community feedback and contributions to help prioritize these enhancements. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. | ||
|
||
|
||
## License | ||
|
||
This plugin is part of the Eliza project. See the main project repository for license information. | ||
|
||
## Credits | ||
|
||
This plugin integrates with and builds upon several key technologies: | ||
|
||
- [NewsAPI](https://newsapi.org/): News data provider | ||
|
||
Plugin generated from Eliza coding tutorial [Agent Dev School Part 2](https://www.youtube.com/watch?v=XenGeAcPAQo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import eslintGlobalConfig from "../../eslint.config.mjs"; | ||
|
||
export default [...eslintGlobalConfig]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@elizaos/plugin-news", | ||
"version": "0.1.5-alpha.5", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@elizaos/core": "workspace:*", | ||
"tsup": "8.3.5" | ||
}, | ||
"scripts": { | ||
"build": "tsup --format esm --dts", | ||
"dev": "tsup --format esm --dts --watch", | ||
"lint": "eslint . --fix" | ||
}, | ||
"peerDependencies": { | ||
"whatwg-url": "7.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./news.ts"; | ||
|
Oops, something went wrong.