File tree 2 files changed +8
-10
lines changed
packages/plugin-news/src/actions
2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import { newsPlugin } from "@ai16z/plugin-news";
29
29
import { zgPlugin } from "@ai16z/plugin-0g" ;
30
30
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap" ;
31
31
import createGoatPlugin from "@ai16z/plugin-goat" ;
32
- import { intifacePlugin } from "@ai16z/plugin-intiface" ;
32
+ // import { intifacePlugin } from "@ai16z/plugin-intiface";
33
33
import { DirectClient } from "@ai16z/client-direct" ;
34
34
import { aptosPlugin } from "@ai16z/plugin-aptos" ;
35
35
import {
@@ -483,7 +483,6 @@ export async function createAgent(
483
483
// character.plugins are handled when clients are added
484
484
plugins : [
485
485
bootstrapPlugin ,
486
- newsPlugin ,
487
486
getSecret ( character , "CONFLUX_CORE_PRIVATE_KEY" )
488
487
? confluxPlugin
489
488
: null ,
Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ import {
10
10
type Action ,
11
11
} from "@ai16z/eliza" ;
12
12
13
-
14
13
export const currentNewsAction : Action = {
15
14
name : "CURRENT_NEWS" ,
16
15
similes : [ "NEWS" , "GET_NEWS" , "GET_CURRENT_NEWS" ] ,
17
16
validate : async ( _runtime : IAgentRuntime , _message : Memory ) => {
17
+ const apiKey = process . env . NEWS_API_KEY ;
18
+ if ( ! apiKey ) {
19
+ console . error ( 'NEWS_API_KEY environment variable is not set' ) ;
20
+ return false ;
21
+ }
18
22
return true ;
19
23
} ,
20
24
description :
@@ -28,11 +32,6 @@ export const currentNewsAction: Action = {
28
32
) : Promise < boolean > => {
29
33
async function getCurrentNews ( searchTerm : string ) {
30
34
try {
31
- const apiKey = process . env . NEWS_API_KEY ;
32
- if ( ! apiKey ) {
33
- throw new Error ( 'NEWS_API_KEY environment variable is not set' ) ;
34
- }
35
-
36
35
// Add quotes and additional context terms
37
36
const enhancedSearchTerm = encodeURIComponent ( `"${ searchTerm } " AND (Spain OR Spanish OR Madrid OR Felipe)` ) ;
38
37
@@ -43,15 +42,15 @@ export const currentNewsAction: Action = {
43
42
`sortBy=relevancy&` +
44
43
`language=en&` +
45
44
`pageSize=50&` +
46
- `apiKey=${ apiKey } `
45
+ `apiKey=${ process . env . NEWS_API_KEY } `
47
46
) ,
48
47
fetch (
49
48
`https://newsapi.org/v2/top-headlines?` +
50
49
`q=${ searchTerm } &` +
51
50
`country=es&` +
52
51
`language=en&` +
53
52
`pageSize=50&` +
54
- `apiKey=${ apiKey } `
53
+ `apiKey=${ process . env . NEWS_API_KEY } `
55
54
)
56
55
] ) ;
57
56
You can’t perform that action at this time.
0 commit comments