acp-plugin-gamesdk 0.1.18__tar.gz → 0.1.19__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: acp-plugin-gamesdk
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: ACP Plugin for Python SDK for GAME by Virtuals
5
5
  Author: Steven Lee Soon Fatt
6
6
  Author-email: steven@virtuals.io
@@ -264,3 +264,39 @@ class AcpClient:
264
264
  f"Response status code: {response.status_code}\n"
265
265
  f"Response description: {response.text}\n"
266
266
  )
267
+
268
+ def get_agent_by_wallet_address(self, wallet_address: str) -> AcpAgent:
269
+ url = f"{self.acp_base_url}/agents?filters[walletAddress]={wallet_address}"
270
+
271
+ response = requests.get(
272
+ url,
273
+ )
274
+
275
+ if response.status_code != 200:
276
+ raise Exception(
277
+ f"Failed to get agent: {response.status_code} {response.text}"
278
+ )
279
+
280
+ response_json = response.json()
281
+
282
+ result = []
283
+
284
+ for agent in response_json.get("data", []):
285
+ if agent["offerings"]:
286
+ offerings = [AcpOffering(name=offering["name"], price=offering["price"]) for offering in agent["offerings"]]
287
+ else:
288
+ offerings = None
289
+
290
+ result.append(
291
+ AcpAgent(
292
+ id=agent["id"],
293
+ name=agent["name"],
294
+ twitter_handle=agent["twitterHandle"],
295
+ description=agent["description"],
296
+ wallet_address=agent["walletAddress"],
297
+ offerings=offerings,
298
+ score=0,
299
+ explanation=""
300
+ )
301
+ )
302
+ return result[0]
@@ -74,7 +74,10 @@ class AcpPlugin:
74
74
  if options.on_evaluate is not None:
75
75
  self.on_evaluate = options.on_evaluate
76
76
  if options.on_phase_change is not None:
77
- self.on_phase_change = options.on_phase_change
77
+ def phase_change_wrapper(job : AcpJob):
78
+ job["getAgentByWalletAddress"] = self.acp_client.get_agent_by_wallet_address
79
+ return options.on_phase_change(job)
80
+ self.on_phase_change = phase_change_wrapper
78
81
  self.initialize_socket()
79
82
  self.job_expiry_duration_mins = options.job_expiry_duration_mins if options.job_expiry_duration_mins is not None else 1440
80
83
 
@@ -115,7 +118,6 @@ class AcpPlugin:
115
118
  @self.socket.on(SocketEvents["ON_PHASE_CHANGE"])
116
119
  def on_phase_change(data):
117
120
  if hasattr(self, 'on_phase_change') and self.on_phase_change:
118
- print(f"on_phase_change: {data}")
119
121
  self.on_phase_change(data)
120
122
 
121
123
  # Set up cleanup function for graceful shutdown
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from enum import IntEnum, Enum
3
- from typing import List, Literal, Optional
3
+ from typing import List, Literal, Optional, Callable
4
4
 
5
5
  @dataclass
6
6
  class AcpOffering:
@@ -79,10 +79,13 @@ class AcpJob:
79
79
  desc: str
80
80
  price: str
81
81
  providerAddress: Optional[str]
82
+ clientAddress: Optional[str]
82
83
  phase: AcpJobPhasesDesc
83
84
  memo: List[AcpRequestMemo]
84
85
  tweetHistory : ITweet | List
85
86
  lastUpdated: int
87
+ getAgentByWalletAddress: Optional[Callable[[str], AcpAgent]]
88
+
86
89
 
87
90
  def __repr__(self) -> str:
88
91
  output =(
@@ -92,6 +95,7 @@ class AcpJob:
92
95
  f"Description: {self.desc}, "
93
96
  f"Price: {self.price}, "
94
97
  f"Provider Address: {self.providerAddress}, "
98
+ f"Client Address: {self.clientAddress}, "
95
99
  f"Phase: {self.phase.value}, "
96
100
  f"Memo: {self.memo}, "
97
101
  f"Tweet History: {self.tweetHistory}, "
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "acp-plugin-gamesdk"
3
- version = "0.1.18"
3
+ version = "0.1.19"
4
4
  description = "ACP Plugin for Python SDK for GAME by Virtuals"
5
5
  authors = ["Steven Lee Soon Fatt <steven@virtuals.io>"]
6
6
  readme = "README.md"