Skip to content

Commit

Permalink
refactored news agent to new format; temporarily disabled as it inter…
Browse files Browse the repository at this point in the history
…feres with real time agent
  • Loading branch information
LachsBagel committed Oct 8, 2024
1 parent 1023dd0 commit 5001441
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
logger = logging.getLogger(__name__)

class NewsAgent:
def __init__(self, agent_info, llm, llm_ollama, embeddings, flask_app):
def __init__(self, agent_info, llm, embeddings):
self.agent_info = agent_info
self.llm = llm
self.flask_app = flask_app
self.embeddings = embeddings
self.tools_provided = self.get_tools()
self.url_shortener = pyshorteners.Shortener()
logger.info("NewsAgent initialized")
Expand Down Expand Up @@ -44,12 +44,9 @@ def get_tools(self):
def check_relevance_and_summarize(self, title, content, coin):
logger.info(f"Checking relevance for {coin}: {title}")
prompt = Config.RELEVANCE_PROMPT.format(coin=coin, title=title, content=content)
result = self.llm.create_chat_completion(
messages=[{"role": "user", "content": prompt}],
max_tokens=Config.LLM_MAX_TOKENS,
temperature=Config.LLM_TEMPERATURE
)
return result['choices'][0]['message']['content'].strip()
result = self.llm.invoke([{"role": "user", "content": prompt}])
result = " ".join(result.content.strip().split())
return result

def process_rss_feed(self, feed_url, coin):
logger.info(f"Processing RSS feed for {coin}: {feed_url}")
Expand Down Expand Up @@ -90,7 +87,7 @@ def fetch_crypto_news(self, coins):

def chat(self, request):
try:
data = request.get_json()
data = request.dict()
if 'prompt' in data:
prompt = data['prompt']
if isinstance(prompt, dict) and 'content' in prompt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@ class Config:
'EIGEN': 'Eigenlayer',
'ORDI': 'ORDI',
'CFX': 'Conflux',
'W': 'Wormhole'
'W': 'Wormhole',
'MOR': 'Morpheus AI'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dateutil import parser
import re
from html import unescape
from news_agent.config import Config
from src.agents.news_agent.config import Config
import logging
import urllib.parse

Expand Down
16 changes: 8 additions & 8 deletions submodules/moragents_dockers/agents/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class Config:
{
"path": "src.agents.realtime_search.agent",
"class": "RealtimeSearchAgent",
"description": "Performs real-time web searches. Use when the query is about searching the web for real-time information.",
"description": "Performs real-time web searches. Use when query is for searching web for real-time information or general news.",
"name": "realtime search agent",
"upload_required": False,
},
{
"path": "src.agents.news_agent.agent",
"class": "NewsAgent",
"description": "Fetches and analyzes cryptocurrency news for potential price impacts.",
"name": "crypto news agent",
"upload_required": False,
}
# {
# "path": "src.agents.news_agent.agent",
# "class": "NewsAgent",
# "description": "Fetches and analyzes cryptocurrency headlines for potential price impacts. Use when query is about project updates related to a token or cryptocurrency.",
# "name": "crypto news agent",
# "upload_required": False,
# }
]
}

0 comments on commit 5001441

Please sign in to comment.