Skip to content

Commit 9a9d0ff

Browse files
committed
fixed requested items
1 parent 338651b commit 9a9d0ff

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

agent/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ export async function createAgent(
710710
// character.plugins are handled when clients are added
711711
plugins: [
712712
bootstrapPlugin,
713-
newsPlugin,
714713
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
715714
? confluxPlugin
716715
: 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)