Skip to content

Commit e0824a7

Browse files
committed
sometimes it was generating the tool call inputs but they themselves were empty -.- but added a check for that in the error handling in handle_tool_call
1 parent 88347b7 commit e0824a7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

npcsh/llm_funcs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,14 +1051,14 @@ def handle_tool_call(
10511051
for inp in required_inputs:
10521052
if not isinstance(inp, dict):
10531053
# dicts contain the keywords so its fine if theyre missing from the inputs.
1054-
if inp not in input_values:
1054+
if inp not in input_values or input_values[inp] == "":
10551055
missing_inputs.append(inp)
10561056
if len(missing_inputs) > 0:
10571057
# print(f"Missing required inputs for tool '{tool_name}': {missing_inputs}")
10581058
if attempt < n_attempts:
10591059
print(f"attempt {attempt+1} to generate inputs failed, trying again")
10601060
print("missing inputs", missing_inputs)
1061-
print("llm response", response)
1061+
#print("llm response", response)
10621062
print("input values", input_values)
10631063
return handle_tool_call(
10641064
command,
@@ -1080,6 +1080,7 @@ def handle_tool_call(
10801080
}
10811081

10821082
# try:
1083+
print("Executing tool with input values:", input_values)
10831084
tool_output = tool.execute(
10841085
input_values,
10851086
npc.all_tools_dict,

npcsh/npc_compiler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ def execute_step(
222222
context["results"] = exec_env["output"]
223223
except NameError as e:
224224
print(f"NameError: {e} , on the following tool code: ", rendered_code)
225+
except SyntaxError as e:
226+
print(f"SyntaxError: {e} , on the following tool code: ", rendered_code)
227+
except Exception as e:
228+
print(f"Error executing Python code: {e}")
229+
225230
return context
226231

227232
def to_dict(self):

0 commit comments

Comments
 (0)