Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug prints & bet only on one market hotfix #36

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading