MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / auto_reduce_n

Method auto_reduce_n

bmtools/tools/database/utils/llm.py:279–286  ·  view source on GitHub ↗

Reduces n by half until the function succeeds.

(self, fn, prompt, n)

Source from the content-addressed store, hash-verified

277 raise Exception("Aborted.")
278
279 def auto_reduce_n(self, fn, prompt, n):
280 """Reduces n by half until the function succeeds."""
281 try:
282 return fn(prompt, n)
283 except BatchSizeException as e:
284 if n == 1:
285 raise e
286 return self.auto_reduce_n(fn, prompt, n // 2) + self.auto_reduce_n(fn, prompt, n // 2)
287
288 def generate_text(self, prompt, n):
289 if not isinstance(prompt, list):

Callers 1

generate_textMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected