Load toolkit instructions from centralized instruction files
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from agno.tools import Toolkit
|
||||
from app.api.tools.instructions import NEWS_TOOL_INSTRUCTIONS
|
||||
from app.api.wrapper_handler import WrapperHandler
|
||||
from app.api.core.news import NewsWrapper, Article
|
||||
from app.api.news import NewsApiWrapper, GoogleNewsWrapper, CryptoPanicWrapper, DuckDuckGoWrapper
|
||||
@@ -16,17 +16,6 @@ class NewsAPIsTool(NewsWrapper, Toolkit):
|
||||
If no wrapper succeeds, an exception is raised.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _load_instructions() -> str:
|
||||
"""
|
||||
Load the toolkit instructions from the external text file.
|
||||
|
||||
Returns:
|
||||
str: The content of the instructions file.
|
||||
"""
|
||||
instructions_path = Path(__file__).parent / "instructions" / "news_instructions.md"
|
||||
return instructions_path.read_text(encoding="utf-8")
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize the NewsAPIsTool with news API wrappers configured in configs.yaml.
|
||||
@@ -44,13 +33,13 @@ class NewsAPIsTool(NewsWrapper, Toolkit):
|
||||
Toolkit.__init__( # type: ignore
|
||||
self,
|
||||
name="News APIs Toolkit",
|
||||
instructions=NEWS_TOOL_INSTRUCTIONS,
|
||||
tools=[
|
||||
self.get_top_headlines,
|
||||
self.get_latest_news,
|
||||
self.get_top_headlines_aggregated,
|
||||
self.get_latest_news_aggregated,
|
||||
],
|
||||
instructions=self._load_instructions(),
|
||||
)
|
||||
|
||||
def get_top_headlines(self, limit: int = 100) -> list[Article]:
|
||||
|
||||
Reference in New Issue
Block a user