Skip to content

Commit

Permalink
Update metadata when error comes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaavee315 committed Aug 19, 2024
1 parent 2851574 commit f7cced1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
11 changes: 8 additions & 3 deletions python/composio/client/enums/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from composio.constants import LOCAL_CACHE_DIRECTORY
from composio.exceptions import ComposioSDKError
from composio.storage.base import LocalStorage
from composio.utils.logging import get_logger


_model_cache: t.Dict[str, LocalStorage] = {}
Expand Down Expand Up @@ -152,10 +153,14 @@ def load(self) -> EntityType:
if self._slug in _runtime_actions:
return _runtime_actions[self._slug] # type: ignore
if not (self._path / self._slug).exists():
raise MetadataFileNotFound(
f"Metadata file for `{self._slug}` not found, "
"Please run `composio apps update` to fix this"
from composio.cli.apps import update
from composio.cli.context import get_context

logger = get_logger()
logger.debug(
f"Metadata file for `{self._slug}` not found, updating metadata"
)
update(context=get_context())
if self._slug not in _model_cache:
_model_cache[self._slug] = self._model.load(self._path / self._slug)
return t.cast(EntityType, _model_cache[self._slug])
Expand Down
4 changes: 3 additions & 1 deletion python/composio/tools/local/base/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def _parse_docstring(
) -> t.Tuple[str, t.Dict[str, str], t.Optional[t.Tuple[str, str]],]:
"""Parse docstring for descriptions."""
if docstr is None:
raise ValueError("Docstring is None, Please provide a docstring for runtime tools")
raise ValueError(
"Docstring is None, Please provide a docstring for runtime tools"
)
header, *descriptions = docstr.lstrip().rstrip().split("\n")
params = {}
returns = None
Expand Down
8 changes: 2 additions & 6 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,9 @@ def execute_action(
action = Action(action)
is_runtime = action.is_runtime
self.logger.debug(f"Action: {action}, runtime: {is_runtime}")
params = self._serialize_execute_params(param=params)
if not is_runtime:
params = self._process_request(
action=action,
request=self._serialize_execute_params(
param=params,
),
)
params = self._process_request(action=action, request=params)
metadata = self._add_metadata(action=action, metadata=metadata)
response = (
self._execute_local(
Expand Down
3 changes: 3 additions & 0 deletions python/composio/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ def __init__(
def logger(self) -> logging.Logger:
"""Get the component logger."""
return t.cast(logging.Logger, self._logger)


get_logger = get
3 changes: 2 additions & 1 deletion python/swe/examples/langgraph_agent/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import argparse

from agent import composio_toolset, graph
from langchain_core.messages import HumanMessage

from agent import composio_toolset, graph

from composio_langgraph import Action

from swekit.benchmark.run_evaluation import evaluate
Expand Down
1 change: 0 additions & 1 deletion python/swe/examples/langgraph_agent/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path

from agent import composio_toolset

from composio import Action


Expand Down
3 changes: 2 additions & 1 deletion python/swe/examples/langgraph_agent/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from agent import composio_toolset, graph
from inputs import from_github
from langchain_core.messages import HumanMessage

from agent import composio_toolset, graph

from composio_langgraph import Action


Expand Down

0 comments on commit f7cced1

Please sign in to comment.