From 5001441ed497f9297961162ba826b6126b90d8e1 Mon Sep 17 00:00:00 2001 From: LachsBagel <149974355+LachsBagel@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:41:22 -0500 Subject: [PATCH] refactored news agent to new format; temporarily disabled as it interferes with real time agent --- .../agents/src/agents/news_agent/agent.py | 15 ++++++--------- .../agents/src/agents/news_agent/config.py | 3 ++- .../agents/src/agents/news_agent/tools.py | 2 +- .../moragents_dockers/agents/src/config.py | 16 ++++++++-------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/submodules/moragents_dockers/agents/src/agents/news_agent/agent.py b/submodules/moragents_dockers/agents/src/agents/news_agent/agent.py index dc5df22..732ff0f 100644 --- a/submodules/moragents_dockers/agents/src/agents/news_agent/agent.py +++ b/submodules/moragents_dockers/agents/src/agents/news_agent/agent.py @@ -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") @@ -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}") @@ -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: diff --git a/submodules/moragents_dockers/agents/src/agents/news_agent/config.py b/submodules/moragents_dockers/agents/src/agents/news_agent/config.py index c8a399b..e9fe7d3 100644 --- a/submodules/moragents_dockers/agents/src/agents/news_agent/config.py +++ b/submodules/moragents_dockers/agents/src/agents/news_agent/config.py @@ -125,5 +125,6 @@ class Config: 'EIGEN': 'Eigenlayer', 'ORDI': 'ORDI', 'CFX': 'Conflux', - 'W': 'Wormhole' + 'W': 'Wormhole', + 'MOR': 'Morpheus AI' } \ No newline at end of file diff --git a/submodules/moragents_dockers/agents/src/agents/news_agent/tools.py b/submodules/moragents_dockers/agents/src/agents/news_agent/tools.py index 94b86b6..f017b22 100644 --- a/submodules/moragents_dockers/agents/src/agents/news_agent/tools.py +++ b/submodules/moragents_dockers/agents/src/agents/news_agent/tools.py @@ -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 diff --git a/submodules/moragents_dockers/agents/src/config.py b/submodules/moragents_dockers/agents/src/config.py index 083b880..f32e083 100644 --- a/submodules/moragents_dockers/agents/src/config.py +++ b/submodules/moragents_dockers/agents/src/config.py @@ -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, + # } ] }