MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/optillm / select_best_answer

Method select_best_answer

optillm/rstar.py:231–248  ·  view source on GitHub ↗
(self, answers: List[Tuple[str, float]])

Source from the content-addressed store, hash-verified

229 return last_node.value / last_node.visits
230
231 def select_best_answer(self, answers: List[Tuple[str, float]]) -> str:
232 valid_answers = [(answer, conf) for answer, conf in answers if answer]
233 if not valid_answers:
234 return "Unable to determine a valid answer."
235
236 # Sort by confidence and then by frequency
237 answer_counts = {}
238 for answer, conf in valid_answers:
239 if answer in answer_counts:
240 answer_counts[answer] = (answer_counts[answer][0] + 1, max(answer_counts[answer][1], conf))
241 else:
242 answer_counts[answer] = (1, conf)
243
244 sorted_answers = sorted(answer_counts.items(), key=lambda x: (-x[1][1], -x[1][0]))
245 best_answer, (count, conf) = sorted_answers[0]
246
247 logger.debug(f"Selected best answer: {best_answer} (count: {count}, confidence: {conf})")
248 return best_answer
249
250 def create_prompt(self, state: str, action: str) -> str:
251 question = self.original_question if hasattr(self, 'original_question') else "the original question"

Callers 1

solve_asyncMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected