Skip to content

Commit

Permalink
Waiting function for NFT agent (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Jan 7, 2025
1 parent acc1ecd commit 13e357c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
BroadcastPublicMessageToHumans,
ReceiveMessage,
SendPaidMessageToAnotherAgent,
Wait,
)
from prediction_market_agent.db.agent_communication import (
fetch_count_unprocessed_transactions,
Expand Down Expand Up @@ -144,6 +145,8 @@ def customized_chat_message(
icon = "🧠"
case Stop.__name__:
icon = "😴"
case Wait.__name__:
icon = "⏳"
case ReceiveMessage.__name__:
icon = "👤"
case BroadcastPublicMessageToHumans.__name__:
Expand Down Expand Up @@ -177,6 +180,7 @@ def customized_chat_message(
Stop.__name__,
BroadcastPublicMessageToHumans.__name__,
SendPaidMessageToAnotherAgent.__name__,
Wait.__name__,
):
st.markdown(parsed_function_output_body)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

from microchain import Function
from prediction_market_agent_tooling.config import APIKeys as APIKeys_PMAT
from prediction_market_agent_tooling.gtypes import xdai_type
Expand Down Expand Up @@ -95,8 +97,23 @@ def __call__(self) -> str:
return parse_message_for_agent(message=popped_message)


class Wait(Function):
@property
def description(self) -> str:
return f"""Use {Wait.__name__} to wait for given amount of time in seconds and the reason for it. You can use this for example to wait for a while before checking for new messages."""

@property
def example_args(self) -> list[str]:
return ["10", "Waiting for responses."]

def __call__(self, wait: int, reason: str) -> str:
time.sleep(wait)
return f"Waited for {wait} seconds to {reason}."


MESSAGES_FUNCTIONS: list[type[Function]] = [
BroadcastPublicMessageToHumans,
SendPaidMessageToAnotherAgent,
ReceiveMessage,
Wait,
]

0 comments on commit 13e357c

Please sign in to comment.