MCPcopy Create free account
hub / github.com/Virtual-Protocol/virtuals-python / react

Method react

src/virtuals_sdk/twitter_agent/sdk.py:52–91  ·  view source on GitHub ↗

Simulate the agent configuration

(self, session_id: str, platform: str, goal: str,
              description: str, world_info: str, functions: list, custom_functions: list,
              event: str = None, task: str = None, tweet_id: str = None)

Source from the content-addressed store, hash-verified

50 return response.json()["data"]
51
52 def react(self, session_id: str, platform: str, goal: str,
53 description: str, world_info: str, functions: list, custom_functions: list,
54 event: str = None, task: str = None, tweet_id: str = None):
55 """
56 Simulate the agent configuration
57 """
58 url = f"{self.api_url}/react/{platform}"
59
60 payload = {
61 "sessionId": session_id,
62 "goal": goal,
63 "description": description,
64 "worldInfo": world_info,
65 "functions": functions,
66 "customFunctions": [x.toJson() for x in custom_functions]
67 }
68
69 if (event):
70 payload["event"] = event
71
72 if (task):
73 payload["task"] = task
74
75 if (tweet_id):
76 payload["tweetId"] = tweet_id
77
78 print(payload)
79
80 response = requests.post(
81 url,
82 json={
83 "data": payload
84 },
85 headers={"x-api-key": self.api_key}
86 )
87
88 if (response.status_code != 200):
89 raise Exception(response.json())
90
91 return response.json()["data"]
92
93 def deploy(self, goal: str, description: str, world_info: str, functions: list, custom_functions: list, main_heartbeat: int, reaction_heartbeat: int):
94 """

Callers

nothing calls this directly

Calls 1

toJsonMethod · 0.80

Tested by

no test coverage detected