prediction-market-agent-tooling 0.69.5.dev1084__tar.gz → 0.69.6__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.
Files changed (143) hide show
  1. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/PKG-INFO +3 -2
  2. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/README.md +2 -1
  3. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/data_download/langfuse_data_downloader.py +1 -1
  4. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/agent.py +1 -1
  5. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/agent_example.py +1 -1
  6. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/betting_strategy.py +1 -1
  7. prediction_market_agent_tooling-0.69.5.dev1084/prediction_market_agent_tooling/markets/markets.py → prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/markets/market_type.py +4 -29
  8. prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/markets/markets.py +34 -0
  9. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/omen.py +1 -1
  10. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +1 -1
  11. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +25 -3
  12. prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py +91 -0
  13. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/utils.py +1 -1
  14. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/_generic_value.py +1 -1
  15. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/contract.py +29 -1
  16. prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/tools/contract_utils.py +61 -0
  17. prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/tools/openai_utils.py +31 -0
  18. prediction_market_agent_tooling-0.69.6/prediction_market_agent_tooling/tools/streamlit_utils.py +188 -0
  19. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/pyproject.toml +1 -1
  20. prediction_market_agent_tooling-0.69.5.dev1084/prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py +0 -50
  21. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/LICENSE +0 -0
  22. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/agentresultmapping.abi.json +0 -0
  23. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
  24. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
  25. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/erc1155.abi.json +0 -0
  26. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
  27. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
  28. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
  29. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
  30. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
  31. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
  32. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
  33. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
  34. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
  35. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
  36. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
  37. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
  38. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
  39. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
  40. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
  41. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json +0 -0
  42. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
  43. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/abis/swapr_router.abi.json +0 -0
  44. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
  45. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
  46. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
  47. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
  48. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/chains.py +0 -0
  49. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/config.py +0 -0
  50. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/constants.py +0 -0
  51. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
  52. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
  53. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
  54. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
  55. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/gtypes.py +0 -0
  56. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
  57. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
  58. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
  59. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/loggers.py +0 -0
  60. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/logprobs_parser.py +0 -0
  61. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
  62. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
  63. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/blockchain_utils.py +0 -0
  64. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/categorize.py +0 -0
  65. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/data_models.py +0 -0
  66. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
  67. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
  68. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
  69. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
  70. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
  71. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
  72. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
  73. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
  74. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
  75. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
  76. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
  77. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
  78. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
  79. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
  80. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
  81. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
  82. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/clob_manager.py +0 -0
  83. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/constants.py +0 -0
  84. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
  85. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/polymarket/polymarket_contracts.py +0 -0
  86. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/data_models.py +0 -0
  87. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/exceptions.py +0 -0
  88. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/price_manager.py +0 -0
  89. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/seer.py +0 -0
  90. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/seer_api.py +0 -0
  91. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
  92. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +0 -0
  93. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -0
  94. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/markets/seer/swap_pool_handler.py +0 -0
  95. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/py.typed +0 -0
  96. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/balances.py +0 -0
  97. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
  98. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
  99. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
  100. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
  101. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
  102. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
  103. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/costs.py +0 -0
  104. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
  105. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/cow/models.py +0 -0
  106. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/cow/semaphore.py +0 -0
  107. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
  108. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
  109. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
  110. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
  111. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
  112. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
  113. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
  114. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
  115. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
  116. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
  117. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
  118. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
  119. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
  120. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
  121. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
  122. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
  123. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/perplexity/perplexity_client.py +0 -0
  124. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/perplexity/perplexity_models.py +0 -0
  125. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/perplexity/perplexity_search.py +0 -0
  126. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
  127. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
  128. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
  129. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/rephrase.py +0 -0
  130. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/safe.py +0 -0
  131. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/singleton.py +0 -0
  132. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
  133. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
  134. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
  135. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
  136. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
  137. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
  138. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/slippage.py +0 -0
  139. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
  140. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
  141. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
  142. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/utils.py +0 -0
  143. {prediction_market_agent_tooling-0.69.5.dev1084 → prediction_market_agent_tooling-0.69.6}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.69.5.dev1084
3
+ Version: 0.69.6
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -101,7 +101,8 @@ For example:
101
101
  ```python
102
102
  import prediction_market_agent_tooling.benchmark.benchmark as bm
103
103
  from prediction_market_agent_tooling.benchmark.agents import RandomAgent
104
- from prediction_market_agent_tooling.markets.markets import MarketType, get_binary_markets
104
+ from prediction_market_agent_tooling.markets.market_type import MarketType
105
+ from prediction_market_agent_tooling.markets.markets import get_binary_markets
105
106
 
106
107
  benchmarker = bm.Benchmarker(
107
108
  markets=get_binary_markets(limit=10, market_type=MarketType.MANIFOLD),
@@ -33,7 +33,8 @@ For example:
33
33
  ```python
34
34
  import prediction_market_agent_tooling.benchmark.benchmark as bm
35
35
  from prediction_market_agent_tooling.benchmark.agents import RandomAgent
36
- from prediction_market_agent_tooling.markets.markets import MarketType, get_binary_markets
36
+ from prediction_market_agent_tooling.markets.market_type import MarketType
37
+ from prediction_market_agent_tooling.markets.markets import get_binary_markets
37
38
 
38
39
  benchmarker = bm.Benchmarker(
39
40
  markets=get_binary_markets(limit=10, market_type=MarketType.MANIFOLD),
@@ -16,7 +16,7 @@ from prediction_market_agent_tooling.gtypes import DatetimeUTC, OutcomeStr, Outc
16
16
  from prediction_market_agent_tooling.loggers import logger
17
17
  from prediction_market_agent_tooling.markets.agent_market import AgentMarket
18
18
  from prediction_market_agent_tooling.markets.data_models import Resolution
19
- from prediction_market_agent_tooling.markets.markets import MarketType
19
+ from prediction_market_agent_tooling.markets.market_type import MarketType
20
20
  from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
21
21
  from prediction_market_agent_tooling.markets.seer.seer import SeerAgentMarket
22
22
  from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
@@ -36,7 +36,7 @@ from prediction_market_agent_tooling.markets.data_models import (
36
36
  ScalarProbabilisticAnswer,
37
37
  Trade,
38
38
  )
39
- from prediction_market_agent_tooling.markets.markets import MarketType
39
+ from prediction_market_agent_tooling.markets.market_type import MarketType
40
40
  from prediction_market_agent_tooling.tools.custom_exceptions import (
41
41
  CantPayForGasError,
42
42
  OutOfFundsError,
@@ -6,7 +6,7 @@ from prediction_market_agent_tooling.markets.agent_market import AgentMarket, So
6
6
  from prediction_market_agent_tooling.markets.data_models import (
7
7
  CategoricalProbabilisticAnswer,
8
8
  )
9
- from prediction_market_agent_tooling.markets.markets import MarketType
9
+ from prediction_market_agent_tooling.markets.market_type import MarketType
10
10
 
11
11
 
12
12
  class DeployableCoinFlipAgent(DeployableTraderAgent):
@@ -26,7 +26,7 @@ from prediction_market_agent_tooling.markets.data_models import (
26
26
  Trade,
27
27
  TradeType,
28
28
  )
29
- from prediction_market_agent_tooling.markets.markets import MarketType
29
+ from prediction_market_agent_tooling.markets.market_type import MarketType
30
30
  from prediction_market_agent_tooling.markets.omen.omen import (
31
31
  get_buy_outcome_token_amount,
32
32
  )
@@ -1,14 +1,9 @@
1
- import typing as t
2
1
  from enum import Enum
2
+ from typing import TypeVar
3
3
 
4
4
  from prediction_market_agent_tooling.jobs.jobs_models import JobAgentMarket
5
5
  from prediction_market_agent_tooling.jobs.omen.omen_jobs import OmenJobAgentMarket
6
- from prediction_market_agent_tooling.markets.agent_market import (
7
- AgentMarket,
8
- FilterBy,
9
- QuestionType,
10
- SortBy,
11
- )
6
+ from prediction_market_agent_tooling.markets.agent_market import AgentMarket
12
7
  from prediction_market_agent_tooling.markets.manifold.manifold import (
13
8
  ManifoldAgentMarket,
14
9
  )
@@ -20,7 +15,8 @@ from prediction_market_agent_tooling.markets.polymarket.polymarket import (
20
15
  PolymarketAgentMarket,
21
16
  )
22
17
  from prediction_market_agent_tooling.markets.seer.seer import SeerAgentMarket
23
- from prediction_market_agent_tooling.tools.utils import DatetimeUTC
18
+
19
+ T = TypeVar("T", bound=AgentMarket)
24
20
 
25
21
 
26
22
  class MarketType(str, Enum):
@@ -76,24 +72,3 @@ AGENT_MARKET_TO_MARKET_TYPE: dict[type[AgentMarket], MarketType] = {
76
72
  JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET: dict[MarketType, type[JobAgentMarket]] = {
77
73
  MarketType.OMEN: OmenJobAgentMarket,
78
74
  }
79
-
80
-
81
- def get_binary_markets(
82
- limit: int,
83
- market_type: MarketType,
84
- filter_by: FilterBy = FilterBy.OPEN,
85
- sort_by: SortBy = SortBy.NONE,
86
- excluded_questions: set[str] | None = None,
87
- created_after: DatetimeUTC | None = None,
88
- question_type: QuestionType = QuestionType.BINARY,
89
- ) -> t.Sequence[AgentMarket]:
90
- agent_market_class = MARKET_TYPE_TO_AGENT_MARKET[market_type]
91
- markets = agent_market_class.get_markets(
92
- limit=limit,
93
- sort_by=sort_by,
94
- filter_by=filter_by,
95
- created_after=created_after,
96
- excluded_questions=excluded_questions,
97
- question_type=question_type,
98
- )
99
- return markets
@@ -0,0 +1,34 @@
1
+ import typing as t
2
+
3
+ from prediction_market_agent_tooling.markets.agent_market import (
4
+ AgentMarket,
5
+ FilterBy,
6
+ QuestionType,
7
+ SortBy,
8
+ )
9
+ from prediction_market_agent_tooling.markets.market_type import (
10
+ MARKET_TYPE_TO_AGENT_MARKET,
11
+ MarketType,
12
+ )
13
+ from prediction_market_agent_tooling.tools.utils import DatetimeUTC
14
+
15
+
16
+ def get_binary_markets(
17
+ limit: int,
18
+ market_type: MarketType,
19
+ filter_by: FilterBy = FilterBy.OPEN,
20
+ sort_by: SortBy = SortBy.NONE,
21
+ excluded_questions: set[str] | None = None,
22
+ created_after: DatetimeUTC | None = None,
23
+ question_type: QuestionType = QuestionType.BINARY,
24
+ ) -> t.Sequence[AgentMarket]:
25
+ agent_market_class = MARKET_TYPE_TO_AGENT_MARKET[market_type]
26
+ markets = agent_market_class.get_markets(
27
+ limit=limit,
28
+ sort_by=sort_by,
29
+ filter_by=filter_by,
30
+ created_after=created_after,
31
+ excluded_questions=excluded_questions,
32
+ question_type=question_type,
33
+ )
34
+ return markets
@@ -1114,7 +1114,7 @@ def get_conditional_tokens_balance_for_market(
1114
1114
 
1115
1115
  for index_set in market.condition.index_sets:
1116
1116
  collection_id = conditional_token_contract.getCollectionId(
1117
- parent_collection_id, market.condition.id, index_set, web3=web3
1117
+ HexBytes(parent_collection_id), market.condition.id, index_set, web3=web3
1118
1118
  )
1119
1119
  # Note that collection_id is returned as bytes, which is accepted by the contract calls downstream.
1120
1120
  position_id: int = conditional_token_contract.getPositionId(
@@ -13,7 +13,7 @@ from prediction_market_agent_tooling.markets.data_models import Resolution
13
13
  from prediction_market_agent_tooling.markets.manifold.api import (
14
14
  find_resolution_on_manifold,
15
15
  )
16
- from prediction_market_agent_tooling.markets.markets import MarketType
16
+ from prediction_market_agent_tooling.markets.market_type import MarketType
17
17
  from prediction_market_agent_tooling.markets.omen.data_models import (
18
18
  OmenMarket,
19
19
  RealityQuestion,
@@ -46,6 +46,7 @@ from prediction_market_agent_tooling.markets.polymarket.data_models import (
46
46
  PolymarketGammaResponseDataItem,
47
47
  )
48
48
  from prediction_market_agent_tooling.markets.polymarket.polymarket_contracts import (
49
+ PolymarketConditionalTokenContract,
49
50
  USDCeContract,
50
51
  )
51
52
  from prediction_market_agent_tooling.markets.polymarket.polymarket_subgraph_handler import (
@@ -266,9 +267,30 @@ class PolymarketAgentMarket(AgentMarket):
266
267
  )
267
268
 
268
269
  @staticmethod
269
- def redeem_winnings(api_keys: APIKeys) -> None:
270
- # ToDo - implement me - https://github.com/gnosis/prediction-market-agent-tooling/issues/824
271
- pass
270
+ def redeem_winnings(api_keys: APIKeys, web3: Web3 | None = None) -> None:
271
+ web3 = web3 or RPCConfig().get_polygon_web3()
272
+ user_id = api_keys.bet_from_address
273
+ conditional_token_contract = PolymarketConditionalTokenContract()
274
+ positions = PolymarketSubgraphHandler().get_market_positions_from_user(user_id)
275
+ for pos in positions:
276
+ if (
277
+ pos.market.condition.resolutionTimestamp is None
278
+ or pos.market.condition.payoutNumerators is None
279
+ ):
280
+ continue
281
+
282
+ condition_id = pos.market.condition.id
283
+ index_sets = pos.market.condition.index_sets
284
+
285
+ redeem_event = conditional_token_contract.redeemPositions(
286
+ api_keys=api_keys,
287
+ collateral_token_address=USDCeContract().address,
288
+ condition_id=condition_id,
289
+ index_sets=index_sets,
290
+ web3=web3,
291
+ )
292
+
293
+ logger.info(f"Redeemed {redeem_event=} from condition_id {condition_id=}.")
272
294
 
273
295
  @staticmethod
274
296
  def verify_operational_balance(api_keys: APIKeys) -> bool:
@@ -0,0 +1,91 @@
1
+ from pydantic import BaseModel
2
+ from subgrounds import FieldPath
3
+
4
+ from prediction_market_agent_tooling.gtypes import ChecksumAddress, HexBytes
5
+ from prediction_market_agent_tooling.markets.base_subgraph_handler import (
6
+ BaseSubgraphHandler,
7
+ )
8
+
9
+
10
+ class ConditionSubgraphModel(BaseModel):
11
+ id: HexBytes
12
+ payoutDenominator: int | None = None
13
+ payoutNumerators: list[int] | None = None
14
+ outcomeSlotCount: int
15
+ resolutionTimestamp: int | None = None
16
+ questionId: HexBytes
17
+
18
+ @property
19
+ def index_sets(self) -> list[int]:
20
+ return [i + 1 for i in range(self.outcomeSlotCount)]
21
+
22
+
23
+ class MarketPositionMarket(BaseModel):
24
+ condition: ConditionSubgraphModel
25
+
26
+
27
+ class MarketPosition(BaseModel):
28
+ id: HexBytes
29
+ market: MarketPositionMarket
30
+
31
+
32
+ class PolymarketSubgraphHandler(BaseSubgraphHandler):
33
+ POLYMARKET_CONDITIONS_SUBGRAPH = "https://gateway.thegraph.com/api/{graph_api_key}/subgraphs/id/81Dm16JjuFSrqz813HysXoUPvzTwE7fsfPk2RTf66nyC"
34
+
35
+ def __init__(self) -> None:
36
+ super().__init__()
37
+
38
+ # Load the subgraph
39
+ self.conditions_subgraph = self.sg.load_subgraph(
40
+ self.POLYMARKET_CONDITIONS_SUBGRAPH.format(
41
+ graph_api_key=self.keys.graph_api_key.get_secret_value()
42
+ )
43
+ )
44
+
45
+ def _get_fields_for_condition(self, field: FieldPath) -> list[FieldPath]:
46
+ return [
47
+ field.id,
48
+ field.questionId,
49
+ field.payoutNumerators,
50
+ field.payoutDenominator,
51
+ field.outcomeSlotCount,
52
+ field.resolutionTimestamp,
53
+ ]
54
+
55
+ def get_conditions(
56
+ self, condition_ids: list[HexBytes]
57
+ ) -> list[ConditionSubgraphModel]:
58
+ where_stms = {"id_in": [i.to_0x_hex() for i in condition_ids]}
59
+ conditions = self.conditions_subgraph.Query.conditions(
60
+ first=len(condition_ids),
61
+ where=where_stms,
62
+ )
63
+
64
+ condition_fields = self._get_fields_for_condition(conditions)
65
+
66
+ conditions_models = self.do_query(
67
+ fields=condition_fields, pydantic_model=ConditionSubgraphModel
68
+ )
69
+ return conditions_models
70
+
71
+ def get_market_positions_from_user(
72
+ self,
73
+ user: ChecksumAddress,
74
+ first: int = 1000,
75
+ block_number: int | None = None,
76
+ ) -> list[MarketPosition]:
77
+ # Not possible to filter using `market_.condition` on a subgraph level, bad indexers error.
78
+ positions = self.conditions_subgraph.Query.marketPositions(
79
+ first=first,
80
+ where={"user": user.lower()},
81
+ block={"number": block_number} if block_number else None,
82
+ )
83
+
84
+ condition_fields = self._get_fields_for_condition(
85
+ positions.market.condition
86
+ ) + [positions.id]
87
+
88
+ positions_models = self.do_query(
89
+ fields=condition_fields, pydantic_model=MarketPosition
90
+ )
91
+ return positions_models
@@ -1,4 +1,4 @@
1
- from prediction_market_agent_tooling.markets.markets import MarketType
1
+ from prediction_market_agent_tooling.markets.market_type import MarketType
2
2
  from prediction_market_agent_tooling.tools.google_utils import search_google_gcp
3
3
 
4
4
 
@@ -239,7 +239,7 @@ class _GenericValue(
239
239
  cls, source_type: t.Any, handler: GetCoreSchemaHandler
240
240
  ) -> CoreSchema:
241
241
  # Support for Pydantic usage.
242
- dt_schema = handler(str | int | float | dict)
242
+ dt_schema = handler(cls.parser | str | dict)
243
243
  return core_schema.no_info_after_validator_function(
244
244
  lambda x: cls(x["value"] if isinstance(x, dict) else x),
245
245
  dt_schema,
@@ -665,7 +665,7 @@ class ConditionalTokenContract(ContractBaseClass):
665
665
 
666
666
  def getCollectionId(
667
667
  self,
668
- parent_collection_id: HexStr,
668
+ parent_collection_id: HexBytes,
669
669
  condition_id: HexBytes,
670
670
  index_set: int,
671
671
  web3: Web3 | None = None,
@@ -773,6 +773,34 @@ class ConditionalTokenContract(ContractBaseClass):
773
773
  )
774
774
  return payoutForCondition
775
775
 
776
+ def splitPosition(
777
+ self,
778
+ api_keys: APIKeys,
779
+ collateral_token: ChecksumAddress,
780
+ condition_id: HexBytes,
781
+ outcome_slot_count: int,
782
+ amount_wei: Wei,
783
+ parent_collateral_id: HexBytes = HexBytes(HASH_ZERO),
784
+ tx_params: t.Optional[TxParams] = None,
785
+ web3: Web3 | None = None,
786
+ ) -> TxReceipt:
787
+ # We always split the full set of outcome tokens (for simplicity)
788
+ # partitions are given in bitmasks, i.e. outcomes are 1,2,4,8,etc.
789
+ partition = [2**i for i in range(outcome_slot_count)]
790
+ return self.send(
791
+ api_keys=api_keys,
792
+ function_name="splitPosition",
793
+ function_params=[
794
+ collateral_token,
795
+ parent_collateral_id,
796
+ condition_id,
797
+ partition,
798
+ amount_wei,
799
+ ],
800
+ tx_params=tx_params,
801
+ web3=web3,
802
+ )
803
+
776
804
  def setApprovalForAll(
777
805
  self,
778
806
  api_keys: APIKeys,
@@ -0,0 +1,61 @@
1
+ from web3 import Web3
2
+
3
+ from prediction_market_agent_tooling.config import RPCConfig
4
+ from prediction_market_agent_tooling.gtypes import ChecksumAddress
5
+ from prediction_market_agent_tooling.tools.contract import contract_implements_function
6
+
7
+
8
+ def is_erc20_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
9
+ """
10
+ Checks if the given address is an ERC20-compatible contract.
11
+
12
+ It estimates it by looking if it implements symbol, name, decimals, totalSupply, balanceOf.
13
+ """
14
+ web3 = web3 or RPCConfig().get_web3()
15
+ return (
16
+ contract_implements_function(address, "symbol", web3)
17
+ and contract_implements_function(address, "name", web3)
18
+ and contract_implements_function(address, "totalSupply", web3)
19
+ and contract_implements_function(
20
+ address, "balanceOf", web3, function_arg_types=["address"]
21
+ )
22
+ )
23
+
24
+
25
+ def is_nft_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
26
+ """
27
+ Checks if the given address is an NFT-compatible contract (ERC721 or ERC1155).
28
+
29
+ For ERC721, checks for: ownerOf, balanceOf, transferFrom.
30
+ For ERC1155, checks for: balanceOf, safeTransferFrom.
31
+
32
+ Returns True if either ERC721 or ERC1155 interface is detected.
33
+ """
34
+ web3 = web3 or RPCConfig().get_web3()
35
+ is_erc721 = (
36
+ contract_implements_function(
37
+ address, "ownerOf", web3, function_arg_types=["uint256"]
38
+ )
39
+ and contract_implements_function(
40
+ address, "balanceOf", web3, function_arg_types=["address"]
41
+ )
42
+ and contract_implements_function(
43
+ address,
44
+ "transferFrom",
45
+ web3,
46
+ function_arg_types=["address", "address", "uint256"],
47
+ )
48
+ )
49
+ if is_erc721:
50
+ return True
51
+ is_erc1155 = contract_implements_function(
52
+ address, "balanceOf", web3, function_arg_types=["address", "uint256"]
53
+ ) and contract_implements_function(
54
+ address,
55
+ "safeTransferFrom",
56
+ web3,
57
+ function_arg_types=["address", "address", "uint256", "uint256", "bytes"],
58
+ )
59
+ if is_erc1155:
60
+ return True
61
+ return False
@@ -0,0 +1,31 @@
1
+ from langfuse.openai import AsyncOpenAI
2
+ from openai import DEFAULT_TIMEOUT, DefaultAsyncHttpxClient
3
+ from pydantic import SecretStr
4
+ from pydantic_ai.models.openai import OpenAIModel # noqa: F401 # Just for convenience.
5
+ from pydantic_ai.providers.openai import OpenAIProvider
6
+
7
+ OPENAI_BASE_URL = "https://api.openai.com/v1"
8
+
9
+
10
+ def get_openai_provider(
11
+ api_key: SecretStr,
12
+ base_url: str = OPENAI_BASE_URL,
13
+ ) -> OpenAIProvider:
14
+ """
15
+ For some reason, when OpenAIProvider/AsyncOpenAI is initialised without the http_client directly provided, and it's used with Langfuse observer decorator,
16
+ we are getting false error messages.
17
+
18
+ Unfortunatelly, Langfuse doesn't seem eager to fix this, so this is a workaround. See https://github.com/langfuse/langfuse/issues/5622.
19
+
20
+ Use this function as a helper function to create bug-free OpenAIProvider.
21
+ """
22
+ return OpenAIProvider(
23
+ openai_client=AsyncOpenAI(
24
+ api_key=api_key.get_secret_value(),
25
+ base_url=base_url,
26
+ http_client=DefaultAsyncHttpxClient(
27
+ timeout=DEFAULT_TIMEOUT,
28
+ base_url=base_url,
29
+ ),
30
+ )
31
+ )
@@ -0,0 +1,188 @@
1
+ import asyncio
2
+ import os
3
+ import typing as t
4
+
5
+ import streamlit
6
+ import streamlit as st
7
+
8
+ from prediction_market_agent_tooling.config import APIKeys
9
+ from prediction_market_agent_tooling.loggers import logger
10
+ from prediction_market_agent_tooling.tools.caches.db_cache import DB_CACHE_LOG_PREFIX
11
+
12
+ if t.TYPE_CHECKING:
13
+ from loguru import Message
14
+
15
+ STREAMLIT_SINK_EXPLICIT_FLAG = "streamlit"
16
+
17
+
18
+ def streamlit_asyncio_event_loop_hack() -> None:
19
+ """
20
+ This function is a hack to make Streamlit work with asyncio event loop.
21
+ See https://github.com/streamlit/streamlit/issues/744
22
+ """
23
+
24
+ def get_or_create_eventloop() -> asyncio.AbstractEventLoop:
25
+ try:
26
+ return asyncio.get_event_loop()
27
+ except RuntimeError as ex:
28
+ if "There is no current event loop in thread" in str(ex):
29
+ loop = asyncio.new_event_loop()
30
+ asyncio.set_event_loop(loop)
31
+ return asyncio.get_event_loop()
32
+ else:
33
+ raise ex
34
+
35
+ loop = get_or_create_eventloop()
36
+ asyncio.set_event_loop(loop)
37
+
38
+
39
+ def check_required_api_keys(keys: APIKeys, required_keys: list[str]) -> None:
40
+ has_missing_keys = False
41
+ for key in required_keys:
42
+ if not getattr(keys, key):
43
+ st.error(f"Environment variable for key {key} has not been set.")
44
+ has_missing_keys = True
45
+ if has_missing_keys:
46
+ st.stop()
47
+
48
+
49
+ def get_loguru_streamlit_sink(
50
+ explicit: bool,
51
+ expander_if_longer_than: int | None,
52
+ include_in_expander: int = 50,
53
+ ) -> t.Callable[["Message"], None]:
54
+ def loguru_streamlit_sink(log: "Message") -> None:
55
+ record = log.record
56
+ level = record["level"].name
57
+
58
+ message = streamlit_escape(record["message"])
59
+
60
+ # Ignore certain messages that aren't interesting for Streamlit user, but are in the production logs.
61
+ if any(x in message for x in [DB_CACHE_LOG_PREFIX]):
62
+ return
63
+
64
+ if explicit and not record["extra"].get(STREAMLIT_SINK_EXPLICIT_FLAG, False):
65
+ return
66
+
67
+ if level == "ERROR":
68
+ st_func = st.error
69
+ st_icon = "❌"
70
+
71
+ elif level == "WARNING":
72
+ st_func = st.warning
73
+ st_icon = "⚠️"
74
+
75
+ elif level == "SUCCESS":
76
+ st_func = st.success
77
+ st_icon = "✅"
78
+
79
+ elif level == "DEBUG":
80
+ st_func = None
81
+ st_icon = None
82
+
83
+ else:
84
+ st_func = st.info
85
+ st_icon = "ℹ️"
86
+
87
+ if st_func is None:
88
+ pass
89
+
90
+ elif (
91
+ expander_if_longer_than is not None
92
+ and len(message) > expander_if_longer_than
93
+ ):
94
+ with st.expander(
95
+ f"[Expand to see more] {message[:include_in_expander]}..."
96
+ ):
97
+ st_func(message, icon=st_icon)
98
+
99
+ else:
100
+ st_func(message, icon=st_icon)
101
+
102
+ return loguru_streamlit_sink
103
+
104
+
105
+ @st.cache_resource
106
+ def add_sink_to_logger(
107
+ explicit: bool = False, expander_if_longer_than: int | None = 500
108
+ ) -> None:
109
+ """
110
+ Adds streamlit as a sink to the loguru, so any loguru logs will be shown in the streamlit app.
111
+
112
+ Needs to be behind a cache decorator, so it only runs once per streamlit session (otherwise we would see duplicated messages).
113
+
114
+ If `explicit` is set to True, only logged messages with extra attribute `streamlit` will be shown in the streamlit app.
115
+ """
116
+ logger.add(
117
+ get_loguru_streamlit_sink(
118
+ explicit=explicit, expander_if_longer_than=expander_if_longer_than
119
+ )
120
+ )
121
+
122
+
123
+ def streamlit_escape(message: str) -> str:
124
+ """
125
+ Escapes the string for streamlit writes.
126
+ """
127
+ # Replace escaped newlines with actual newlines.
128
+ message = message.replace("\\n", "\n")
129
+ # Fix malformed dollar signs in the messages.
130
+ message = message.replace("$", "\$")
131
+
132
+ return message
133
+
134
+
135
+ def dict_to_point_list(d: dict[str, t.Any], indent: int = 0) -> str:
136
+ """
137
+ Helper method to convert nested dicts to a bullet point list.
138
+ """
139
+ lines = []
140
+ prefix = " " * indent
141
+ for k, v in d.items():
142
+ if isinstance(v, dict):
143
+ lines.append(f"{prefix}- {k}:")
144
+ lines.append(dict_to_point_list(v, indent + 1))
145
+ elif isinstance(v, list):
146
+ lines.append(f"{prefix}- {k}:")
147
+ for idx, item in enumerate(v):
148
+ if isinstance(item, dict):
149
+ lines.append(f"{prefix} - item {idx}:")
150
+ lines.append(dict_to_point_list(item, indent + 2))
151
+ else:
152
+ lines.append(f"{prefix} - item {idx}: {item}")
153
+ else:
154
+ lines.append(f"{prefix}- {k}: {v}")
155
+ return "\n".join(lines)
156
+
157
+
158
+ def customize_index_html(head_content: str) -> None:
159
+ """
160
+ Unfortunatelly, Streamlit doesn't allow to update HTML content of the main index.html file, any component that allows passing of HTML will render it in iframe.
161
+ That's unusable for analytics tools like Posthog.
162
+
163
+ This is workaround that patches their index.html file directly in their package, found in https://stackoverflow.com/questions/70520191/how-to-add-the-google-analytics-tag-to-website-developed-with-streamlit/78992559#78992559.
164
+
165
+ There is also an issue that tracks this feature (open since 2023): https://github.com/streamlit/streamlit/issues/6140
166
+ """
167
+ streamlit_package_dir = os.path.dirname(streamlit.__file__)
168
+ index_path = os.path.join(streamlit_package_dir, "static", "index.html")
169
+
170
+ with open(index_path, "r") as f:
171
+ index_html = f.read()
172
+
173
+ if head_content not in index_html:
174
+ # Add the custom content to the head
175
+ index_html = index_html.replace("</head>", f"{head_content}</head>")
176
+
177
+ # Replace the <title> tag
178
+ index_html = index_html.replace(
179
+ "<title>Streamlit</title>", "<title>Savantly is cool</title>"
180
+ )
181
+
182
+ with open(index_path, "w") as f:
183
+ f.write(index_html)
184
+
185
+ logger.info("index.html injected with custom code.")
186
+
187
+ else:
188
+ logger.info("index.html injection skipped because it's already present.")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "prediction-market-agent-tooling"
3
- version = "0.69.5.dev1084"
3
+ version = "0.69.6"
4
4
  description = "Tools to benchmark, deploy and monitor prediction market agents."
5
5
  authors = ["Gnosis"]
6
6
  readme = "README.md"