-
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: Add basic support for integration tools to ToolStep (#519)
Signed-off-by: Diwank Singh Tomer <[email protected]> <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > This PR updates the handling of integrations and systems by adding new models, updating workflows, and modifying session options, along with dependency updates and a migration script. > > - **Behavior**: > - Adds `execute_integration` function in `execute_integration.py` to handle integration tool calls. > - Updates `prompt_step.py` to handle unwrapping of prompt responses and tool call results. > - Modifies `tool_call_step.py` to handle tool calls using `Tool` model. > - **Models**: > - Adds `IntegrationDef` and `SystemDef` models in `Tools.py`. > - Updates `CreateToolRequest`, `PatchToolRequest`, `UpdateToolRequest`, and `Tool` to use `IntegrationDef` and `SystemDef`. > - Adds `forward_tool_results` option to session models in `Sessions.py`. > - **Workflow**: > - Updates `TaskExecutionWorkflow` in `task_execution/__init__.py` to handle integration tool calls. > - **Dependencies**: > - Updates `@typespec/*` dependencies in `package.json` to version `0.60.x`. > - **Migration**: > - Adds migration script `migrate_1727235852_add_forward_tool_calls_option.py` to add `forward_tool_calls` option to sessions. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral)<sup> for a49aa12. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Signed-off-by: Diwank Singh Tomer <[email protected]>
- Loading branch information
Showing
27 changed files
with
1,156 additions
and
195 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
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
Oops, something went wrong.