feat: Export getLlamaForOptions#465
Conversation
Add getLlamaForOptions to the list of exported functions
|
@Thomas101 To check which GPU types are supported by the current machine at runtime you can use the Here's how you can achieve the same result in a more stable manner using the public APIs: import {getLlamaGpuTypes, getLlama, LlamaLogLevel} from "node-llama-cpp";
async function getWorkingGpuTypes() {
const gpuTypes = await getLlamaGpuTypes("supported");
const testResults = await Promise.all(
gpuTypes.map(async (gpuType) => {
try {
await getLlama({
gpu: gpuType,
build: "never",
logLevel: LlamaLogLevel.disabled,
// this will only load the binary and avoid loading the llama.cpp backend.
// to also validate loading the llama.cpp backend,
// omit this option and then call `.dispose()` on the returned `Llama` instance afterwards
dryRun: true
});
return gpuType;
} catch (err) {
return null;
}
})
);
return testResults.filter((gpuType) => gpuType != null);
}Let me know if this solves your issue, or you still need something not possible with the above solution. |
|
Thanks, that's a much better way to do it. I don't think the |
This was added to accomodate testing for gpu support, but is no longer needed as we have getLlamaGpuTypes See withcatai#465
Add getLlamaForOptions to the list of exported functions
Description of change
This PR exports
getLllamaForOptionsfrom the main import. We've been using this in Aibrow to hard check for GPU engine support at runtime. For example...Pull-Request Checklist
masterbranchnpm run formatto apply eslint formattingnpm run testpasses with this changeFixes #0000N/A