Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Enhancements to Parameter Handling and Default Values #1360

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/seer/automation/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,25 @@ class FunctionTool(BaseModel):
parameters: List[Dict[str, str | List[str] | Dict[str, str]]]
required: List[str] = []

def _get_parameter_default(self, param_name: str) -> any:
for param in self.parameters:
if param["name"] == param_name and "default" in param:
return param["default"]
return None

def call(self, **kwargs):
try:
# Check for required parameters
missing_params = [param for param in self.required if param not in kwargs]
if missing_params:
raise ValueError(f"Missing required parameters: {', '.join(missing_params)}")

# Add defaults for parameters if specified
for param in self.parameters:
if param["name"] not in kwargs and "default" in param:
kwargs[param["name"]] = param["default"]

return self.fn(**kwargs)
except Exception as e:
logger.exception(e)
return f"Error: {get_full_exception_string(e)}"
return f"Error: {get_full_exception_string(e)}"
16 changes: 14 additions & 2 deletions src/seer/automation/autofix/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,18 @@ def cleanup(self):
def keyword_search(
self,
keyword: str,
supported_extensions: list[str],
supported_extensions: list[str] | None = None,
repo_name: str | None = None,
in_proximity_to: str | None = None,
):
"""
Searches for a keyword in the codebase.
"""

# Use default extensions if none provided
if supported_extensions is None:
supported_extensions = [".py", ".js", ".jsx", ".ts", ".tsx"]

if self.tmp_dir is None or self.tmp_repo_dir is None:
repo_client = self.context.get_repo_client(
repo_name=repo_name, type=self.repo_client_type
Expand Down Expand Up @@ -331,6 +335,13 @@ def get_tools(self):
{
"name": "repo_name",
"type": "string",
"default": [
".py",
".js",
".jsx",
".ts",
".tsx"
]
"description": "Optional name of the repository to search in if you know it.",
},
{
Expand All @@ -350,6 +361,7 @@ def get_tools(self):
"type": "string",
"description": "The file to search for.",
},
required=["keyword"],
{
"name": "repo_name",
"type": "string",
Expand Down Expand Up @@ -395,4 +407,4 @@ def get_tools(self):
)
)

return tools
return tools
Loading