Fix Agent Slowness (#3979)

This commit is contained in:
Yuhong Sun
2025-02-13 15:54:34 -08:00
committed by GitHub
parent c6434db7eb
commit 1a7aca06b9
14 changed files with 87 additions and 28 deletions

View File

@@ -1,7 +1,9 @@
import abc
from collections.abc import Generator
from typing import Any
from typing import Generic
from typing import TYPE_CHECKING
from typing import TypeVar
from onyx.llm.interfaces import LLM
from onyx.llm.models import PreviousMessage
@@ -14,7 +16,10 @@ if TYPE_CHECKING:
from onyx.tools.models import ToolResponse
class Tool(abc.ABC):
OVERRIDE_T = TypeVar("OVERRIDE_T")
class Tool(abc.ABC, Generic[OVERRIDE_T]):
@property
@abc.abstractmethod
def name(self) -> str:
@@ -57,7 +62,9 @@ class Tool(abc.ABC):
"""Actual execution of the tool"""
@abc.abstractmethod
def run(self, **kwargs: Any) -> Generator["ToolResponse", None, None]:
def run(
self, override_kwargs: OVERRIDE_T | None = None, **llm_kwargs: Any
) -> Generator["ToolResponse", None, None]:
raise NotImplementedError
@abc.abstractmethod