prediction-market-agent-tooling 0.64.9__tar.gz → 0.64.11__tar.gz
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-0.64.9 → prediction_market_agent_tooling-0.64.11}/PKG-INFO +1 -1
- prediction_market_agent_tooling-0.64.11/prediction_market_agent_tooling/logprobs_parser.py +155 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/data_models.py +2 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/omen.py +2 -1
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/pyproject.toml +1 -1
- prediction_market_agent_tooling-0.64.9/prediction_market_agent_tooling/logprobs_parser.py +0 -117
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/README.md +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/agent.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/betting_strategy.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/blockchain_utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/price_manager.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/seer.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
import math
|
2
|
+
from itertools import product
|
3
|
+
from typing import Any, Tuple, Type
|
4
|
+
|
5
|
+
from pydantic import BaseModel, ValidationError
|
6
|
+
from pydantic.fields import FieldInfo
|
7
|
+
from pydantic.type_adapter import TypeAdapter
|
8
|
+
|
9
|
+
from prediction_market_agent_tooling.loggers import logger
|
10
|
+
|
11
|
+
|
12
|
+
class LogprobDetail(BaseModel):
|
13
|
+
token: str
|
14
|
+
logprob: float
|
15
|
+
prob: float
|
16
|
+
|
17
|
+
|
18
|
+
class FieldLogprobs(BaseModel):
|
19
|
+
key: str
|
20
|
+
logprobs: list[LogprobDetail]
|
21
|
+
|
22
|
+
|
23
|
+
class LogprobsParser:
|
24
|
+
def __init__(
|
25
|
+
self,
|
26
|
+
skip_fields: list[str] | None = None,
|
27
|
+
max_top_logprobs_length: int = 3,
|
28
|
+
max_logprobs_length: int = 5,
|
29
|
+
):
|
30
|
+
base_skip_fields = ["logprobs"]
|
31
|
+
self.skip_fields = base_skip_fields + (skip_fields or [])
|
32
|
+
self.max_top_logprobs_length = max_top_logprobs_length
|
33
|
+
self.max_logprobs_length = max_logprobs_length
|
34
|
+
|
35
|
+
def _get_logprobs_key_index(
|
36
|
+
self, logprobs: list[dict[str, Any]], field_name: str
|
37
|
+
) -> int:
|
38
|
+
key_candidate = ""
|
39
|
+
for i, token in enumerate(logprobs):
|
40
|
+
if token["token"] in field_name:
|
41
|
+
key_candidate = key_candidate + token["token"]
|
42
|
+
else:
|
43
|
+
key_candidate = ""
|
44
|
+
if key_candidate == field_name:
|
45
|
+
return i
|
46
|
+
|
47
|
+
return -1
|
48
|
+
|
49
|
+
def _get_logprobs_indexes_for_result(
|
50
|
+
self, logprobs: list[dict[str, Any]], key_index: int
|
51
|
+
) -> Tuple[int, int]:
|
52
|
+
result_start_index = next(
|
53
|
+
(
|
54
|
+
i
|
55
|
+
for i in range(key_index + 1, len(logprobs))
|
56
|
+
if logprobs[i]["token"] in {":", ",", " ", ' "', '"', "\t", "\u00A0"}
|
57
|
+
),
|
58
|
+
-1,
|
59
|
+
)
|
60
|
+
result_end_index = next(
|
61
|
+
(
|
62
|
+
i
|
63
|
+
for i in range(result_start_index, len(logprobs))
|
64
|
+
if logprobs[i]["token"] in {",", '"', ",\n", "\",\n'", '",\n'}
|
65
|
+
),
|
66
|
+
len(logprobs) - 1,
|
67
|
+
)
|
68
|
+
return result_start_index + 1, result_end_index
|
69
|
+
|
70
|
+
def _is_correct_type(self, token: str, key_type: type | None) -> bool:
|
71
|
+
if key_type is None:
|
72
|
+
return True
|
73
|
+
|
74
|
+
try:
|
75
|
+
TypeAdapter(key_type).validate_python(token)
|
76
|
+
return True
|
77
|
+
except ValidationError:
|
78
|
+
return False
|
79
|
+
|
80
|
+
def _parse_valid_tokens_with__agg_probs(
|
81
|
+
self,
|
82
|
+
logprobs_list: list[tuple[dict[str, Any]]],
|
83
|
+
field_info: FieldInfo,
|
84
|
+
top_logprobs: int,
|
85
|
+
) -> list[dict[str, Any]]:
|
86
|
+
results: list[dict[str, Any]] = [
|
87
|
+
{
|
88
|
+
"token": "".join(str(logprob["token"]) for logprob in logprobs),
|
89
|
+
"logprob": sum(float(logprob["logprob"]) for logprob in logprobs),
|
90
|
+
"prob": math.exp(
|
91
|
+
sum(float(logprob["logprob"]) for logprob in logprobs)
|
92
|
+
),
|
93
|
+
}
|
94
|
+
for logprobs in logprobs_list
|
95
|
+
]
|
96
|
+
|
97
|
+
results_filtered: list[dict[str, Any]] = [
|
98
|
+
result
|
99
|
+
for result in results
|
100
|
+
if self._is_correct_type(result["token"], field_info.annotation)
|
101
|
+
]
|
102
|
+
|
103
|
+
sorted_results = sorted(
|
104
|
+
results_filtered, key=lambda x: x["logprob"], reverse=True
|
105
|
+
)
|
106
|
+
return (
|
107
|
+
sorted_results[:top_logprobs]
|
108
|
+
if len(sorted_results) > top_logprobs
|
109
|
+
else sorted_results
|
110
|
+
)
|
111
|
+
|
112
|
+
def parse_logprobs(
|
113
|
+
self, logprobs: list[dict[str, Any]], target_model_cls: Type[BaseModel]
|
114
|
+
) -> list[FieldLogprobs]:
|
115
|
+
results_for_keys = []
|
116
|
+
|
117
|
+
for field_name, field_info in target_model_cls.model_fields.items():
|
118
|
+
if field_name in self.skip_fields:
|
119
|
+
continue
|
120
|
+
|
121
|
+
key_index = self._get_logprobs_key_index(logprobs, field_name)
|
122
|
+
|
123
|
+
if key_index < 0:
|
124
|
+
logger.warning(f"Key {field_name} not found in logprobs")
|
125
|
+
continue
|
126
|
+
|
127
|
+
(
|
128
|
+
result_start_index,
|
129
|
+
result_end_index,
|
130
|
+
) = self._get_logprobs_indexes_for_result(logprobs, key_index)
|
131
|
+
|
132
|
+
if result_start_index < 0 or result_end_index < 0:
|
133
|
+
logger.warning(f"Error in parsing result for {field_name} in logprobs")
|
134
|
+
continue
|
135
|
+
|
136
|
+
valid_logprobs_raw = [
|
137
|
+
logprobs[i]["top_logprobs"][: self.max_top_logprobs_length]
|
138
|
+
for i in range(result_start_index, result_end_index)
|
139
|
+
if logprobs[i]["top_logprobs"] is not None
|
140
|
+
]
|
141
|
+
|
142
|
+
parsed_logprobs_data = self._parse_valid_tokens_with__agg_probs(
|
143
|
+
list(product(*valid_logprobs_raw[: self.max_logprobs_length])),
|
144
|
+
field_info,
|
145
|
+
min(len(sublist) for sublist in valid_logprobs_raw),
|
146
|
+
)
|
147
|
+
|
148
|
+
results_for_keys.append(
|
149
|
+
FieldLogprobs(
|
150
|
+
key=field_name,
|
151
|
+
logprobs=[LogprobDetail(**item) for item in parsed_logprobs_data],
|
152
|
+
)
|
153
|
+
)
|
154
|
+
|
155
|
+
return results_for_keys
|
@@ -10,6 +10,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
10
10
|
OutcomeToken,
|
11
11
|
Probability,
|
12
12
|
)
|
13
|
+
from prediction_market_agent_tooling.logprobs_parser import FieldLogprobs
|
13
14
|
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
14
15
|
|
15
16
|
|
@@ -77,6 +78,7 @@ class ProbabilisticAnswer(BaseModel):
|
|
77
78
|
p_yes: Probability
|
78
79
|
confidence: float
|
79
80
|
reasoning: str | None = None
|
81
|
+
logprobs: list[FieldLogprobs] | None = None
|
80
82
|
|
81
83
|
@property
|
82
84
|
def p_no(self) -> Probability:
|
@@ -89,7 +89,8 @@ from prediction_market_agent_tooling.tools.utils import (
|
|
89
89
|
from prediction_market_agent_tooling.tools.web3_utils import get_receipt_block_timestamp
|
90
90
|
|
91
91
|
OMEN_DEFAULT_REALITIO_BOND_VALUE = xDai(0.01)
|
92
|
-
|
92
|
+
# Too low value would work with the Omen contract, but causes CoW orders (when buying the specific market's tokens) to fail.
|
93
|
+
OMEN_TINY_BET_AMOUNT = USD(0.001)
|
93
94
|
|
94
95
|
|
95
96
|
class OmenAgentMarket(AgentMarket):
|
@@ -1,117 +0,0 @@
|
|
1
|
-
import math
|
2
|
-
from itertools import product
|
3
|
-
from typing import Any, Tuple
|
4
|
-
|
5
|
-
from pydantic import BaseModel
|
6
|
-
|
7
|
-
from prediction_market_agent_tooling.loggers import logger
|
8
|
-
|
9
|
-
|
10
|
-
class LogprobKey(BaseModel):
|
11
|
-
name: str
|
12
|
-
key_type: type
|
13
|
-
valid_values: set[Any] | None
|
14
|
-
|
15
|
-
|
16
|
-
class LogprobsParser:
|
17
|
-
def _get_logprobs_key_index(
|
18
|
-
self, logprobs: list[dict[str, Any]], key: LogprobKey
|
19
|
-
) -> int:
|
20
|
-
key_candidate = ""
|
21
|
-
for i, token in enumerate(logprobs):
|
22
|
-
if token["token"] in key.name:
|
23
|
-
key_candidate = key_candidate + token["token"]
|
24
|
-
else:
|
25
|
-
key_candidate = ""
|
26
|
-
if key_candidate == key.name:
|
27
|
-
return i
|
28
|
-
|
29
|
-
return -1
|
30
|
-
|
31
|
-
def _get_logprobs_indexes_for_result(
|
32
|
-
self, logprobs: list[dict[str, Any]], key_index: int
|
33
|
-
) -> Tuple[int, int]:
|
34
|
-
result_start_index = next(
|
35
|
-
(
|
36
|
-
i
|
37
|
-
for i in range(key_index + 1, len(logprobs))
|
38
|
-
if logprobs[i]["token"] in {":", ",", " ", ' "', '"', "\t", "\u00A0"}
|
39
|
-
),
|
40
|
-
-1,
|
41
|
-
)
|
42
|
-
result_end_index = next(
|
43
|
-
(
|
44
|
-
i
|
45
|
-
for i in range(result_start_index, len(logprobs))
|
46
|
-
if logprobs[i]["token"] in {",", '"', ",\n", "\",\n'", '",\n'}
|
47
|
-
),
|
48
|
-
-1,
|
49
|
-
)
|
50
|
-
return result_start_index + 1, result_end_index
|
51
|
-
|
52
|
-
def _is_correct_type(self, token: str, key_type: type) -> bool:
|
53
|
-
try:
|
54
|
-
key_type(token)
|
55
|
-
return True
|
56
|
-
except ValueError:
|
57
|
-
return False
|
58
|
-
|
59
|
-
def _parse_valid_tokens_with__agg_probs(
|
60
|
-
self, logprobs_list: list[tuple[dict[str, Any]]], key: LogprobKey
|
61
|
-
) -> list[dict[str, Any]]:
|
62
|
-
results: list[dict[str, Any]] = [
|
63
|
-
{
|
64
|
-
"token": "".join(str(logprob["token"]) for logprob in logprobs),
|
65
|
-
"logprob": sum(float(logprob["logprob"]) for logprob in logprobs),
|
66
|
-
"prob": math.exp(
|
67
|
-
sum(float(logprob["logprob"]) for logprob in logprobs)
|
68
|
-
),
|
69
|
-
}
|
70
|
-
for logprobs in logprobs_list
|
71
|
-
]
|
72
|
-
|
73
|
-
results_filtered: list[dict[str, Any]] = [
|
74
|
-
result
|
75
|
-
for result in results
|
76
|
-
if self._is_correct_type(result["token"], key.key_type)
|
77
|
-
and (key.valid_values is None or result["token"] in key.valid_values)
|
78
|
-
]
|
79
|
-
|
80
|
-
return sorted(results_filtered, key=lambda x: x["logprob"], reverse=True)[
|
81
|
-
: len(logprobs_list[0])
|
82
|
-
]
|
83
|
-
|
84
|
-
def parse_logprobs(
|
85
|
-
self, logprobs: list[dict[str, Any]], keys: list[LogprobKey]
|
86
|
-
) -> list[dict[str, Any]]:
|
87
|
-
results_for_keys = []
|
88
|
-
|
89
|
-
for key in keys:
|
90
|
-
key_index = self._get_logprobs_key_index(logprobs, key)
|
91
|
-
if key_index < 0:
|
92
|
-
logger.warning(f"Key {key.name} not found in logprobs")
|
93
|
-
continue
|
94
|
-
|
95
|
-
(
|
96
|
-
result_start_index,
|
97
|
-
result_end_index,
|
98
|
-
) = self._get_logprobs_indexes_for_result(logprobs, key_index)
|
99
|
-
if result_start_index < 0 or result_end_index < 0:
|
100
|
-
logger.warning(f"Error in parsing result for {key.name} in logprobs")
|
101
|
-
continue
|
102
|
-
|
103
|
-
valid_logprobs = [
|
104
|
-
logprobs[i]["top_logprobs"]
|
105
|
-
for i in range(result_start_index, result_end_index)
|
106
|
-
]
|
107
|
-
|
108
|
-
results_for_keys.append(
|
109
|
-
{
|
110
|
-
"key": key.name,
|
111
|
-
"logprobs": self._parse_valid_tokens_with__agg_probs(
|
112
|
-
list(product(*valid_logprobs)), key
|
113
|
-
),
|
114
|
-
}
|
115
|
-
)
|
116
|
-
|
117
|
-
return results_for_keys
|
File without changes
|
{prediction_market_agent_tooling-0.64.9 → prediction_market_agent_tooling-0.64.11}/README.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|