Skip to content
Merged
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
23 changes: 13 additions & 10 deletions plugins/acp/acp_plugin_gamesdk/acp_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def __init__(self, options: AcpPluginOptions):
"""
self.cluster = options.cluster
self.evaluator_cluster = options.evaluator_cluster
self.twitter_plugin = options.twitter_plugin
self.twitter_plugin = None
if (options.twitter_plugin is not None):
self.twitter_plugin = options.twitter_plugin

self.produced_inventory: List[IInventory] = []
self.acp_base_url = self.acp_token_client.acp_base_url if self.acp_token_client.acp_base_url is None else "https://acpx-staging.virtuals.io/api"
if (options.on_evaluate is not None):
Expand All @@ -72,7 +75,6 @@ def initializeSocket(self) -> Tuple[bool, str]:
Returns a tuple of (success, message).
"""
try:
print("Initializing socket after")
self.socket = socketio.Client()

# Set up authentication before connecting
Expand Down Expand Up @@ -252,7 +254,7 @@ def initiate_job(self) -> Function:

args = [seller_wallet_address_arg, price_arg, reasoning_arg, service_requirements_arg, require_evaluation_arg, evaluator_keyword_arg]

if self.twitter_plugin is not None:
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
tweet_content_arg = Argument(
name="tweetContent",
type="string",
Expand Down Expand Up @@ -304,7 +306,7 @@ def _initiate_job_executable(self, sellerWalletAddress: str, price: str, reasoni
evaluatorAddress
)

if (self.twitter_plugin is not None and tweetContent is not None):
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
post_tweet_fn = self.twitter_plugin.get_function('post_tweet')
tweet_id = post_tweet_fn(tweetContent, None).get('data', {}).get('id')
if (tweet_id is not None):
Expand Down Expand Up @@ -343,7 +345,7 @@ def respond_job(self) -> Function:

args = [job_id_arg, decision_arg, reasoning_arg]

if self.twitter_plugin is not None:
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
tweet_content_arg = Argument(
name="tweetContent",
type="string",
Expand Down Expand Up @@ -389,7 +391,7 @@ def _respond_job_executable(self, jobId: int, decision: str, reasoning: str, twe
reasoning
)

if (self.twitter_plugin is not None and tweetContent is not None):
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
tweet_history = job.get("tweetHistory", [])
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
if (tweet_id is not None):
Expand Down Expand Up @@ -429,7 +431,7 @@ def pay_job(self) -> Function:

args = [job_id_arg, amount_arg, reasoning_arg]

if self.twitter_plugin is not None:
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
tweet_content_arg = Argument(
name="tweetContent",
type="string",
Expand Down Expand Up @@ -476,7 +478,7 @@ def _pay_job_executable(self, jobId: int, amount: float, reasoning: str, tweetCo
reasoning
)

if (self.twitter_plugin is not None and tweetContent is not None):
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
tweet_history = job.get("tweetHistory", [])
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
if (tweet_id is not None):
Expand Down Expand Up @@ -522,7 +524,7 @@ def deliver_job(self) -> Function:

args = [job_id_arg, deliverable_type_arg, deliverable_arg, reasoning_arg]

if self.twitter_plugin is not None:
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
tweet_content_arg = Argument(
name="tweetContent",
type="string",
Expand Down Expand Up @@ -579,7 +581,8 @@ def _deliver_job_executable(self, jobId: int, deliverableType: str, deliverable:
json.dumps(deliverable),
)

if (self.twitter_plugin is not None and tweetContent is not None):
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):

tweet_history = job.get("tweetHistory", [])
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
if (tweet_id is not None):
Expand Down