Skip to content

Commit 3e479be

Browse files
committed
fixed requested items
1 parent feb7c2d commit 3e479be

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

agent/src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { newsPlugin } from "@ai16z/plugin-news";
2929
import { zgPlugin } from "@ai16z/plugin-0g";
3030
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
3131
import createGoatPlugin from "@ai16z/plugin-goat";
32-
import { intifacePlugin } from "@ai16z/plugin-intiface";
32+
//import { intifacePlugin } from "@ai16z/plugin-intiface";
3333
import { DirectClient } from "@ai16z/client-direct";
3434
import { aptosPlugin } from "@ai16z/plugin-aptos";
3535
import {
@@ -483,7 +483,6 @@ export async function createAgent(
483483
// character.plugins are handled when clients are added
484484
plugins: [
485485
bootstrapPlugin,
486-
newsPlugin,
487486
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
488487
? confluxPlugin
489488
: null,

packages/plugin-news/src/actions/news.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import {
1010
type Action,
1111
} from "@ai16z/eliza";
1212

13-
1413
export const currentNewsAction: Action = {
1514
name: "CURRENT_NEWS",
1615
similes: ["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"],
1716
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+
}
1822
return true;
1923
},
2024
description:
@@ -28,11 +32,6 @@ export const currentNewsAction: Action = {
2832
): Promise<boolean> => {
2933
async function getCurrentNews(searchTerm: string) {
3034
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-
3635
// Add quotes and additional context terms
3736
const enhancedSearchTerm = encodeURIComponent(`"${searchTerm}" AND (Spain OR Spanish OR Madrid OR Felipe)`);
3837

@@ -43,15 +42,15 @@ export const currentNewsAction: Action = {
4342
`sortBy=relevancy&` +
4443
`language=en&` +
4544
`pageSize=50&` +
46-
`apiKey=${apiKey}`
45+
`apiKey=${process.env.NEWS_API_KEY}`
4746
),
4847
fetch(
4948
`https://newsapi.org/v2/top-headlines?` +
5049
`q=${searchTerm}&` +
5150
`country=es&` +
5251
`language=en&` +
5352
`pageSize=50&` +
54-
`apiKey=${apiKey}`
53+
`apiKey=${process.env.NEWS_API_KEY}`
5554
)
5655
]);
5756

0 commit comments

Comments
 (0)