diff --git a/prediction_market_agent/agents/known_outcome_agent/deploy.py b/prediction_market_agent/agents/known_outcome_agent/deploy.py index bbc0992e..6c6e2775 100644 --- a/prediction_market_agent/agents/known_outcome_agent/deploy.py +++ b/prediction_market_agent/agents/known_outcome_agent/deploy.py @@ -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: diff --git a/prediction_market_agent/agents/known_outcome_agent/known_outcome_agent.py b/prediction_market_agent/agents/known_outcome_agent/known_outcome_agent.py index e933e31b..1c86f68d 100644 --- a/prediction_market_agent/agents/known_outcome_agent/known_outcome_agent.py +++ b/prediction_market_agent/agents/known_outcome_agent/known_outcome_agent.py @@ -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.")