prediction-market-agent-tooling 0.60.5__py3-none-any.whl → 0.60.6__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.
- prediction_market_agent_tooling/config.py +8 -0
- prediction_market_agent_tooling/deploy/agent.py +1 -0
- prediction_market_agent_tooling/markets/polymarket/utils.py +2 -2
- prediction_market_agent_tooling/tools/google_utils.py +23 -27
- {prediction_market_agent_tooling-0.60.5.dist-info → prediction_market_agent_tooling-0.60.6.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.60.5.dist-info → prediction_market_agent_tooling-0.60.6.dist-info}/RECORD +9 -9
- {prediction_market_agent_tooling-0.60.5.dist-info → prediction_market_agent_tooling-0.60.6.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.60.5.dist-info → prediction_market_agent_tooling-0.60.6.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.60.5.dist-info → prediction_market_agent_tooling-0.60.6.dist-info}/entry_points.txt +0 -0
@@ -60,6 +60,8 @@ class APIKeys(BaseSettings):
|
|
60
60
|
PINATA_API_SECRET: t.Optional[SecretStr] = None
|
61
61
|
|
62
62
|
TAVILY_API_KEY: t.Optional[SecretStr] = None
|
63
|
+
# Don't get fooled! Serper and Serp are two different services.
|
64
|
+
SERPER_API_KEY: t.Optional[SecretStr] = None
|
63
65
|
|
64
66
|
SQLALCHEMY_DB_URL: t.Optional[SecretStr] = None
|
65
67
|
|
@@ -102,6 +104,12 @@ class APIKeys(BaseSettings):
|
|
102
104
|
data.SAFE_ADDRESS = None
|
103
105
|
return data
|
104
106
|
|
107
|
+
@property
|
108
|
+
def serper_api_key(self) -> SecretStr:
|
109
|
+
return check_not_none(
|
110
|
+
self.SERPER_API_KEY, "SERPER_API_KEY missing in the environment."
|
111
|
+
)
|
112
|
+
|
105
113
|
@property
|
106
114
|
def manifold_user_id(self) -> str:
|
107
115
|
return get_authenticated_user(
|
@@ -3,7 +3,7 @@ from prediction_market_agent_tooling.markets.markets import MarketType
|
|
3
3
|
from prediction_market_agent_tooling.markets.polymarket.data_models_web import (
|
4
4
|
PolymarketFullMarket,
|
5
5
|
)
|
6
|
-
from prediction_market_agent_tooling.tools.google_utils import
|
6
|
+
from prediction_market_agent_tooling.tools.google_utils import search_google_gcp
|
7
7
|
|
8
8
|
|
9
9
|
def find_resolution_on_polymarket(question: str) -> Resolution | None:
|
@@ -35,7 +35,7 @@ def find_url_to_polymarket(question: str) -> str | None:
|
|
35
35
|
slug = "".join(replace_chars.get(char, char) for char in question.lower())
|
36
36
|
|
37
37
|
# Search for the links to the Polymarket's market page on Google.
|
38
|
-
links =
|
38
|
+
links = search_google_gcp(
|
39
39
|
# For some reason, just giving it in the query works better than using `site_search`, `exact_terms` or other parameters of the google search.
|
40
40
|
query=f"{MarketType.POLYMARKET.market_class.base_url} {question}",
|
41
41
|
num=10,
|
@@ -1,14 +1,11 @@
|
|
1
|
-
import json
|
2
1
|
import typing as t
|
3
2
|
from datetime import timedelta
|
4
3
|
|
4
|
+
import requests
|
5
5
|
import tenacity
|
6
|
-
from google.cloud import secretmanager
|
7
6
|
from googleapiclient.discovery import build
|
8
|
-
from pydantic import SecretStr
|
9
7
|
|
10
|
-
from prediction_market_agent_tooling.config import APIKeys
|
11
|
-
from prediction_market_agent_tooling.gtypes import PrivateKey
|
8
|
+
from prediction_market_agent_tooling.config import APIKeys
|
12
9
|
from prediction_market_agent_tooling.loggers import logger
|
13
10
|
from prediction_market_agent_tooling.tools.caches.db_cache import db_cache
|
14
11
|
|
@@ -16,10 +13,10 @@ from prediction_market_agent_tooling.tools.caches.db_cache import db_cache
|
|
16
13
|
@tenacity.retry(
|
17
14
|
wait=tenacity.wait_fixed(1),
|
18
15
|
stop=tenacity.stop_after_attempt(3),
|
19
|
-
after=lambda x: logger.debug(f"
|
16
|
+
after=lambda x: logger.debug(f"search_google_gcp failed, {x.attempt_number=}."),
|
20
17
|
)
|
21
18
|
@db_cache(max_age=timedelta(days=1))
|
22
|
-
def
|
19
|
+
def search_google_gcp(
|
23
20
|
query: str | None = None,
|
24
21
|
num: int = 3,
|
25
22
|
exact_terms: str | None = None,
|
@@ -57,24 +54,23 @@ def search_google(
|
|
57
54
|
raise ValueError(f"Can not parse results: {search}") from e
|
58
55
|
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
)
|
65
|
-
|
66
|
-
|
67
|
-
|
57
|
+
@tenacity.retry(
|
58
|
+
wait=tenacity.wait_fixed(1),
|
59
|
+
stop=tenacity.stop_after_attempt(3),
|
60
|
+
after=lambda x: logger.debug(f"search_google_serper failed, {x.attempt_number=}."),
|
61
|
+
)
|
62
|
+
@db_cache(max_age=timedelta(days=1))
|
63
|
+
def search_google_serper(q: str) -> list[str]:
|
64
|
+
"""Search Google using the Serper API."""
|
65
|
+
url = "https://google.serper.dev/search"
|
66
|
+
response = requests.post(
|
67
|
+
url,
|
68
|
+
headers={
|
69
|
+
"X-API-KEY": APIKeys().serper_api_key.get_secret_value(),
|
70
|
+
"Content-Type": "application/json",
|
71
|
+
},
|
72
|
+
json={"q": q},
|
68
73
|
)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
else:
|
73
|
-
client = secretmanager.SecretManagerServiceClient()
|
74
|
-
name = f"projects/{project_id}/secrets/{secret_id}/versions/{version_id}"
|
75
|
-
response = client.access_secret_version(request={"name": name})
|
76
|
-
secret_payload = response.payload.data.decode("UTF-8")
|
77
|
-
secret_json = json.loads(secret_payload)
|
78
|
-
if "private_key" not in secret_json:
|
79
|
-
raise ValueError(f"Private key not found in gcp secret {secret_id}")
|
80
|
-
return PrivateKey(SecretStr(secret_json["private_key"]))
|
74
|
+
response.raise_for_status()
|
75
|
+
parsed = response.json()
|
76
|
+
return [x["link"] for x in parsed["organic"] if x.get("link")]
|
@@ -20,8 +20,8 @@ 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=
|
24
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
23
|
+
prediction_market_agent_tooling/config.py,sha256=M1bbUiADK3cbOp-S19u_x5GciOM8h86ZNcZ0GSD04lQ,9923
|
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
|
27
27
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
@@ -60,7 +60,7 @@ prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qg
|
|
60
60
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=Fd5PI5y3mJM8VHExBhWFWEnuuIKxQmIAXgBuoPDvNjw,4341
|
61
61
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=VZhVccTApygSKMmy6Au2G02JCJOKJnR_oVeKlaesuSg,12548
|
62
62
|
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=NRoZK71PtH8kkangMqme7twcAXhRJSSabbmOir-UnAI,3418
|
63
|
-
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=
|
63
|
+
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
|
64
64
|
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=HGJv4XSvCxXLLC5VwxZTZ5E4w_bWGKv50fM_6ssloxI,8203
|
65
65
|
prediction_market_agent_tooling/markets/seer/seer.py,sha256=r21sXj_4_oIG2L1N5l56vEYGI_q2RGem_6G-Sixkbck,12954
|
66
66
|
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=E7CYAKZiK6cg3dyj1kJuIPKSYYUft98F64shF5S0g4s,2730
|
@@ -90,7 +90,7 @@ prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=M3zQohgAzy_LETnf9r
|
|
90
90
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
91
91
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
|
92
92
|
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
93
|
-
prediction_market_agent_tooling/tools/google_utils.py,sha256=
|
93
|
+
prediction_market_agent_tooling/tools/google_utils.py,sha256=D-6FB2HRtmxaKZJ_Za-qj6VZCp5XU18rF4wLMMrqEUg,2557
|
94
94
|
prediction_market_agent_tooling/tools/hexbytes_custom.py,sha256=ytwr4N8t-9UF1F4wXsln3IV1HBKgaYirsErc3NsKL-M,2119
|
95
95
|
prediction_market_agent_tooling/tools/httpx_cached_client.py,sha256=RxD-hwtZCMctnMwfzy8t51W9Z9gxFGtDYxBIMChazpc,406
|
96
96
|
prediction_market_agent_tooling/tools/image_gen/image_gen.py,sha256=HzRwBx62hOXBOmrtpkXaP9Qq1Ku03uUGdREocyjLQ_k,1266
|
@@ -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.
|
121
|
-
prediction_market_agent_tooling-0.60.
|
122
|
-
prediction_market_agent_tooling-0.60.
|
123
|
-
prediction_market_agent_tooling-0.60.
|
124
|
-
prediction_market_agent_tooling-0.60.
|
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,,
|
File without changes
|
File without changes
|