MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / shouldSend

Method shouldSend

AskAgent/python/core/ranking.py:306–325  ·  view source on GitHub ↗
(self, result)

Source from the content-addressed store, hash-verified

304 logger.debug("=== end scores ===")
305
306 def shouldSend(self, result):
307 # Get max_results from handler, or use default
308 max_results = getattr(self.handler, 'max_results', self.NUM_RESULTS_TO_SEND)
309
310 # Don't send if we've already reached the limit
311 if self.num_results_sent >= max_results:
312 return False
313
314 should_send = False
315 # Allow sending if we're still well below the limit
316 if (self.num_results_sent < max_results - 3):
317 should_send = True
318 else:
319 # Near the limit - only send if this result is better than something we already sent
320 for r in self.rankedAnswers:
321 if r["sent"] and r["ranking"]["score"] < result["ranking"]["score"]:
322 should_send = True
323 break
324
325 return should_send
326
327 async def sendAnswers(self, answers, force=False):
328 if not self.handler.connection_alive_event.is_set():

Callers 2

sendAnswersMethod · 0.95
send_answersMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected