prediction-market-agent-tooling 0.60.6__py3-none-any.whl → 0.61.0__py3-none-any.whl

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.
@@ -3,7 +3,7 @@ import typing as t
3
3
  from copy import deepcopy
4
4
 
5
5
  from eth_account.signers.local import LocalAccount
6
- from pydantic import BeforeValidator, Field, model_validator
6
+ from pydantic import Field, model_validator
7
7
  from pydantic.types import SecretStr
8
8
  from pydantic.v1.types import SecretStr as SecretStrV1
9
9
  from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -39,10 +39,7 @@ class APIKeys(BaseSettings):
39
39
  METACULUS_API_KEY: t.Optional[SecretStr] = None
40
40
  METACULUS_USER_ID: t.Optional[int] = None
41
41
  BET_FROM_PRIVATE_KEY: t.Optional[PrivateKey] = None
42
- SAFE_ADDRESS: t.Annotated[
43
- ChecksumAddress | None,
44
- BeforeValidator(lambda x: x if x is None else Web3.to_checksum_address(x)),
45
- ] = None
42
+ SAFE_ADDRESS: str | None = None
46
43
  OPENAI_API_KEY: t.Optional[SecretStr] = None
47
44
  GRAPH_API_KEY: t.Optional[SecretStr] = None
48
45
  TENDERLY_FORK_RPC: t.Optional[str] = None
@@ -104,6 +101,12 @@ class APIKeys(BaseSettings):
104
101
  data.SAFE_ADDRESS = None
105
102
  return data
106
103
 
104
+ @property
105
+ def safe_address_checksum(self) -> ChecksumAddress | None:
106
+ return (
107
+ Web3.to_checksum_address(self.SAFE_ADDRESS) if self.SAFE_ADDRESS else None
108
+ )
109
+
107
110
  @property
108
111
  def serper_api_key(self) -> SecretStr:
109
112
  return check_not_none(
@@ -148,7 +151,11 @@ class APIKeys(BaseSettings):
148
151
  @property
149
152
  def bet_from_address(self) -> ChecksumAddress:
150
153
  """If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
151
- return self.SAFE_ADDRESS if self.SAFE_ADDRESS else self.public_key
154
+ return (
155
+ self.safe_address_checksum
156
+ if self.safe_address_checksum
157
+ else self.public_key
158
+ )
152
159
 
153
160
  @property
154
161
  def openai_api_key(self) -> SecretStr:
@@ -257,10 +264,10 @@ class APIKeys(BaseSettings):
257
264
  }
258
265
 
259
266
  def check_if_is_safe_owner(self, ethereum_client: EthereumClient) -> bool:
260
- if not self.SAFE_ADDRESS:
267
+ if not self.safe_address_checksum:
261
268
  raise ValueError("Cannot check ownership if safe_address is not defined.")
262
269
 
263
- s = SafeV141(self.SAFE_ADDRESS, ethereum_client)
270
+ s = SafeV141(self.safe_address_checksum, ethereum_client)
264
271
  public_key_from_signer = private_key_to_public_key(self.bet_from_private_key)
265
272
  return s.retrieve_is_owner(public_key_from_signer)
266
273
 
@@ -113,13 +113,13 @@ class ContractBaseClass(BaseModel):
113
113
  Used for changing a state (writing) to the contract.
114
114
  """
115
115
 
116
- if api_keys.SAFE_ADDRESS:
116
+ if api_keys.safe_address_checksum:
117
117
  return send_function_on_contract_tx_using_safe(
118
118
  web3=web3 or self.get_web3(),
119
119
  contract_address=self.address,
120
120
  contract_abi=self.abi,
121
121
  from_private_key=api_keys.bet_from_private_key,
122
- safe_address=api_keys.SAFE_ADDRESS,
122
+ safe_address=api_keys.safe_address_checksum,
123
123
  function_name=function_name,
124
124
  function_params=function_params,
125
125
  tx_params=tx_params,
@@ -64,24 +64,28 @@ def get_traces_for_agent(
64
64
  has_output: bool,
65
65
  client: Langfuse,
66
66
  to_timestamp: DatetimeUTC | None = None,
67
+ tags: str | list[str] | None = None,
67
68
  ) -> list[TraceWithDetails]:
68
69
  """
69
70
  Fetch agent traces using pagination
70
71
  """
72
+ total_pages = -1
71
73
  page = 1 # index starts from 1
72
74
  all_agent_traces = []
73
75
  while True:
74
- logger.debug(f"fetching page {page}")
76
+ logger.debug(f"Fetching Langfuse page {page} / {total_pages}.")
75
77
  traces = client.fetch_traces(
76
78
  name=trace_name,
77
79
  limit=100,
78
80
  page=page,
79
81
  from_timestamp=from_timestamp,
80
82
  to_timestamp=to_timestamp,
83
+ tags=tags,
81
84
  )
82
85
  if not traces.data:
83
86
  break
84
87
  page += 1
88
+ total_pages = traces.meta.total_pages
85
89
 
86
90
  agent_traces = [
87
91
  t
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.60.6
3
+ Version: 0.61.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -20,7 +20,7 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
20
20
  prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
21
21
  prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
22
22
  prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
23
- prediction_market_agent_tooling/config.py,sha256=M1bbUiADK3cbOp-S19u_x5GciOM8h86ZNcZ0GSD04lQ,9923
23
+ prediction_market_agent_tooling/config.py,sha256=pZW8xsmPhAkhYE9XG8G3f9UIYlaoLSpZ9nv7MHxYpuo,10058
24
24
  prediction_market_agent_tooling/deploy/agent.py,sha256=tMREXM2LwFsatbysCaNRvtCAyCNMAPMGgkkIEpCRj7g,25022
25
25
  prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
26
26
  prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=Y6Pb8OfSb6galRbfdNBvvNTgO-4dR2ybJ4o5GKJcMoM,12894
@@ -83,7 +83,7 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=kpIb-ci
83
83
  prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=dB8LNs2JvVRaFCeAKRmIQRwiirsMgtL31he8051wM-g,11431
84
84
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
85
85
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
86
- prediction_market_agent_tooling/tools/contract.py,sha256=BCl3R-n5jpp5XPAho9yTuUxRbOoKbZSga1Qaa4RfAp8,20945
86
+ prediction_market_agent_tooling/tools/contract.py,sha256=XM7v6Wmi5OXPtn0SS__27MhlaBHGJG3VEeQFSIBJo6U,20963
87
87
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
88
88
  prediction_market_agent_tooling/tools/cow/cow_manager.py,sha256=WK6Uk722VotjLHtxDPHxvwBrWVb3rvTegg_3w58ehwU,3869
89
89
  prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=M3zQohgAzy_LETnf9rKtS1L9rr7FP92CH6v0G2laZkM,4435
@@ -99,7 +99,7 @@ prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py,sha256=CTTMfTvs_8PH4k
99
99
  prediction_market_agent_tooling/tools/is_invalid.py,sha256=TAHQXiiusAU45xJ11ZyEP7PnEfcjfzVG7qHRbsHiAd0,5335
100
100
  prediction_market_agent_tooling/tools/is_predictable.py,sha256=qVd6zqay2Dg2fyeAuZvAFqSHMg71TcPfCZULsVk2XvA,6797
101
101
  prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
102
- prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=83T31s-YbsnNBLyYCjmBI2BBKUEqJUuYFa0uCdkoqy8,5901
102
+ prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=IQboU9EPl4QEIo0poNylomevuVntpPpmkuNCzZl1Qdg,6058
103
103
  prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1gVlQSTskdVFTn09uPLST23YeipVIWj54io,2236
104
104
  prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=hZCxXpcACO95DyiZ5oLFp982N0erZg4wccdSUKTgRlA,2307
105
105
  prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
@@ -117,8 +117,8 @@ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=7JPgVF4RbiFzLD
117
117
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
118
118
  prediction_market_agent_tooling/tools/utils.py,sha256=jLG4nbEoIzzJiZ4RgMx4Q969Zdl0p0s63p8uET_0Fuw,6440
119
119
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=3wfqNxvMn44ivweFRoeKNVb9QRtFd7kFtp7VUY5juEE,12862
120
- prediction_market_agent_tooling-0.60.6.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
- prediction_market_agent_tooling-0.60.6.dist-info/METADATA,sha256=kuT3T3Lv5FgZC2BNXWTtV3BToC9c4pWfydW7fA86UJU,8629
122
- prediction_market_agent_tooling-0.60.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
- prediction_market_agent_tooling-0.60.6.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
- prediction_market_agent_tooling-0.60.6.dist-info/RECORD,,
120
+ prediction_market_agent_tooling-0.61.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
+ prediction_market_agent_tooling-0.61.0.dist-info/METADATA,sha256=Dj083O-3F_h45GoO99u4jvmNKsgeaLGnrB869GRE1Gk,8629
122
+ prediction_market_agent_tooling-0.61.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
+ prediction_market_agent_tooling-0.61.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
+ prediction_market_agent_tooling-0.61.0.dist-info/RECORD,,