try block, removed example, they confuse LLM
This commit is contained in:
@@ -4,6 +4,7 @@ from tool_helper import tool
|
||||
import math_lexer
|
||||
import math_ast
|
||||
import math_interpreter
|
||||
import utils
|
||||
|
||||
|
||||
@tool
|
||||
@@ -42,28 +43,34 @@ def math_evaluate(expression: str):
|
||||
Args:
|
||||
expression: Reduce mathematic expression (without '=') algebraically.
|
||||
"""
|
||||
|
||||
tokens = math_lexer.tokenize(expression)
|
||||
parser = math_ast.Parser()
|
||||
ast = parser.parse(tokens)
|
||||
return math_interpreter.interpret(ast)
|
||||
try:
|
||||
tokens = math_lexer.tokenize(expression)
|
||||
parser = math_ast.Parser()
|
||||
ast = parser.parse(tokens)
|
||||
return math_interpreter.interpret(ast)
|
||||
except Exception as e:
|
||||
utils.print_error("Tool call evaluation failed. - " + str(e))
|
||||
return "Tool call evaluation failed."
|
||||
|
||||
|
||||
@tool
|
||||
def math_solve(equations: list[str], variables: list[str]):
|
||||
"""evaluate a mathematical equation system and solve equation systems. Can be used to solve (x + 1)*(x - 1) = 1 for x as an example.
|
||||
"""evaluate a mathematical equation system and solve equation systems.
|
||||
Args:
|
||||
equations: list of mathematical equations containing a '='.
|
||||
variables: list of variables to solve for. Must be lower or equal the number of given equations.
|
||||
"""
|
||||
try:
|
||||
expression = "solve " + " and ".join(equations) + " for " + " and ".join(variables)
|
||||
print(expression)
|
||||
|
||||
expression = "solve " + " and ".join(equations) + " for " + " and ".join(variables)
|
||||
print(expression)
|
||||
|
||||
tokens = math_lexer.tokenize(expression)
|
||||
parser = math_ast.Parser()
|
||||
ast = parser.parse(tokens)
|
||||
return math_interpreter.interpret(ast)
|
||||
tokens = math_lexer.tokenize(expression)
|
||||
parser = math_ast.Parser()
|
||||
ast = parser.parse(tokens)
|
||||
return math_interpreter.interpret(ast)
|
||||
except Exception as e:
|
||||
utils.print_error("Tool call evaluation failed. - " + str(e))
|
||||
return "Tool call evaluation failed."
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user