refined tool use

This commit is contained in:
2025-01-04 13:31:16 +01:00
parent 7d60d9bd00
commit 8c00a6c326
6 changed files with 46 additions and 37 deletions

View File

@@ -58,8 +58,21 @@ def solve_multi_equation(equations, variables):
# solutionpairs = [f"{variable}={value.doit()}" for variable, value in zip(variables, list(solution)[0])]
return "solved equation system for " + ", ".join(solutionpairs[:-1]) + " and " + solutionpairs[-1]
# return "solved equation system for " + ", ".join(solutionpairs[:-1]) + " and " + solutionpairs[-1]
if len(equations) > 1:
leadin = "Solved equation system "
else:
leadin = "Solved equation "
return leadin + _natural_join([_pretty_equation(e) for e in equations]) + " for " + _natural_join(solutionpairs) + "."
def _natural_join(data: list[any], joiner=", ", last=" and "):
if len(data) > 1:
return joiner.join(data[:-1]) + last + data[-1]
return last.join(data)
def _pretty_equation(simpy_Eq) -> str:
return f"{simpy_Eq.lhs} = {simpy_Eq.rhs}"