Small RC Fixes (#608)

* mentioning ollama on the docs as embedder

* lowering barrier to match tool with simialr name

* Fixing agent tools to support co_worker

* Adding new tests

* Fixing type"

* updating tests

* fixing conflict
This commit is contained in:
João Moura
2024-05-13 02:29:04 -03:00
committed by GitHub
parent 7a4d3dd496
commit 7fd8850ddb
21 changed files with 204252 additions and 3737 deletions

View File

@@ -1,4 +1,4 @@
from typing import List
from typing import List, Union
from langchain.tools import StructuredTool
from pydantic import BaseModel, Field
@@ -33,12 +33,14 @@ class AgentTools(BaseModel):
]
return tools
def delegate_work(self, coworker: str, task: str, context: str):
def delegate_work(self, task: str, context: str, coworker: Union[str, None] = None, **kwargs):
"""Useful to delegate a specific task to a co-worker passing all necessary context and names."""
coworker = coworker or kwargs.get("co_worker")
return self._execute(coworker, task, context)
def ask_question(self, coworker: str, question: str, context: str):
def ask_question(self, question: str, context: str, coworker: Union[str, None] = None, **kwargs):
"""Useful to ask a question, opinion or take from a co-worker passing all necessary context and names."""
coworker = coworker or kwargs.get("co_worker")
return self._execute(coworker, question, context)
def _execute(self, agent, task, context):

View File

@@ -219,13 +219,20 @@ class ToolUsage:
)
def _select_tool(self, tool_name: str) -> BaseTool:
for tool in self.tools:
order_tools = sorted(
self.tools,
key=lambda tool: SequenceMatcher(
None, tool.name.lower().strip(), tool_name.lower().strip()
).ratio(),
reverse=True,
)
for tool in order_tools:
if (
tool.name.lower().strip() == tool_name.lower().strip()
or SequenceMatcher(
None, tool.name.lower().strip(), tool_name.lower().strip()
).ratio()
> 0.9
> 0.85
):
return tool
self.task.increment_tools_errors()