First upload version 0.0.1
This commit is contained in:
27
node_modules/node-llama-cpp/dist/gguf/utils/getGgufMetadataKeyValue.js
generated
vendored
Normal file
27
node_modules/node-llama-cpp/dist/gguf/utils/getGgufMetadataKeyValue.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export function getGgufMetadataKeyValue(metadata, key) {
|
||||
return readMedataKey(metadata, key.split("."));
|
||||
}
|
||||
function readMedataKey(metadata, keyParts) {
|
||||
for (const [metadataKey, value] of Object.entries(metadata)) {
|
||||
const matchLength = checkMatchLength(metadataKey, keyParts);
|
||||
if (matchLength === 0)
|
||||
continue;
|
||||
if (matchLength === keyParts.length)
|
||||
return value;
|
||||
const res = readMedataKey(value, keyParts.slice(matchLength));
|
||||
if (res !== undefined)
|
||||
return res;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function checkMatchLength(metadataKey, keyParts) {
|
||||
const metadataKeyParts = metadataKey.split(".");
|
||||
if (metadataKeyParts.length > keyParts.length)
|
||||
return 0;
|
||||
for (let i = 0; i < metadataKeyParts.length; i++) {
|
||||
if (metadataKeyParts[i] !== keyParts[i])
|
||||
return 0;
|
||||
}
|
||||
return metadataKeyParts.length;
|
||||
}
|
||||
//# sourceMappingURL=getGgufMetadataKeyValue.js.map
|
||||
Reference in New Issue
Block a user