(pack_data: PackResponse)
| 81 | |
| 82 | |
| 83 | def 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 | |
| 104 | def format_packs_to_openai_functions(packs: list["Pack"]) -> list[dict[str, Any]]: |
no test coverage detected