Skip to content

Commit

Permalink
Log session ID when ingesting logs and executing an action (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade authored Oct 15, 2024
1 parent bf6a389 commit 6f41d67
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/composio/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def execute(
action: Action,
params: t.Dict,
connected_account_id: t.Optional[str] = None,
session_id: t.Optional[str] = None,
text: t.Optional[str] = None,
) -> t.Dict:
"""
Expand All @@ -240,13 +241,15 @@ def execute(
:param params: Parameters for executing actions
:param connected_account_id: Connection ID if you want to use a specific
connection
:param session_id: ID of the current workspace session
:return: Dictionary containing execution result
"""
if action.no_auth:
return self.client.actions.execute(
action=action,
params=params,
entity_id=self.id,
session_id=session_id,
text=text,
)

Expand All @@ -259,6 +262,7 @@ def execute(
params=params,
entity_id=t.cast(str, connected_account.clientUniqueUserId),
connected_account=connected_account.id,
session_id=session_id,
text=text,
)

Expand Down
7 changes: 6 additions & 1 deletion python/composio/client/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ def execute(
params: t.Dict,
entity_id: str = "default",
connected_account: t.Optional[str] = None,
session_id: t.Optional[str] = None,
text: t.Optional[str] = None,
) -> t.Dict:
"""
Expand All @@ -1040,6 +1041,7 @@ def execute(
:param params: A dictionary of parameters to be passed to the action.
:param entity_id: The unique identifier of the entity on which the action is executed.
:param connected_account: Optional connected account ID if required for the action.
:param session_id: ID of the current workspace session
:return: A dictionary containing the response from the executed action.
"""
if action.is_local:
Expand Down Expand Up @@ -1086,10 +1088,13 @@ def execute(
self.client.http.post(
url=str(self.endpoint / action.name / "execute"),
json={
"entityId": entity_id,
"appName": action.app,
"input": modified_params,
"entityId": entity_id,
"text": text,
"sessionInfo": {
"sessionId": session_id,
},
},
)
).json()
Expand Down
4 changes: 4 additions & 0 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def _execute_local(
request=params,
response=response,
is_error=not response.get("successful", False),
session_id=self.workspace.id,
)

return response
Expand All @@ -424,6 +425,7 @@ def _execute_remote(
params: t.Dict,
entity_id: str = DEFAULT_ENTITY_ID,
connected_account_id: t.Optional[str] = None,
session_id: t.Optional[str] = None,
text: t.Optional[str] = None,
) -> t.Dict:
"""Execute a remote action."""
Expand All @@ -432,6 +434,7 @@ def _execute_remote(
action=action,
params=params,
text=text,
session_id=session_id,
connected_account_id=connected_account_id,
)
if self.output_in_file:
Expand Down Expand Up @@ -664,6 +667,7 @@ def execute_action(
entity_id=entity_id or self.entity_id,
connected_account_id=connected_account_id,
text=text,
session_id=self.workspace.id,
)
)
response = (
Expand Down
2 changes: 2 additions & 0 deletions python/composio/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def log(
request,
response,
is_error,
session_id,
) -> None:
"""Log new request."""
if not hasattr(self, "_queue"):
Expand All @@ -210,6 +211,7 @@ def log(
"request": request,
"response": response,
"isError": is_error,
"sessionId": session_id,
}
)

Expand Down

0 comments on commit 6f41d67

Please sign in to comment.