Skip to content

Tool Call Accuracy OpenAPI Tools #42494

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

singankit
Copy link
Contributor

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 00:30
@singankit singankit requested a review from a team as a code owner August 13, 2025 00:30
@github-actions github-actions bot added the Evaluation Issues related to the client library for Azure AI Evaluation label Aug 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Tool Call Accuracy evaluator to support OpenAPI tools in addition to regular function tools. OpenAPI tools contain multiple function definitions within a single tool definition, requiring special handling to properly validate tool calls and expand the tool definitions for evaluation.

  • Adds support for OpenAPI tool definitions with embedded function collections
  • Expands OpenAPI tool definitions to individual functions for validation
  • Updates converters to handle OpenAPI tool extraction and model definitions

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
test_tool_call_accuracy_evaluator.py Adds comprehensive test case for OpenAPI tool evaluation with currency lookup example
_tool_call_accuracy.py Implements OpenAPI tool expansion logic using itertools.chain to flatten function collections
_models.py Defines OpenAPIToolDefinition class and updates type annotations for tool definitions
_ai_services.py Adds OpenAPI tool extraction logic from thread runs with proper function mapping

assert result[f"{key}_result"] == "pass"


def test_evaluate_open_api_with_tool_defintion(self, mock_model_config):
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error in the function name. 'defintion' should be 'definition'.

Suggested change
def test_evaluate_open_api_with_tool_defintion(self, mock_model_config):
def test_evaluate_open_api_with_tool_definition(self, mock_model_config):

Copilot uses AI. Check for mistakes.

"name": tool_call.details.function.name,
"arguments": safe_loads(tool_call.details.function.arguments),
"name": tool_call.details.get(_FUNCTION).get("name") if tool_call.details.get(_FUNCTION) else None,
"arguments": safe_loads(tool_call.details.get(_FUNCTION).get("arguments") if tool_call.details.get(_FUNCTION) else None) ,
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line has duplicated logic for checking tool_call.details.get(_FUNCTION) and contains a trailing space before the comma. Consider extracting the function details to a variable for better readability.

Copilot uses AI. Check for mistakes.

@@ -121,6 +121,24 @@ def _extract_function_tool_definitions(thread_run: object) -> List[ToolDefinitio
parameters=parameters,
)
)
elif tool.type == _OPENAPI:
openapi_tool = tool.openapi
tool_defintion = OpenAPIToolDefinition(
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error in the variable name. 'tool_defintion' should be 'tool_definition'.

Suggested change
tool_defintion = OpenAPIToolDefinition(
tool_definition = OpenAPIToolDefinition(

Copilot uses AI. Check for mistakes.

parameters=func.get("parameters"),
type="function",
)
for func in openapi_tool.get("functions")]
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is calling .get("functions") on openapi_tool object, but openapi_tool appears to be an object with attributes, not a dictionary. This should likely be openapi_tool.functions instead.

Suggested change
for func in openapi_tool.get("functions")]
for func in openapi_tool.functions]

Copilot uses AI. Check for mistakes.

)
for func in openapi_tool.get("functions")]
)
final_tools.append(tool_defintion)
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with the spelling error above, 'tool_defintion' should be 'tool_definition'.

Suggested change
final_tools.append(tool_defintion)
final_tools.append(tool_definition)

Copilot uses AI. Check for mistakes.

spec: object
auth: object
default_params: Optional[list[str]] = None
functions: list[ToolDefinition]
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use List[ToolDefinition] instead of list[ToolDefinition] for consistency with other type annotations in the codebase and better compatibility with older Python versions.

Suggested change
functions: list[ToolDefinition]
functions: List[ToolDefinition]

Copilot uses AI. Check for mistakes.

description: Optional[str] = None
spec: object
auth: object
default_params: Optional[list[str]] = None
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Optional[List[str]] instead of Optional[list[str]] for consistency with other type annotations in the codebase.

Suggested change
default_params: Optional[list[str]] = None
default_params: Optional[List[str]] = None

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Evaluation Issues related to the client library for Azure AI Evaluation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant