MCPcopy Create free account
hub / github.com/AutoPackAI/autopack / fetch_pack_object

Function fetch_pack_object

autopack/utils.py:83–101  ·  view source on GitHub ↗
(pack_data: PackResponse)

Source from the content-addressed store, hash-verified

81
82
83def fetch_pack_object(pack_data: PackResponse) -> type["Pack"]:
84 package_path = pack_data.package_path
85 class_name = pack_data.class_name
86 try:
87 module = find_module(pack_data)
88 pack_class = getattr(module, class_name)
89 return pack_class
90 except ImportError:
91 raise AutoPackLoadError(
92 f"Could not import module '{package_path}'. The path is incorrect or module does not exist."
93 )
94 except AttributeError:
95 raise AutoPackLoadError(
96 f"Module '{package_path}' does not contain a class named '{class_name}'. The class name is incorrect."
97 )
98 except TypeError:
99 raise AutoPackLoadError(
100 f"'{class_name}' in module '{package_path}' is not a class or cannot be instantiated without arguments."
101 )
102
103
104def format_packs_to_openai_functions(packs: list["Pack"]) -> list[dict[str, Any]]:

Callers 1

get_packFunction · 0.90

Calls 2

AutoPackLoadErrorClass · 0.90
find_moduleFunction · 0.85

Tested by

no test coverage detected