prediction-market-agent-tooling 0.55.2.dev117__py3-none-any.whl → 0.56.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.
- prediction_market_agent_tooling/deploy/agent.py +17 -8
- prediction_market_agent_tooling/jobs/jobs_models.py +27 -2
- prediction_market_agent_tooling/jobs/omen/omen_jobs.py +67 -41
- prediction_market_agent_tooling/markets/agent_market.py +8 -2
- prediction_market_agent_tooling/markets/base_subgraph_handler.py +51 -0
- prediction_market_agent_tooling/markets/markets.py +12 -0
- prediction_market_agent_tooling/markets/metaculus/metaculus.py +1 -1
- prediction_market_agent_tooling/markets/omen/data_models.py +11 -2
- prediction_market_agent_tooling/markets/omen/omen.py +16 -9
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +29 -51
- prediction_market_agent_tooling/markets/seer/data_models.py +27 -0
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +142 -0
- prediction_market_agent_tooling/tools/caches/db_cache.py +351 -0
- prediction_market_agent_tooling/tools/google.py +3 -2
- prediction_market_agent_tooling/tools/is_invalid.py +4 -3
- prediction_market_agent_tooling/tools/is_predictable.py +3 -3
- prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +6 -10
- prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -66
- prediction_market_agent_tooling/tools/tavily/tavily_search.py +12 -44
- prediction_market_agent_tooling/tools/utils.py +2 -0
- {prediction_market_agent_tooling-0.55.2.dev117.dist-info → prediction_market_agent_tooling-0.56.0.dist-info}/METADATA +2 -1
- {prediction_market_agent_tooling-0.55.2.dev117.dist-info → prediction_market_agent_tooling-0.56.0.dist-info}/RECORD +26 -24
- prediction_market_agent_tooling/jobs/jobs.py +0 -45
- prediction_market_agent_tooling/tools/tavily/tavily_storage.py +0 -105
- /prediction_market_agent_tooling/tools/{cache.py → caches/inmemory_cache.py} +0 -0
- {prediction_market_agent_tooling-0.55.2.dev117.dist-info → prediction_market_agent_tooling-0.56.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.55.2.dev117.dist-info → prediction_market_agent_tooling-0.56.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.55.2.dev117.dist-info → prediction_market_agent_tooling-0.56.0.dist-info}/entry_points.txt +0 -0
@@ -1,11 +1,4 @@
|
|
1
|
-
import typing as t
|
2
|
-
|
3
1
|
from pydantic import BaseModel
|
4
|
-
from sqlalchemy import Column
|
5
|
-
from sqlalchemy.dialects.postgresql import JSONB
|
6
|
-
from sqlmodel import ARRAY, Field, SQLModel, String
|
7
|
-
|
8
|
-
from prediction_market_agent_tooling.tools.utils import DatetimeUTC, utcnow
|
9
2
|
|
10
3
|
|
11
4
|
class TavilyResult(BaseModel):
|
@@ -23,62 +16,3 @@ class TavilyResponse(BaseModel):
|
|
23
16
|
images: list[str]
|
24
17
|
results: list[TavilyResult]
|
25
18
|
response_time: float
|
26
|
-
|
27
|
-
|
28
|
-
class TavilyResponseModel(SQLModel, table=True):
|
29
|
-
__tablename__ = "tavily_response"
|
30
|
-
__table_args__ = {"extend_existing": True}
|
31
|
-
id: int | None = Field(None, primary_key=True)
|
32
|
-
agent_id: str = Field(index=True, nullable=False)
|
33
|
-
# Parameters used to execute the search
|
34
|
-
query: str = Field(index=True, nullable=False)
|
35
|
-
search_depth: str
|
36
|
-
topic: str
|
37
|
-
days: int | None = Field(default=None, nullable=True)
|
38
|
-
max_results: int
|
39
|
-
include_domains: list[str] | None = Field(
|
40
|
-
None, sa_column=Column(ARRAY(String), nullable=True)
|
41
|
-
)
|
42
|
-
exclude_domains: list[str] | None = Field(
|
43
|
-
None, sa_column=Column(ARRAY(String), nullable=True)
|
44
|
-
)
|
45
|
-
include_answer: bool
|
46
|
-
include_raw_content: bool
|
47
|
-
include_images: bool
|
48
|
-
use_cache: bool
|
49
|
-
# Datetime at the time of search response and response from the search
|
50
|
-
datetime_: DatetimeUTC = Field(index=True, nullable=False)
|
51
|
-
response: dict[str, t.Any] = Field(sa_column=Column(JSONB, nullable=False))
|
52
|
-
|
53
|
-
@staticmethod
|
54
|
-
def from_model(
|
55
|
-
agent_id: str,
|
56
|
-
query: str,
|
57
|
-
search_depth: t.Literal["basic", "advanced"],
|
58
|
-
topic: t.Literal["general", "news"],
|
59
|
-
days: int | None,
|
60
|
-
max_results: int,
|
61
|
-
include_domains: t.Sequence[str] | None,
|
62
|
-
exclude_domains: t.Sequence[str] | None,
|
63
|
-
include_answer: bool,
|
64
|
-
include_raw_content: bool,
|
65
|
-
include_images: bool,
|
66
|
-
use_cache: bool,
|
67
|
-
response: TavilyResponse,
|
68
|
-
) -> "TavilyResponseModel":
|
69
|
-
return TavilyResponseModel(
|
70
|
-
agent_id=agent_id,
|
71
|
-
query=query,
|
72
|
-
search_depth=search_depth,
|
73
|
-
topic=topic,
|
74
|
-
days=days,
|
75
|
-
max_results=max_results,
|
76
|
-
include_domains=sorted(include_domains) if include_domains else None,
|
77
|
-
exclude_domains=sorted(exclude_domains) if exclude_domains else None,
|
78
|
-
include_answer=include_answer,
|
79
|
-
include_raw_content=include_raw_content,
|
80
|
-
include_images=include_images,
|
81
|
-
use_cache=use_cache,
|
82
|
-
datetime_=utcnow(),
|
83
|
-
response=response.model_dump(),
|
84
|
-
)
|
@@ -1,23 +1,25 @@
|
|
1
1
|
import typing as t
|
2
|
+
from datetime import date, timedelta
|
2
3
|
|
3
4
|
import tenacity
|
4
5
|
from tavily import TavilyClient
|
5
6
|
|
6
7
|
from prediction_market_agent_tooling.config import APIKeys
|
8
|
+
from prediction_market_agent_tooling.tools.caches.db_cache import db_cache
|
7
9
|
from prediction_market_agent_tooling.tools.tavily.tavily_models import (
|
8
10
|
TavilyResponse,
|
9
11
|
TavilyResult,
|
10
12
|
)
|
11
|
-
from prediction_market_agent_tooling.tools.tavily.tavily_storage import TavilyStorage
|
12
13
|
|
13
14
|
DEFAULT_SCORE_THRESHOLD = 0.75 # Based on some empirical testing, anything lower wasn't very relevant to the question being asked
|
14
15
|
|
15
16
|
|
17
|
+
@db_cache(max_age=timedelta(days=1), ignore_args=["api_keys"])
|
16
18
|
def tavily_search(
|
17
19
|
query: str,
|
18
20
|
search_depth: t.Literal["basic", "advanced"] = "advanced",
|
19
21
|
topic: t.Literal["general", "news"] = "general",
|
20
|
-
|
22
|
+
news_since: date | None = None,
|
21
23
|
max_results: int = 5,
|
22
24
|
include_domains: t.Sequence[str] | None = None,
|
23
25
|
exclude_domains: t.Sequence[str] | None = None,
|
@@ -26,34 +28,16 @@ def tavily_search(
|
|
26
28
|
include_images: bool = True,
|
27
29
|
use_cache: bool = False,
|
28
30
|
api_keys: APIKeys | None = None,
|
29
|
-
tavily_storage: TavilyStorage | None = None,
|
30
31
|
) -> TavilyResponse:
|
31
32
|
"""
|
32
|
-
Wrapper around Tavily's search method that will save the response to `TavilyResponseCache`, if provided.
|
33
|
-
|
34
33
|
Argument default values are different from the original method, to return everything by default, because it can be handy in the future and it doesn't increase the costs.
|
35
34
|
"""
|
36
|
-
if topic == "news" and
|
37
|
-
raise ValueError("When topic is 'news',
|
38
|
-
if topic == "general" and
|
39
|
-
raise ValueError("When topic is 'general',
|
35
|
+
if topic == "news" and news_since is None:
|
36
|
+
raise ValueError("When topic is 'news', news_since must be provided")
|
37
|
+
if topic == "general" and news_since is not None:
|
38
|
+
raise ValueError("When topic is 'general', news_since must be None")
|
40
39
|
|
41
|
-
if
|
42
|
-
response_parsed := tavily_storage.find(
|
43
|
-
query=query,
|
44
|
-
search_depth=search_depth,
|
45
|
-
topic=topic,
|
46
|
-
max_results=max_results,
|
47
|
-
days=days,
|
48
|
-
include_domains=include_domains,
|
49
|
-
exclude_domains=exclude_domains,
|
50
|
-
include_answer=include_answer,
|
51
|
-
include_raw_content=include_raw_content,
|
52
|
-
include_images=include_images,
|
53
|
-
use_cache=use_cache,
|
54
|
-
)
|
55
|
-
):
|
56
|
-
return response_parsed
|
40
|
+
days = None if news_since is None else (date.today() - news_since).days
|
57
41
|
response = _tavily_search(
|
58
42
|
query=query,
|
59
43
|
search_depth=search_depth,
|
@@ -69,21 +53,7 @@ def tavily_search(
|
|
69
53
|
api_keys=api_keys,
|
70
54
|
)
|
71
55
|
response_parsed = TavilyResponse.model_validate(response)
|
72
|
-
|
73
|
-
tavily_storage.save(
|
74
|
-
query=query,
|
75
|
-
search_depth=search_depth,
|
76
|
-
topic=topic,
|
77
|
-
days=days,
|
78
|
-
max_results=max_results,
|
79
|
-
include_domains=include_domains,
|
80
|
-
exclude_domains=exclude_domains,
|
81
|
-
include_answer=include_answer,
|
82
|
-
include_raw_content=include_raw_content,
|
83
|
-
include_images=include_images,
|
84
|
-
use_cache=use_cache,
|
85
|
-
response=response_parsed,
|
86
|
-
)
|
56
|
+
|
87
57
|
return response_parsed
|
88
58
|
|
89
59
|
|
@@ -131,16 +101,14 @@ def _tavily_search(
|
|
131
101
|
|
132
102
|
def get_relevant_news_since(
|
133
103
|
question: str,
|
134
|
-
|
104
|
+
news_since: date,
|
135
105
|
score_threshold: float = DEFAULT_SCORE_THRESHOLD,
|
136
106
|
max_results: int = 3,
|
137
|
-
tavily_storage: TavilyStorage | None = None,
|
138
107
|
) -> list[TavilyResult]:
|
139
108
|
news = tavily_search(
|
140
109
|
query=question,
|
141
|
-
|
110
|
+
news_since=news_since,
|
142
111
|
max_results=max_results,
|
143
112
|
topic="news",
|
144
|
-
tavily_storage=tavily_storage,
|
145
113
|
)
|
146
114
|
return [r for r in news.results if r.score > score_threshold]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.56.0
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.12
|
@@ -36,6 +36,7 @@ Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
|
|
36
36
|
Requires-Dist: pydantic (>=2.6.1,<3.0.0)
|
37
37
|
Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
|
38
38
|
Requires-Dist: pymongo (>=4.8.0,<5.0.0)
|
39
|
+
Requires-Dist: pytest-postgresql (>=6.1.1,<7.0.0)
|
39
40
|
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
40
41
|
Requires-Dist: safe-cli (>=1.0.0,<2.0.0)
|
41
42
|
Requires-Dist: safe-eth-py (>=6.0.0b41,<7.0.0)
|
@@ -17,7 +17,7 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-Cc
|
|
17
17
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
|
18
18
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
19
19
|
prediction_market_agent_tooling/config.py,sha256=114f3V9abaok27p5jX3UVr5b5gRUiSxBIYn8Snid34I,6731
|
20
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
20
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=dpc94DUo8Gq1LdRdw6k78vm_47OeJIfomG9CRVpgzk0,22757
|
21
21
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
22
22
|
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=kMrIE3wMv_IB6nJd_1DmDXDkEZhsXFOgyTd7JZ0gqHI,13068
|
23
23
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
@@ -27,11 +27,11 @@ prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=oyW0jgrUT2Tr49c7GlpcM
|
|
27
27
|
prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
|
28
28
|
prediction_market_agent_tooling/gtypes.py,sha256=tqp03PyY0Yhievl4XELfwAn0xOoecaTvBZ1Co6b-A7o,2541
|
29
29
|
prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
|
-
prediction_market_agent_tooling/jobs/
|
31
|
-
prediction_market_agent_tooling/jobs/
|
32
|
-
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=I2_vGrEJj1reSI8M377ab5QCsYNp_l4l4QeYEmDBkFM,3989
|
30
|
+
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=GOtsNm7URhzZM5fPY64r8m8Gz-sSsUhG1qmDoC7wGL8,2231
|
31
|
+
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=N0_jGDyXQeVXXlYg4oA_pOfqIjscHsLQbr0pBwFGoRo,5178
|
33
32
|
prediction_market_agent_tooling/loggers.py,sha256=Am6HHXRNO545BO3l7Ue9Wb2TkYE1OK8KKhGbI3XypVU,3751
|
34
|
-
prediction_market_agent_tooling/markets/agent_market.py,sha256=
|
33
|
+
prediction_market_agent_tooling/markets/agent_market.py,sha256=W2ME57-CSAhrt8qm8-b5r7yLq-Sk7R_BZMaApvjhrUE,12901
|
34
|
+
prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=IxDTwX4tej9j5olNkXcLIE0RCF1Nh2icZQUT2ERMmZo,1937
|
35
35
|
prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
|
36
36
|
prediction_market_agent_tooling/markets/data_models.py,sha256=jMqrSFO_w2z-5N3PFVgZqTHdVdkzSDhhzky2lHsGGKA,3621
|
37
37
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -40,21 +40,23 @@ prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=ylXIEHymx
|
|
40
40
|
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=qemQIwuFg4yf6egGWFp9lWpz1lXr02QiBeZ2akcT6II,5026
|
41
41
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=cPPFWXm3vCYH1jy7_ctJZuQH9ZDaPL4_AgAYzGWkoow,513
|
42
42
|
prediction_market_agent_tooling/markets/market_fees.py,sha256=Q64T9uaJx0Vllt0BkrPmpMEz53ra-hMVY8Czi7CEP7s,1227
|
43
|
-
prediction_market_agent_tooling/markets/markets.py,sha256=
|
43
|
+
prediction_market_agent_tooling/markets/markets.py,sha256=_b-BAfoKIcXl5ZXVODi1ywMhRCbc52022csH1nQT084,3893
|
44
44
|
prediction_market_agent_tooling/markets/metaculus/api.py,sha256=4TRPGytQQbSdf42DCg2M_JWYPAuNjqZ3eBqaQBLkNks,2736
|
45
45
|
prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=Suxa7xELdYuFNKqvGvFh8qyfVtAg79E-vaQ6dqNZOtA,3261
|
46
|
-
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=
|
46
|
+
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=86TIx6cavEWc8Cv4KpZxSvwiSw9oFybXE3YB49pg-CA,4377
|
47
47
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
|
-
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=
|
49
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
48
|
+
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=0eky-RO0TuJysUXHd52A6DSU2mx1ZWiJvvntS4xQsUc,27794
|
49
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=uOuV2DgQmxz6kzPcMovyGg0xYS0c6x12fEFNtLmN-uY,51260
|
50
50
|
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=Zq7SncCq-hvpgXKsVruGBGCn1OhKZTe7r1qLdCTrT2w,28297
|
51
51
|
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=iDWdjICGkt968exwCjY-6nsnQyrrNAg3YjnDdP430GQ,9415
|
52
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
52
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=cXgtBfc5uv7d8598SJ537LxFGVfF_mv-VoQoqI4_G84,36330
|
53
53
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
|
54
54
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=Fd5PI5y3mJM8VHExBhWFWEnuuIKxQmIAXgBuoPDvNjw,4341
|
55
55
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=VZhVccTApygSKMmy6Au2G02JCJOKJnR_oVeKlaesuSg,12548
|
56
56
|
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=NRoZK71PtH8kkangMqme7twcAXhRJSSabbmOir-UnAI,3418
|
57
57
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=m4JG6WULh5epCJt4XBMHg0ae5NoVhqlOvAl0A7DR9iM,2023
|
58
|
+
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=2f6DOXhGerYbTSk5vUvw_y87TcUxOtSfca8-Et7imtU,643
|
59
|
+
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=Jola8AxmNDljBCzl6Gvjb9qH75Y7D5dAwbdZl_jndN8,5478
|
58
60
|
prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=TS4ERwTfQnot8dhekNyVNhJYf5ysYsjF-9v5_kM3aVI,3334
|
59
61
|
prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=LOnyWWBFdg10-cTWdb76nOsNjDloO8OfMT85GBzRCFI,1455
|
60
62
|
prediction_market_agent_tooling/monitor/markets/omen.py,sha256=EqiJYTvDbSu7fBpbrBmCuf3fc6GHr4MxWrBGa69MIyc,3305
|
@@ -69,36 +71,36 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
|
|
69
71
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
70
72
|
prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
|
71
73
|
prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=kpIb-ci67Vc1Yqqaa-_S4OUkbhWSIYog4_Iwp69HU_k,97
|
72
|
-
prediction_market_agent_tooling/tools/
|
74
|
+
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=l-Ghs434NuDZKkYQlQo6sh5-8eAgE-55I_ojc4Hxcmk,13185
|
75
|
+
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=tGHHd9HCiE_hCCtPtloHZQdDfBuiow9YsqJNYi2Tx_0,499
|
73
76
|
prediction_market_agent_tooling/tools/contract.py,sha256=s3yo8IbXTcvAJcPfLM0_NbgaEsWwLsPmyVnOgyjq_xI,20919
|
74
77
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
75
78
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=2JSWF7AXQnv04_D_cu9Vmdkq0TWmGJ1QcK9AeqrA-U8,2765
|
76
79
|
prediction_market_agent_tooling/tools/gnosis_rpc.py,sha256=ctBfB1os-MvZ1tm0Rwdyn9b3dvFnlM9naKvZmzywc3A,197
|
77
|
-
prediction_market_agent_tooling/tools/google.py,sha256=
|
80
|
+
prediction_market_agent_tooling/tools/google.py,sha256=jwXhu4lKfF0cuu02fMX-mGCRntRgiGQWkZ2CstaprK4,1828
|
78
81
|
prediction_market_agent_tooling/tools/hexbytes_custom.py,sha256=Bp94qgPjvjWf1Vb4lNzGFDXRdThw1rJ91vL6r2PWq5E,2096
|
79
82
|
prediction_market_agent_tooling/tools/httpx_cached_client.py,sha256=0-N1r0zcGKlY9Rk-Ab8hbqwc54eMbsoa3jXL0_yCCiM,355
|
80
83
|
prediction_market_agent_tooling/tools/image_gen/image_gen.py,sha256=HzRwBx62hOXBOmrtpkXaP9Qq1Ku03uUGdREocyjLQ_k,1266
|
81
84
|
prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py,sha256=8A3U2uxsCsOfLjru-6R_PPIAuiKY4qFkWp_GSBPV6-s,1280
|
82
85
|
prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py,sha256=CTTMfTvs_8PH4kAtlQby2aeEKwgpmxtuGbd4oYIdJ2A,1201
|
83
|
-
prediction_market_agent_tooling/tools/is_invalid.py,sha256=
|
84
|
-
prediction_market_agent_tooling/tools/is_predictable.py,sha256=
|
86
|
+
prediction_market_agent_tooling/tools/is_invalid.py,sha256=GSMwSWUZy-xviaFoIl0L34AVfLLTdh7zegjsTFE7_1M,5323
|
87
|
+
prediction_market_agent_tooling/tools/is_predictable.py,sha256=VGkxSoJ8CSLknloOLzm5J4-us7XImYxVzvpsAzxbpCc,6730
|
85
88
|
prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
|
86
89
|
prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=B0PhAQyviFnVbtOCYMxYmcCn66cu9nbqAOIAZcdgiRI,5771
|
87
90
|
prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1gVlQSTskdVFTn09uPLST23YeipVIWj54io,2236
|
88
91
|
prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
|
89
92
|
prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py,sha256=95l84aztFaxcRLLcRQ46yKJbIlOEuDAbIGLouyliDzA,1316
|
90
|
-
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=
|
93
|
+
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=CddJem7tk15NAudJDwmuL8znTycbR-YI8kTNtd3LzG8,5474
|
91
94
|
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py,sha256=2yxtBIDyMT_6CsTpZyuIv_2dy2B9WgEOaTT1fSloBu0,3223
|
92
95
|
prediction_market_agent_tooling/tools/safe.py,sha256=9vxGGLvSPnfy-sxUFDpBTe8omqpGXP7MzvGPp6bRxrU,5197
|
93
96
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
94
97
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
95
|
-
prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=
|
96
|
-
prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=
|
97
|
-
prediction_market_agent_tooling/tools/
|
98
|
-
prediction_market_agent_tooling/tools/utils.py,sha256=W-9SqeCKd51BYMRhDjYPQ7lfNO_zE9EvYpmu2r5WXGA,7163
|
98
|
+
prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=5ldQs1pZe6uJ5eDAuP4OLpzmcqYShlIV67kttNFvGS0,342
|
99
|
+
prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=Kw2mXNkMTYTEe1MBSTqhQmLoeXtgb6CkmHlcAJvhtqE,3809
|
100
|
+
prediction_market_agent_tooling/tools/utils.py,sha256=1VvunbTmzGzpIlRukFhArreFNxJPbsg4lLtQNk0r2bY,7185
|
99
101
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=44W8siSLNQxeib98bbwAe7V5C609NHNlUuxwuWIRDiY,11838
|
100
|
-
prediction_market_agent_tooling-0.
|
101
|
-
prediction_market_agent_tooling-0.
|
102
|
-
prediction_market_agent_tooling-0.
|
103
|
-
prediction_market_agent_tooling-0.
|
104
|
-
prediction_market_agent_tooling-0.
|
102
|
+
prediction_market_agent_tooling-0.56.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
103
|
+
prediction_market_agent_tooling-0.56.0.dist-info/METADATA,sha256=FmWAg9sc322halWtR79LiDoJeRoz1bybzOJh4UynFuI,8106
|
104
|
+
prediction_market_agent_tooling-0.56.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
105
|
+
prediction_market_agent_tooling-0.56.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
106
|
+
prediction_market_agent_tooling-0.56.0.dist-info/RECORD,,
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import typing as t
|
2
|
-
|
3
|
-
from prediction_market_agent_tooling.jobs.jobs_models import JobAgentMarket
|
4
|
-
from prediction_market_agent_tooling.jobs.omen.omen_jobs import OmenJobAgentMarket
|
5
|
-
from prediction_market_agent_tooling.markets.agent_market import FilterBy, SortBy
|
6
|
-
from prediction_market_agent_tooling.markets.markets import MarketType
|
7
|
-
|
8
|
-
JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET: dict[MarketType, type[JobAgentMarket]] = {
|
9
|
-
MarketType.OMEN: OmenJobAgentMarket,
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
@t.overload
|
14
|
-
def get_jobs(
|
15
|
-
market_type: t.Literal[MarketType.OMEN],
|
16
|
-
limit: int | None,
|
17
|
-
filter_by: FilterBy = FilterBy.OPEN,
|
18
|
-
sort_by: SortBy = SortBy.NONE,
|
19
|
-
) -> t.Sequence[OmenJobAgentMarket]:
|
20
|
-
...
|
21
|
-
|
22
|
-
|
23
|
-
@t.overload
|
24
|
-
def get_jobs(
|
25
|
-
market_type: MarketType,
|
26
|
-
limit: int | None,
|
27
|
-
filter_by: FilterBy = FilterBy.OPEN,
|
28
|
-
sort_by: SortBy = SortBy.NONE,
|
29
|
-
) -> t.Sequence[JobAgentMarket]:
|
30
|
-
...
|
31
|
-
|
32
|
-
|
33
|
-
def get_jobs(
|
34
|
-
market_type: MarketType,
|
35
|
-
limit: int | None,
|
36
|
-
filter_by: FilterBy = FilterBy.OPEN,
|
37
|
-
sort_by: SortBy = SortBy.NONE,
|
38
|
-
) -> t.Sequence[JobAgentMarket]:
|
39
|
-
job_class = JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET[market_type]
|
40
|
-
markets = job_class.get_jobs(
|
41
|
-
limit=limit,
|
42
|
-
sort_by=sort_by,
|
43
|
-
filter_by=filter_by,
|
44
|
-
)
|
45
|
-
return markets
|
@@ -1,105 +0,0 @@
|
|
1
|
-
import typing as t
|
2
|
-
from datetime import timedelta
|
3
|
-
|
4
|
-
import tenacity
|
5
|
-
from sqlmodel import Session, SQLModel, create_engine, desc, select
|
6
|
-
|
7
|
-
from prediction_market_agent_tooling.config import APIKeys
|
8
|
-
from prediction_market_agent_tooling.loggers import logger
|
9
|
-
from prediction_market_agent_tooling.tools.tavily.tavily_models import (
|
10
|
-
TavilyResponse,
|
11
|
-
TavilyResponseModel,
|
12
|
-
)
|
13
|
-
from prediction_market_agent_tooling.tools.utils import utcnow
|
14
|
-
|
15
|
-
|
16
|
-
class TavilyStorage:
|
17
|
-
def __init__(self, agent_id: str, sqlalchemy_db_url: str | None = None):
|
18
|
-
self.agent_id = agent_id
|
19
|
-
self.engine = create_engine(
|
20
|
-
sqlalchemy_db_url
|
21
|
-
if sqlalchemy_db_url
|
22
|
-
else APIKeys().sqlalchemy_db_url.get_secret_value()
|
23
|
-
)
|
24
|
-
self._initialize_db()
|
25
|
-
|
26
|
-
def _initialize_db(self) -> None:
|
27
|
-
"""
|
28
|
-
Creates the tables if they don't exist
|
29
|
-
"""
|
30
|
-
|
31
|
-
# trick for making models import mandatory - models must be imported for metadata.create_all to work
|
32
|
-
logger.debug(f"tables being added {TavilyResponseModel}")
|
33
|
-
SQLModel.metadata.create_all(self.engine)
|
34
|
-
|
35
|
-
@tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(1))
|
36
|
-
def save(
|
37
|
-
self,
|
38
|
-
query: str,
|
39
|
-
search_depth: t.Literal["basic", "advanced"],
|
40
|
-
topic: t.Literal["general", "news"],
|
41
|
-
days: int | None,
|
42
|
-
max_results: int,
|
43
|
-
include_domains: t.Sequence[str] | None,
|
44
|
-
exclude_domains: t.Sequence[str] | None,
|
45
|
-
include_answer: bool,
|
46
|
-
include_raw_content: bool,
|
47
|
-
include_images: bool,
|
48
|
-
use_cache: bool,
|
49
|
-
response: TavilyResponse,
|
50
|
-
) -> None:
|
51
|
-
db_item = TavilyResponseModel.from_model(
|
52
|
-
agent_id=self.agent_id,
|
53
|
-
query=query,
|
54
|
-
search_depth=search_depth,
|
55
|
-
topic=topic,
|
56
|
-
max_results=max_results,
|
57
|
-
days=days,
|
58
|
-
include_domains=include_domains,
|
59
|
-
exclude_domains=exclude_domains,
|
60
|
-
include_answer=include_answer,
|
61
|
-
include_raw_content=include_raw_content,
|
62
|
-
include_images=include_images,
|
63
|
-
use_cache=use_cache,
|
64
|
-
response=response,
|
65
|
-
)
|
66
|
-
with Session(self.engine) as session:
|
67
|
-
session.add(db_item)
|
68
|
-
session.commit()
|
69
|
-
|
70
|
-
@tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(1))
|
71
|
-
def find(
|
72
|
-
self,
|
73
|
-
query: str,
|
74
|
-
search_depth: t.Literal["basic", "advanced"],
|
75
|
-
topic: t.Literal["general", "news"],
|
76
|
-
days: int | None,
|
77
|
-
max_results: int,
|
78
|
-
include_domains: t.Sequence[str] | None,
|
79
|
-
exclude_domains: t.Sequence[str] | None,
|
80
|
-
include_answer: bool,
|
81
|
-
include_raw_content: bool,
|
82
|
-
include_images: bool,
|
83
|
-
use_cache: bool,
|
84
|
-
max_age: timedelta = timedelta(days=1),
|
85
|
-
) -> TavilyResponse | None:
|
86
|
-
with Session(self.engine) as session:
|
87
|
-
sql_query = (
|
88
|
-
select(TavilyResponseModel)
|
89
|
-
.where(TavilyResponseModel.query == query)
|
90
|
-
.where(TavilyResponseModel.search_depth == search_depth)
|
91
|
-
.where(TavilyResponseModel.topic == topic)
|
92
|
-
.where(TavilyResponseModel.days == days)
|
93
|
-
.where(TavilyResponseModel.max_results == max_results)
|
94
|
-
.where(TavilyResponseModel.include_domains == include_domains)
|
95
|
-
.where(TavilyResponseModel.exclude_domains == exclude_domains)
|
96
|
-
.where(TavilyResponseModel.include_answer == include_answer)
|
97
|
-
.where(TavilyResponseModel.include_raw_content == include_raw_content)
|
98
|
-
.where(TavilyResponseModel.include_images == include_images)
|
99
|
-
.where(TavilyResponseModel.use_cache == use_cache)
|
100
|
-
.where(TavilyResponseModel.datetime_ >= utcnow() - max_age)
|
101
|
-
)
|
102
|
-
item = session.exec(
|
103
|
-
sql_query.order_by(desc(TavilyResponseModel.datetime_))
|
104
|
-
).first()
|
105
|
-
return TavilyResponse.model_validate(item.response) if item else None
|
File without changes
|
File without changes
|
File without changes
|