Skip to content

Commit

Permalink
fixed requested items
Browse files Browse the repository at this point in the history
  • Loading branch information
ileana-pr committed Jan 12, 2025
1 parent feb7c2d commit 3e479be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { newsPlugin } from "@ai16z/plugin-news";
import { zgPlugin } from "@ai16z/plugin-0g";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import createGoatPlugin from "@ai16z/plugin-goat";
import { intifacePlugin } from "@ai16z/plugin-intiface";
//import { intifacePlugin } from "@ai16z/plugin-intiface";
import { DirectClient } from "@ai16z/client-direct";
import { aptosPlugin } from "@ai16z/plugin-aptos";
import {
Expand Down Expand Up @@ -483,7 +483,6 @@ export async function createAgent(
// character.plugins are handled when clients are added
plugins: [
bootstrapPlugin,
newsPlugin,
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
? confluxPlugin
: null,
Expand Down
15 changes: 7 additions & 8 deletions packages/plugin-news/src/actions/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import {
type Action,
} from "@ai16z/eliza";


export const currentNewsAction: Action = {
name: "CURRENT_NEWS",
similes: ["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"],
validate: async (_runtime: IAgentRuntime, _message: Memory) => {
const apiKey = process.env.NEWS_API_KEY;
if (!apiKey) {
console.error('NEWS_API_KEY environment variable is not set');
return false;
}
return true;
},
description:
Expand All @@ -28,11 +32,6 @@ export const currentNewsAction: Action = {
): Promise<boolean> => {
async function getCurrentNews(searchTerm: string) {
try {
const apiKey = process.env.NEWS_API_KEY;
if (!apiKey) {
throw new Error('NEWS_API_KEY environment variable is not set');
}

// Add quotes and additional context terms
const enhancedSearchTerm = encodeURIComponent(`"${searchTerm}" AND (Spain OR Spanish OR Madrid OR Felipe)`);

Expand All @@ -43,15 +42,15 @@ export const currentNewsAction: Action = {
`sortBy=relevancy&` +
`language=en&` +
`pageSize=50&` +
`apiKey=${apiKey}`
`apiKey=${process.env.NEWS_API_KEY}`
),
fetch(
`https://newsapi.org/v2/top-headlines?` +
`q=${searchTerm}&` +
`country=es&` +
`language=en&` +
`pageSize=50&` +
`apiKey=${apiKey}`
`apiKey=${process.env.NEWS_API_KEY}`
)
]);

Expand Down

0 comments on commit 3e479be

Please sign in to comment.