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

Function run_llm_math_chain_factory

configs/parallelqa_react/tools.py:7–25  ·  view source on GitHub ↗
(llm_math_chain)

Source from the content-addressed store, hash-verified

5
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
27
28web_searcher = ReActWikipedia()

Callers 1

generate_toolsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected