mech-client 0.2.9__py3-none-any.whl → 0.2.10__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.
mech_client/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Mech client."""
2
2
 
3
- __version__ = "0.2.9"
3
+ __version__ = "0.2.10"
mech_client/interact.py CHANGED
@@ -26,7 +26,6 @@ python client.py <prompt> <tool>
26
26
  """
27
27
 
28
28
  import asyncio
29
- import json
30
29
  import os
31
30
  import time
32
31
  import warnings
@@ -66,7 +65,7 @@ LEDGER_CONFIG = {
66
65
  "chain_id": 100,
67
66
  "poa_chain": False,
68
67
  "default_gas_price_strategy": "eip1559",
69
- "is_gas_estimation_enabled": True,
68
+ "is_gas_estimation_enabled": False,
70
69
  }
71
70
  PRIVATE_KEY_FILE_PATH = "ethereum_private_key.txt"
72
71
 
@@ -74,7 +73,15 @@ WSS_ENDPOINT = os.getenv(
74
73
  "WEBSOCKET_ENDPOINT",
75
74
  "wss://rpc.eu-central-2.gateway.fm/ws/v4/gnosis/non-archival/mainnet",
76
75
  )
77
- GNOSISSCAN_API_URL = "https://api.gnosisscan.io/api?module=contract&action=getabi&address={contract_address}"
76
+ MANUAL_GAS_LIMIT = int(
77
+ os.getenv(
78
+ "MANUAL_GAS_LIMIT",
79
+ "100_000",
80
+ )
81
+ )
82
+ BLOCKSCOUT_API_URL = (
83
+ "https://gnosis.blockscout.com/api/v2/smart-contracts/{contract_address}"
84
+ )
78
85
 
79
86
  MAX_RETRIES = 3
80
87
  WAIT_SLEEP = 3.0
@@ -119,9 +126,9 @@ def get_event_signatures(abi: List) -> Tuple[str, str]:
119
126
 
120
127
  def get_abi(contract_address: str) -> List:
121
128
  """Get contract abi"""
122
- abi_request_url = GNOSISSCAN_API_URL.format(contract_address=contract_address)
129
+ abi_request_url = BLOCKSCOUT_API_URL.format(contract_address=contract_address)
123
130
  response = requests.get(abi_request_url).json()
124
- return json.loads(response["result"])
131
+ return response["abi"]
125
132
 
126
133
 
127
134
  def get_contract(
@@ -260,7 +267,11 @@ def send_request( # pylint: disable=too-many-arguments,too-many-locals
260
267
  print(f"Prompt uploaded: https://gateway.autonolas.tech/ipfs/{v1_file_hash_hex}")
261
268
  method_name = "request"
262
269
  methord_args = {"data": v1_file_hash_hex_truncated}
263
- tx_args = {"sender_address": crypto.address, "value": price}
270
+ tx_args = {
271
+ "sender_address": crypto.address,
272
+ "value": price,
273
+ "gas": MANUAL_GAS_LIMIT,
274
+ }
264
275
 
265
276
  tries = 0
266
277
  retries = retries or MAX_RETRIES
@@ -377,7 +388,7 @@ def interact( # pylint: disable=too-many-arguments,too-many-locals
377
388
  :type sleep: float
378
389
  :rtype: Any
379
390
  """
380
- contract_address = query_agent_address(agent_id=agent_id)
391
+ contract_address = query_agent_address(agent_id=agent_id, timeout=timeout)
381
392
  if contract_address is None:
382
393
  raise ValueError(f"Agent with ID {agent_id} does not exist!")
383
394
 
mech_client/subgraph.py CHANGED
@@ -37,16 +37,22 @@ AGENT_QUERY_TEMPLATE = Template(
37
37
  )
38
38
 
39
39
 
40
- def query_agent_address(agent_id: int) -> Optional[str]:
40
+ def query_agent_address(
41
+ agent_id: int, timeout: Optional[float] = None
42
+ ) -> Optional[str]:
41
43
  """
42
44
  Query agent address from subgraph.
43
45
 
44
46
  :param agent_id: The ID of the agent.
47
+ :param timeout: Timeout for the request.
45
48
  :type agent_id: int
46
49
  :return: The agent address if found, None otherwise.
47
50
  :rtype: Optional[str]
48
51
  """
49
- client = Client(transport=AIOHTTPTransport(url=MECH_SUBGRAPH_URL))
52
+ client = Client(
53
+ transport=AIOHTTPTransport(url=MECH_SUBGRAPH_URL),
54
+ execute_timeout=timeout or 30.0,
55
+ )
50
56
  response = client.execute(
51
57
  document=gql(
52
58
  request_string=AGENT_QUERY_TEMPLATE.substitute({"agent_id": agent_id})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mech-client
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: Basic client to interact with a mech
5
5
  License: Apache-2.0
6
6
  Author: David Minarsch
@@ -12,10 +12,10 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Requires-Dist: asn1crypto (>=1.4.0,<1.5.0)
14
14
  Requires-Dist: gql (>=3.4.1)
15
- Requires-Dist: open-aea-cli-ipfs (==1.42.0)
16
- Requires-Dist: open-aea-ledger-cosmos (==1.42.0)
17
- Requires-Dist: open-aea-ledger-ethereum (==1.42.0)
18
- Requires-Dist: open-aea[cli] (==1.42.0)
15
+ Requires-Dist: open-aea-cli-ipfs (==1.50.0)
16
+ Requires-Dist: open-aea-ledger-cosmos (==1.50.0)
17
+ Requires-Dist: open-aea-ledger-ethereum (==1.50.0)
18
+ Requires-Dist: open-aea[cli] (==1.50.0)
19
19
  Requires-Dist: websocket-client (>=0.32.0,<1)
20
20
  Description-Content-Type: text/markdown
21
21
 
@@ -54,7 +54,7 @@ Commands:
54
54
  push-to-ipfs Upload a file to IPFS.
55
55
  ```
56
56
 
57
- ## Usage:
57
+ ## CLI Usage:
58
58
 
59
59
  First, create a private key in file `ethereum_private_key.txt` with this command:
60
60
 
@@ -63,6 +63,12 @@ aea generate-key ethereum
63
63
  ```
64
64
  Ensure the private key carries funds on Gnosis Chain.
65
65
 
66
+ A keyfile is just a file with your ethereum private key as a hex-string, example:
67
+ ```
68
+ 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd
69
+ ```
70
+ In case you add your own, make sure you don't have any extra characters in the file, like newlines or spaces.
71
+
66
72
  Second, run the following command to instruct the mech with `<prompt>` and `<agent_id>`:
67
73
 
68
74
  ```bash
@@ -115,6 +121,32 @@ Data arrived: https://gateway.autonolas.tech/ipfs/f0170122069b55e077430a00f3cbc3
115
121
  Data from agent: {'requestId': 81653153529124597849081567361606842861262371002932574194580478443414142139857, 'result': "\n\nA summer breeze, so sweet,\nA gentle reminder of summer's heat.\nThe sky so blue, no cloud in sight,\nA perfect day, a wondrous sight."}
116
122
  ```
117
123
 
124
+ ## Programmatic Usage:
125
+
126
+ ```python
127
+ from mech_client.interact import interact, ConfirmationType
128
+
129
+ prompt_text = 'Will gnosis pay reach 100k cards in 2024?'
130
+ agent_id = 3
131
+ tool_name = "prediction-online"
132
+
133
+ result = interact(
134
+ prompt=prompt_text,
135
+ agent_id=agent_id,
136
+ tool=tool_name,
137
+ confirmation_type=ConfirmationType.ON_CHAIN,
138
+ private_key_path='PATH_HERE'
139
+ )
140
+ print(result)
141
+ ```
142
+
143
+ # Developer installation
144
+ To setup the development environment, run the following commands:
145
+
146
+ ```bash
147
+ poetry install && poetry shell
148
+ ```
149
+
118
150
  ## Release guide:
119
151
 
120
152
  - Bump versions in `pyproject.toml` and `mech_client/__init__.py`
@@ -122,4 +154,5 @@ Data from agent: {'requestId': 8165315352912459784908156736160684286126237100293
122
154
  - `rm -rf dist`
123
155
  - `autonomy packages sync --update-packages`
124
156
  - `make eject-packages`
125
- - then `poetry publish --build --username=<username> --password=<password>`.
157
+ - then create release PR and tag release
158
+
@@ -1,4 +1,4 @@
1
- mech_client/__init__.py,sha256=Bqj_mLyNm3Ms-GZCI16A17VdYk10lYULVsK0PFaXQTc,42
1
+ mech_client/__init__.py,sha256=No9VVJJY-aVrNiGRM83B1m0Bb-fXIOl_diX4tfBS_BM,43
2
2
  mech_client/acn.py,sha256=Cz93ykB8Vavd6QSEBnoNv0wylfw2RLOqqu7fIYo4YRY,5790
3
3
  mech_client/cli.py,sha256=e6trIN_uoprbvxz41A-x2aUu8kxlyxTAfYv_yZzxmOU,3897
4
4
  mech_client/helpers/__init__.py,sha256=f13zpwGDaKQUjML-5Iq66rRfzg8IS5UNK5I8gBr7w54,1028
@@ -29,14 +29,14 @@ mech_client/helpers/p2p_libp2p_client/README.md,sha256=6x9s6P7TdKkcvAS1wMFHXRz4a
29
29
  mech_client/helpers/p2p_libp2p_client/__init__.py,sha256=-GOP3D_JnmXTDomrMLCbnRk7vRQmihIqTYvyIPzx-q4,879
30
30
  mech_client/helpers/p2p_libp2p_client/connection.py,sha256=pvfHtI-NhgDbay1wLNit6m8InH4c0p00c3hQo0I2jwQ,27887
31
31
  mech_client/helpers/p2p_libp2p_client/connection.yaml,sha256=giYV5FwwugD7ha9IqFHJtvs-Oz1jC5og9rpkstrTqoc,1763
32
- mech_client/interact.py,sha256=Rad_7wV9kHMXgCkAR-NRrcldA0dkmPLkMX4MipB8Hog,14791
32
+ mech_client/interact.py,sha256=Dy0WiiATpp6jdPe5iJ14UzXAnRz13GbNjn_UOHugs8Y,14925
33
33
  mech_client/prompt_to_ipfs.py,sha256=IR0NHBd-f4p9bj_HuindJSwrGcc08fdBxavJmpo6GKA,2250
34
34
  mech_client/push_to_ipfs.py,sha256=IfvgaPU79N_ZmCPF9d7sPCYz2uduZH0KjT_HQ2LHXoQ,2059
35
- mech_client/subgraph.py,sha256=1ja0tTUVpTNGmmyXPPBHd-IJSxZgjQWlIEYWVN1iHEM,1815
35
+ mech_client/subgraph.py,sha256=QR9yAxGSDQJDl3J3PeOwUYLMnCNMQyF4UZlNVTAKoMw,1955
36
36
  mech_client/to_png.py,sha256=pjUcFJ63MJj_r73eqnfqCWMtlpsrj6H4ZmgvIEmRcFw,2581
37
37
  mech_client/wss.py,sha256=a9aKz1WADxjx67zH8I48w9L_z8J1N2xWRrBrtyk-UjY,7353
38
- mech_client-0.2.9.dist-info/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
39
- mech_client-0.2.9.dist-info/METADATA,sha256=bTDfdctRoCD6rtbeEezx3tCjaWlb5Xk2nUuCvypl5mE,4823
40
- mech_client-0.2.9.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
41
- mech_client-0.2.9.dist-info/entry_points.txt,sha256=SbRMRsayzD8XfNXhgwPuXEqQsdZ5Bw9XDPnUuaDExyY,45
42
- mech_client-0.2.9.dist-info/RECORD,,
38
+ mech_client-0.2.10.dist-info/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
39
+ mech_client-0.2.10.dist-info/METADATA,sha256=bPnUfuqr6OX-vv73FqH-Z0Ssnadk0Z8HX5TeMRQCruY,5583
40
+ mech_client-0.2.10.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
41
+ mech_client-0.2.10.dist-info/entry_points.txt,sha256=SbRMRsayzD8XfNXhgwPuXEqQsdZ5Bw9XDPnUuaDExyY,45
42
+ mech_client-0.2.10.dist-info/RECORD,,