Skip to content

Commit d0fb1db

Browse files
committed
fixing some bugginess with tool inclusion, gonna need to refactor it so that check_llm_command is based on NPCTeam instead of npc_compiler.
1 parent 28ecb5d commit d0fb1db

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

npcsh/llm_funcs.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -829,14 +829,29 @@ def check_llm_command(
829829
830830
Available tools:
831831
"""
832-
print(npc.tools_dict, type(npc.tools_dict))
833-
if npc.tools_dict is None or npc.tools_dict == {}:
832+
833+
if (npc.tools_dict is None or npc.tools_dict == {}) & (
834+
npc.all_tools_dict is None or npc.all_tools_dict == {}
835+
):
834836
prompt += "No tools available. Do not invoke tools."
835837
else:
836-
for tool_name, tool in npc.tools_dict.items():
838+
tools_set = {}
839+
840+
if npc.tools_dict is not None:
841+
for tool_name, tool in npc.tools_dict.items():
842+
if tool_name not in tools_set:
843+
tools_set[tool_name] = tool.description
844+
if npc.all_tools_dict is not None:
845+
for tool_name, tool in npc.all_tools_dict.items():
846+
if tool_name not in tools_set:
847+
tools_set[tool_name] = tool.description
848+
849+
for tool_name, tool_description in tools_set.items():
837850
prompt += f"""
838-
{tool_name} : {tool.description} \n
839-
"""
851+
852+
{tool_name} : {tool_description} \n
853+
"""
854+
840855
prompt += f"""
841856
Available NPCs for alternative answers:
842857
@@ -1101,9 +1116,9 @@ def check_llm_command(
11011116
elif action == "execute_sequence":
11021117
tool_names = response_content_parsed.get("tool_name")
11031118
npc_names = response_content_parsed.get("npc_name")
1104-
print(npc_names)
1119+
# print(npc_names)
11051120
npcs = []
1106-
print(tool_names, npc_names)
1121+
# print(tool_names, npc_names)
11071122
if isinstance(npc_names, list):
11081123
for npc_name in npc_names:
11091124
for npc_obj in npc.resolved_npcs:
@@ -1192,9 +1207,8 @@ def handle_tool_call(
11921207
"""
11931208
# print(npc)
11941209
print("handling tool call")
1195-
if not npc or (not npc.all_tools_dict and not npc.tools_dict):
1196-
print("not available")
1197-
available_tools = npc.all_tools_dict if npc else None
1210+
if not npc:
1211+
11981212
print(
11991213
f"No tools available for NPC '{npc.name}' or tools_dict is empty. Available tools: {available_tools}"
12001214
)

0 commit comments

Comments
 (0)