MCPcopy
hub / github.com/SqueezeAILab/LLMCompiler / run_llm_math_chain

Function run_llm_math_chain

configs/parallelqa_react/tools.py:8–23  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

6
7def run_llm_math_chain_factory(llm_math_chain):
8 def run_llm_math_chain(args):
9 # since llm math chain returns the answer with a prefix, we need to remove it
10 try:
11 response = llm_math_chain.run(args)
12 try:
13 r = response.split("Answer:")[-1]
14 r = r.strip()
15 r = float(r)
16 # round to 3 decimal places
17 r = round(r, 3)
18 response = "Answer: " + str(r)
19 except:
20 pass
21 except:
22 response = "Error: Invalid expression. Try with a different expression."
23 return response
24
25 return run_llm_math_chain
26

Callers

nothing calls this directly

Calls 1

runMethod · 0.80

Tested by

no test coverage detected