MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / find_object

Function find_object

eval_heldout/science-world/eval_utils.py:344–358  ·  view source on GitHub ↗
(action, objects_string)

Source from the content-addressed store, hash-verified

342
343
344def find_object(action, objects_string):
345 # Find the index of the target object in the words list
346 target_object = ' '.join(action.split()[2:])
347 if target_object not in objects_string:
348 return action
349 target_object_index = objects_string.index(target_object)
350
351 # Check if the target object is inside a container
352 if objects_string[target_object_index - 8:target_object_index - 1] == "called ":
353 container_start_index = objects_string.rfind("(", 0, target_object_index) - 1
354 container_end_index = objects_string.rfind(")", 0, target_object_index) + 1
355 container = objects_string[container_start_index:container_end_index]
356 action = action.replace(target_object, f"{container}")
357
358 return action
359
360
361def clean_obj_name(action):

Callers 1

try_to_replaceFunction · 0.85

Calls 2

joinMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected