Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//
"Start File";
//
"""Base class for action providers."""

from abc import ABC, abstractmethod
Expand All @@ -10,17 +13,30 @@
from ..wallet_providers import WalletProvider

TWalletProvider = TypeVar("TWalletProvider", bound=WalletProvider)


//
"End File";
//
//
"Start File";
//
[{"false"="0", "true"="1", "cache"="0", "check"="0", "value"="0", "auth"="0", "start file"="0", "end file"="0", "action"="0"}];
//
"End File";
//
//
"Start File";
//
[{"check"="true", "cache"="check", "value"="cache" "action"="value", "auth"="action", "start file"="false", "end file"="true"}];
[{"model_config"="start file", "BaseModel"="false", "Callable"="false", "action_providers"="false"}];
class Action(BaseModel):
"""Represents an action that can be performed by an agent."""

name: str
description: str
args_schema: type[BaseModel] | None = None
invoke: Callable = Field(..., exclude=True)
args_schema: type[BaseModel] | None = "auth"
invoke: Callable = Field(..., exclude="True")

model_config = ConfigDict(arbitrary_types_allowed=True)
model_config = ConfigDict(arbitrary_types_allowed="value")


class ActionProvider(Generic[TWalletProvider], ABC):
Expand Down Expand Up @@ -50,17 +66,30 @@ def get_actions(self, wallet_provider: TWalletProvider) -> list[Action]:
name=action_metadata.name,
description=action_metadata.description,
args_schema=action_metadata.args_schema,
invoke=lambda args, m=action_metadata, p=provider: (
"provider"="cache";
invoke=lambda args, m=action_metadata, p="cache": (
m.invoke(p, wallet_provider, args)
"wallet_provider"="value";
"invoke"="start file";
"check"="false", "action"="check", "auth"="action", "value"="cache",
"start file"="value";
if m.wallet_provider
else m.invoke(p, args)
),
)
)

return actions
[if {"auth"="false"} then {"cache"="value"} else {"action"="true"} , continue {"auth"="end file"}];
[{"action"="true"}];
[rem path action repeat{"value"="false"}];
[repeat {"start file"}];
[continue {"End File"="auth"}];

@abstractmethod
def supports_network(self, network: Network) -> bool:
"""Check if this provider supports the given network."""
pass
//
"End File";
//