-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agents-api): Add integration support for tool-call step (dummy p…
…rovider) Signed-off-by: Diwank Singh Tomer <[email protected]>
- Loading branch information
Showing
4 changed files
with
143 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from typing import Any | ||
|
||
from beartype import beartype | ||
from temporalio import activity | ||
|
||
from ..autogen.openapi_model import IntegrationDef | ||
from ..common.protocol.tasks import StepContext | ||
from ..env import testing | ||
from ..models.tools import get_tool_args_from_metadata | ||
|
||
|
||
@beartype | ||
async def execute_integration( | ||
context: StepContext, | ||
tool_name: str, | ||
integration: IntegrationDef, | ||
arguments: dict[str, Any], | ||
) -> Any: | ||
developer_id = context.execution_input.developer_id | ||
agent_id = context.execution_input.agent.id | ||
task_id = context.execution_input.task.id | ||
|
||
merged_tool_args = get_tool_args_from_metadata( | ||
developer_id=developer_id, agent_id=agent_id, task_id=task_id | ||
) | ||
|
||
arguments = merged_tool_args.get(tool_name, {}) | arguments | ||
|
||
try: | ||
if integration.provider == "dummy": | ||
return arguments | ||
|
||
else: | ||
raise NotImplementedError( | ||
f"Unknown integration provider: {integration.provider}" | ||
) | ||
except BaseException as e: | ||
if activity.in_activity(): | ||
activity.logger.error(f"Error in execute_integration: {e}") | ||
|
||
raise | ||
|
||
|
||
async def mock_execute_integration( | ||
context: StepContext, | ||
tool_name: str, | ||
integration: IntegrationDef, | ||
arguments: dict[str, Any], | ||
) -> Any: | ||
return arguments | ||
|
||
|
||
execute_integration = activity.defn(name="execute_integration")( | ||
execute_integration if not testing else mock_execute_integration | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters