Skip to content

Commit

Permalink
Debug prints & bet only on one market hotfix (#36)
Browse files Browse the repository at this point in the history
* More prints to debug known outcome agent

* Skip failed predictions in known outcome agent and bet only on 1 market (#38)
  • Loading branch information
kongzii authored Apr 2, 2024
1 parent 2a7a8b9 commit c02be15
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 26 additions & 5 deletions prediction_market_agent/agents/known_outcome_agent/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,41 @@ def pick_markets(self, markets: list[AgentMarket]) -> list[AgentMarket]:
# Assume very high probability markets are already known, and have
# been correctly bet on, and therefore the value of betting on them
# is low.
print(f"Looking at market {market.id=} {market.question=}")
if not market_is_saturated(
market=market
) and has_question_event_happened_in_the_past(
model=self.model, question=market.question
):
answer = get_known_outcome(
model=self.model,
question=market.question,
max_tries=3,
)
print(f"Predicting market {market.id=} {market.question=}")
try:
answer = get_known_outcome(
model=self.model,
question=market.question,
max_tries=3,
)
except Exception as e:
print(
f"Error: Failed to predict market {market.id=} {market.question=}: {e}"
)
continue
if answer.has_known_outcome():
print(
f"Picking market {market.id=} {market.question=} with answer {answer.result=}"
)
picked_markets.append(market)
self.markets_with_known_outcomes[market.id] = answer.result

# Return as soon as we have picked a market, because otherwise it will take too long and we will run out of time in GCP Function (540s timeout)
# TODO: After PMAT is updated in this repository, we can return `None` in `answer_binary_market` method and PMAT won't place the bet.
# So we can move this logic out of `pick_markets` into `answer_binary_market`, and simply process as many bets as we have time for.
return picked_markets

else:
print(
f"Skipping market {market.id=} {market.question=}, because it is already saturated."
)

return picked_markets

def answer_binary_market(self, market: AgentMarket) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def get_known_outcome(model: str, question: str, max_tries: int) -> Answer:
search_prompt = ChatPromptTemplate.from_template(
template=GENERATE_SEARCH_QUERY_PROMPT
).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=}")
search_results = web_search(query=search_query, max_results=5)
if not search_results:
raise ValueError("No search results found.")
Expand Down

0 comments on commit c02be15

Please sign in to comment.