mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 14:16:21 +00:00
Add SerenaAgnoToolkit (replacing list of Functions)
This commit is contained in:
1 parent
03c320bcd4
commit
131ca8a15e
2 files changed
+17
-17
No files matched your search
@@ -4,22 +4,19 @@ from agno.playground import Playground, serve_playground_app
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from serena.agent import SerenaAgent
|
||||
from serena.agno import get_agno_functions
|
||||
from serena.agno import SerenaAgnoToolkit
|
||||
|
||||
load_dotenv()
|
||||
|
||||
project_file_path = "../myproject.yml"
|
||||
|
||||
serena_agent = SerenaAgent(project_file_path)
|
||||
tools = get_agno_functions(serena_agent)
|
||||
|
||||
model = Claude(id="claude-3-7-sonnet-20250219")
|
||||
|
||||
agno_agent = Agent(
|
||||
name="Serena",
|
||||
model=model,
|
||||
description="A fully-featured coding assistant",
|
||||
tools=tools, # type: ignore
|
||||
tools=[SerenaAgnoToolkit(serena_agent)], # type: ignore
|
||||
show_tool_calls=True,
|
||||
markdown=True,
|
||||
system_message="", # Todo
|
||||
|
||||
+15
-12
@@ -1,18 +1,21 @@
|
||||
from agno.tools import Function
|
||||
from agno.tools import Function, Toolkit
|
||||
|
||||
from serena.agent import SerenaAgent, Tool
|
||||
|
||||
|
||||
def serena_tool_to_agno_function(tool: Tool) -> Function:
|
||||
def entrypoint(tool=tool, **kwargs): # type: ignore
|
||||
tool.apply_ex(log_call=True, catch_exceptions=True, **kwargs)
|
||||
class SerenaAgnoToolkit(Toolkit):
|
||||
def __init__(self, serena_agent: SerenaAgent):
|
||||
super().__init__("Serena")
|
||||
for tool in serena_agent.tools.values():
|
||||
self.functions[tool.get_name()] = self._create_agno_function(tool)
|
||||
|
||||
function = Function.from_callable(tool.get_apply_fn())
|
||||
function.name = tool.get_name()
|
||||
function.entrypoint = entrypoint
|
||||
function.show_result = True
|
||||
return function
|
||||
@staticmethod
|
||||
def _create_agno_function(tool: Tool) -> Function:
|
||||
def entrypoint(**kwargs): # type: ignore
|
||||
tool.apply_ex(log_call=True, catch_exceptions=True, **kwargs)
|
||||
|
||||
|
||||
def get_agno_functions(serena_agent: SerenaAgent) -> list[Function]:
|
||||
return [serena_tool_to_agno_function(tool) for tool in serena_agent.tools.values()]
|
||||
function = Function.from_callable(tool.get_apply_fn())
|
||||
function.name = tool.get_name()
|
||||
function.entrypoint = entrypoint
|
||||
function.show_result = True
|
||||
return function
|
||||
Reference in new issue
Block a user