@shenghuabi/llama 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -59
- package/index.js.map +3 -3
- package/index.mjs +3 -58
- package/index.mjs.map +3 -3
- package/llama-swap.service.d.ts +0 -1
- package/package.json +1 -1
- package/token.d.ts +0 -1
- package/download/auto-check-vendor.d.ts +0 -4
- package/download/get-ollama-gguf-file.d.ts +0 -7
package/index.js
CHANGED
|
@@ -39,7 +39,6 @@ __export(llama_exports, {
|
|
|
39
39
|
LlamaServerDefine: () => LlamaServerDefine,
|
|
40
40
|
LlamaServerSwapItemDefine: () => LlamaServerSwapItemDefine,
|
|
41
41
|
LlamaSwapService: () => LlamaSwapService,
|
|
42
|
-
OLLAMA_MODEL_URL_TOKEN: () => OLLAMA_MODEL_URL_TOKEN,
|
|
43
42
|
SamplingDefine: () => SamplingDefine
|
|
44
43
|
});
|
|
45
44
|
module.exports = __toCommonJS(llama_exports);
|
|
@@ -54,9 +53,6 @@ var import_static_injector = require("static-injector");
|
|
|
54
53
|
var LLamaConfigToken = new import_static_injector.InjectionToken(
|
|
55
54
|
"LLamaConfig"
|
|
56
55
|
);
|
|
57
|
-
var OLLAMA_MODEL_URL_TOKEN = new import_static_injector.InjectionToken(
|
|
58
|
-
"OLLAMA_MODEL_URL"
|
|
59
|
-
);
|
|
60
56
|
|
|
61
57
|
// packages/llama/llama-swap.service.ts
|
|
62
58
|
var v7 = __toESM(require("valibot"), 1);
|
|
@@ -2648,45 +2644,7 @@ async function readDir2(dir, level) {
|
|
|
2648
2644
|
|
|
2649
2645
|
// packages/llama/llama-swap.service.ts
|
|
2650
2646
|
var import_path2 = require("path");
|
|
2651
|
-
|
|
2652
|
-
// packages/llama/download/get-ollama-gguf-file.ts
|
|
2653
|
-
function getDownloadFileName(name) {
|
|
2654
|
-
return name;
|
|
2655
|
-
}
|
|
2656
|
-
async function getOllamaGgufFile(name, options) {
|
|
2657
|
-
name = name.includes("/") ? name : `library/${name}`;
|
|
2658
|
-
const resultUrl = parseName(name);
|
|
2659
|
-
const endpoint = resultUrl.endpoint ?? `https://${options.endpoint}/`;
|
|
2660
|
-
const hff = `${resultUrl.namespace}/${resultUrl.repo}`;
|
|
2661
|
-
const result = await getModelManifest(name, {
|
|
2662
|
-
...options,
|
|
2663
|
-
endpoint
|
|
2664
|
-
});
|
|
2665
|
-
const rfilename = result.layers.find(
|
|
2666
|
-
(item) => item.mediaType === `application/vnd.ollama.image.model`
|
|
2667
|
-
).digest;
|
|
2668
|
-
const result2 = getDownloadFileName(rfilename);
|
|
2669
|
-
const fileList = [`${endpoint}v2/${hff}/blobs/${result2}`];
|
|
2670
|
-
return {
|
|
2671
|
-
fileList,
|
|
2672
|
-
fileName: `ollama-${name}`.replace(/\/|:/g, "-")
|
|
2673
|
-
};
|
|
2674
|
-
}
|
|
2675
|
-
|
|
2676
|
-
// packages/llama/llama-swap.service.ts
|
|
2677
2647
|
var import_es_toolkit = require("es-toolkit");
|
|
2678
|
-
|
|
2679
|
-
// packages/llama/download/auto-check-vendor.ts
|
|
2680
|
-
async function autoCheckVendor(repo, options) {
|
|
2681
|
-
try {
|
|
2682
|
-
await getModelManifest(repo, options);
|
|
2683
|
-
return void 0;
|
|
2684
|
-
} catch (error) {
|
|
2685
|
-
}
|
|
2686
|
-
return "ollama";
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
// packages/llama/llama-swap.service.ts
|
|
2690
2648
|
var SysMap2 = { win32: "win", linux: "ubuntu" };
|
|
2691
2649
|
var LlamaPlatform2 = SysMap2[process.platform];
|
|
2692
2650
|
var remoteArgs = ["hf-repo", "hf-file", "model-url"];
|
|
@@ -2705,7 +2663,6 @@ var LlamaSwapService = class extends import_external_call.ExternalCallBaseServic
|
|
|
2705
2663
|
return fullPath;
|
|
2706
2664
|
});
|
|
2707
2665
|
llamaSwapDir$$ = (0, import_static_injector2.computed)(() => import_vfs2.path.join(this.#config().dir, "llama-swap"));
|
|
2708
|
-
#ollamaModelUrl$$ = (0, import_static_injector2.inject)(OLLAMA_MODEL_URL_TOKEN);
|
|
2709
2666
|
#hgModelUrl$$ = (0, import_static_injector2.inject)(import_external_call.HUGGINGFACE_URL_TOKEN);
|
|
2710
2667
|
#downloadConfig$$ = (0, import_static_injector2.inject)(import_external_call.DownloadConfigToken);
|
|
2711
2668
|
#hgtoken$$ = (0, import_static_injector2.inject)(import_external_call.HUGGINGFACE_TOKEN_TOKEN);
|
|
@@ -2926,18 +2883,11 @@ var LlamaSwapService = class extends import_external_call.ExternalCallBaseServic
|
|
|
2926
2883
|
let directory;
|
|
2927
2884
|
const dir = import_vfs2.path.join(this.#config().dir, "models");
|
|
2928
2885
|
if (modelOptions.repo) {
|
|
2929
|
-
|
|
2930
|
-
this.log?.info("使用厂商:", modelOptions.vendor);
|
|
2931
|
-
}
|
|
2932
|
-
const resolveResult = await (modelOptions.vendor === "ollama" ? getOllamaGgufFile(modelOptions.repo, {
|
|
2933
|
-
...modelOptions,
|
|
2934
|
-
endpoint: this.#ollamaModelUrl$$(),
|
|
2935
|
-
token: modelOptions.token || this.#hgtoken$$()
|
|
2936
|
-
}) : getGgufFile(modelOptions.repo, {
|
|
2886
|
+
const resolveResult = await getGgufFile(modelOptions.repo, {
|
|
2937
2887
|
...modelOptions,
|
|
2938
2888
|
endpoint: this.#hgModelUrl$$(),
|
|
2939
2889
|
token: modelOptions.token || this.#hgtoken$$()
|
|
2940
|
-
})
|
|
2890
|
+
});
|
|
2941
2891
|
this.log?.info("模型文件:", resolveResult);
|
|
2942
2892
|
const filePath = import_vfs2.path.join(dir, resolveResult.fileName);
|
|
2943
2893
|
if (fs2.existsSync(filePath)) {
|
|
@@ -2991,14 +2941,9 @@ var LlamaSwapService = class extends import_external_call.ExternalCallBaseServic
|
|
|
2991
2941
|
);
|
|
2992
2942
|
}
|
|
2993
2943
|
async createModelConfig(model, options) {
|
|
2994
|
-
const vendor = await autoCheckVendor(model, {
|
|
2995
|
-
endpoint: `https://${this.#hgModelUrl$$()}/`,
|
|
2996
|
-
token: this.#hgtoken$$()
|
|
2997
|
-
});
|
|
2998
2944
|
const downloadFilePath = await this.downloadModel(
|
|
2999
2945
|
{
|
|
3000
|
-
repo: model
|
|
3001
|
-
vendor
|
|
2946
|
+
repo: model
|
|
3002
2947
|
},
|
|
3003
2948
|
options
|
|
3004
2949
|
);
|
|
@@ -3071,7 +3016,6 @@ var LlamaSwapService = class extends import_external_call.ExternalCallBaseServic
|
|
|
3071
3016
|
LlamaServerDefine,
|
|
3072
3017
|
LlamaServerSwapItemDefine,
|
|
3073
3018
|
LlamaSwapService,
|
|
3074
|
-
OLLAMA_MODEL_URL_TOKEN,
|
|
3075
3019
|
SamplingDefine
|
|
3076
3020
|
});
|
|
3077
3021
|
//# sourceMappingURL=index.js.map
|