Skip to content

Commit

Permalink
Bump PMAT version to 0.9.3, simplify calculate_bet_amount for Known…
Browse files Browse the repository at this point in the history
…OutcomeAgent (#51)

* Bump PMAT version to 0.9.3, simplify

* Update poetry.lock

* Skip markets with small liquidity
  • Loading branch information
evangriffiths authored Apr 8, 2024
1 parent 82c8142 commit ee7a7a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 12 additions & 14 deletions prediction_market_agent/agents/known_outcome_agent/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
from prediction_market_agent_tooling.deploy.constants import OWNER_KEY
from prediction_market_agent_tooling.gtypes import SecretStr, private_key_type
from prediction_market_agent_tooling.markets.agent_market import AgentMarket
from prediction_market_agent_tooling.markets.data_models import BetAmount, Currency
from prediction_market_agent_tooling.markets.data_models import BetAmount
from prediction_market_agent_tooling.markets.markets import MarketType
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
from prediction_market_agent_tooling.tools.utils import (
check_not_none,
get_current_git_commit_sha,
get_current_git_url,
should_not_happen,
)

from prediction_market_agent.agents.known_outcome_agent.known_outcome_agent import (
Expand All @@ -28,14 +27,19 @@ def market_is_saturated(market: AgentMarket) -> bool:


class DeployableKnownOutcomeAgent(DeployableAgent):
model = "gpt-4-1106-preview"
model = "gpt-4-turbo-preview"

def load(self) -> None:
self.markets_with_known_outcomes: dict[str, Result] = {}

def pick_markets(self, markets: list[AgentMarket]) -> list[AgentMarket]:
picked_markets: list[AgentMarket] = []
for market in markets:
if not isinstance(market, OmenAgentMarket):
raise NotImplementedError(
"This agent only supports predictions on Omen markets"
)

print(f"Looking at market {market.id=} {market.question=}")

# Assume very high probability markets are already known, and have
Expand All @@ -45,6 +49,10 @@ def pick_markets(self, markets: list[AgentMarket]) -> list[AgentMarket]:
print(
f"Skipping market {market.id=} {market.question=}, because it is already saturated."
)
elif market.get_liquidity_in_xdai() < 5:
print(
f"Skipping market {market.id=} {market.question=}, because it has insufficient liquidity."
)
else:
picked_markets.append(market)

Expand Down Expand Up @@ -83,17 +91,7 @@ def answer_binary_market(self, market: AgentMarket) -> bool | None:

def calculate_bet_amount(self, answer: bool, market: AgentMarket) -> BetAmount:
if isinstance(market, OmenAgentMarket):
if market.currency != Currency.xDai:
should_not_happen()
return BetAmount(
# On markets without liquidity, bet just a small amount for benchmarking.
amount=(
Decimal(1.0)
if market.get_liquidity_in_xdai() > 5
else market.get_tiny_bet_amount().amount
),
currency=Currency.xDai,
)
return BetAmount(amount=(Decimal(1.0)), currency=market.currency)
else:
raise NotImplementedError("This agent only supports xDai markets")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def get_known_outcome(model: str, question: str, max_tries: int) -> Answer:
).format_messages(date_str=date_str, question=question)
print(f"Invoking LLM for {search_prompt=}")
search_query = str(llm.invoke(search_prompt).content).strip('"')
print(f"Searchig for {search_query=}")
print(f"Searching for {search_query=}")
search_results = web_search(query=search_query, max_results=5)
if not search_results:
raise ValueError("No search results found.")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ poetry = "^1.7.1"
poetry-plugin-export = "^1.6.0"
functions-framework = "^3.5.0"
cron-validator = "^1.0.8"
prediction-market-agent-tooling = "^0.9.1"
prediction-market-agent-tooling = "^0.9.3"
pydantic-settings = "^2.1.0"
autoflake = "^2.2.1"
isort = "^5.13.2"
Expand Down

0 comments on commit ee7a7a6

Please sign in to comment.