Utility functions used throughout LLMWare
| 49 | |
| 50 | |
| 51 | class Utilities: |
| 52 | |
| 53 | """ Utility functions used throughout LLMWare """ |
| 54 | |
| 55 | def __init__(self, library=None): |
| 56 | self.library = library |
| 57 | |
| 58 | def get_module_pdf_parser(self): |
| 59 | |
| 60 | """ Loads shared libraries for the Parser module, based on machine architecture. """ |
| 61 | |
| 62 | # Detect machine architecture |
| 63 | if platform.system() == "Windows": |
| 64 | system = "windows" |
| 65 | file_ext = ".dll" |
| 66 | |
| 67 | if platform.machine().lower() == "arm64": |
| 68 | machine = "arm64" |
| 69 | if LLMWareConfig().get_active_db() != "sqlite": |
| 70 | logger.warning(f"Currently Windows Arm64 parser only supports SQLite. Automatically " |
| 71 | f"changing active db setting to SQLite.") |
| 72 | LLMWareConfig().set_active_db("sqlite") |
| 73 | |
| 74 | else: |
| 75 | machine = "x86_64" |
| 76 | else: |
| 77 | system = platform.system().lower() |
| 78 | machine = os.uname().machine.lower() |
| 79 | file_ext = ".so" |
| 80 | |
| 81 | # Default to known architectures if we encounter an unknown one |
| 82 | if system == 'darwin' and machine not in ['arm64', 'x86_64']: |
| 83 | machine = 'arm64' |
| 84 | if system == 'linux' and machine not in ['aarch64', 'x86_64']: |
| 85 | machine = 'x86_64' |
| 86 | |
| 87 | if system == 'linux' and machine == 'aarch64': |
| 88 | |
| 89 | """ 0.4.4 - aarch64 linux in process of being supported |
| 90 | -- re-integrating parsers on aarch64 linux |
| 91 | -- removing deprecation warnings """ |
| 92 | |
| 93 | pass |
| 94 | |
| 95 | # deprecation warning for darwin x86_64 |
| 96 | if system == "darwin" and machine == "x86_64": |
| 97 | |
| 98 | error_msg = ("Mac x86 detected as OS - this is not a supported platform. Support " |
| 99 | "was deprecated in llmware version 0.2.6 and removed in llmware version 0.3.9. " |
| 100 | "Options - move to Mac Metal (M1+), back-level llmware to supported version, or " |
| 101 | "if urgent requirement for Mac x86, please raise ticket on github.") |
| 102 | |
| 103 | raise LLMWareException(message=error_msg) |
| 104 | |
| 105 | machine_dependent_lib_path = os.path.join(LLMWareConfig.get_config("shared_lib_path"), system, machine) |
| 106 | _path_pdf = os.path.join(machine_dependent_lib_path, "llmware", "libpdf_llmware" + file_ext) |
| 107 | |
| 108 | _mod_pdf = None |
no outgoing calls