From 592f0928959938c5eeb7b5b0a2fc8db00b983e07 Mon Sep 17 00:00:00 2001 From: Mengsheng Wu Date: Tue, 14 Oct 2025 11:00:15 +0800 Subject: [PATCH 1/2] feat(local-apps): Add nexa-sdk snippet for model inference and installation instructions --- packages/tasks/src/local-apps.spec.ts | 15 +++++++++ packages/tasks/src/local-apps.ts | 48 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/packages/tasks/src/local-apps.spec.ts b/packages/tasks/src/local-apps.spec.ts index 534efbbc88..3a059a966d 100644 --- a/packages/tasks/src/local-apps.spec.ts +++ b/packages/tasks/src/local-apps.spec.ts @@ -125,4 +125,19 @@ curl -X POST "http://localhost:8000/v1/chat/completions" \\ expect(snippet).toEqual(`docker model run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:{{QUANT_TAG}}`); }); + + it("nexa-sdk", async () => { + const { snippet: snippetFunc } = LOCAL_APPS["nexa-sdk"]; + const model: ModelData = { + id: "NexaAI/OmniNeural-4B", + tags: [], + inference: "", + }; + const snippet = snippetFunc(model); + + expect(snippet.length).toBe(8); + expect(snippet[0].content).toBe( + `nexa infer NexaAI/OmniNeural-4B --prompt "NexaAI embraces HuggingFace and open source."` + ); + }); }); diff --git a/packages/tasks/src/local-apps.ts b/packages/tasks/src/local-apps.ts index 7f9aeb6c43..e6152aa38e 100644 --- a/packages/tasks/src/local-apps.ts +++ b/packages/tasks/src/local-apps.ts @@ -361,6 +361,42 @@ const snippetLemonade = (model: ModelData, filepath?: string): LocalAppSnippet[] ]; }; +const snippetNexaSdk = (model: ModelData): LocalAppSnippet[] => { + const command = `nexa infer ${model.id} --prompt "NexaAI embraces HuggingFace and open source."`; + const releaseUrl = "https://github.com/NexaAI/nexa-sdk/releases/latest"; + + const downloadSetup = (filename: string) => `# Download installer from:\n# ${releaseUrl}/download/${filename}`; + const curlSetup = (arch: string) => + `curl -fsSL ${releaseUrl}/download/nexa-cli_linux_${arch}.sh -o install.sh && chmod +x install.sh && ./install.sh && rm install.sh`; + + const platformConfigs = [ + { title: "Install on Windows (x86_64)", filename: "nexa-cli_windows_x86_64.exe" }, + { title: "Install on Windows (x86_64 CUDA)", filename: "nexa-cli_windows_x86_64_cuda.exe" }, + { title: "Install on Windows (arm64)", filename: "nexa-cli_windows_arm64.exe" }, + { title: "Install on macOS (arm64)", filename: "nexa-cli_macos_arm64.pkg" }, + { title: "Install on macOS (x86_64)", filename: "nexa-cli_macos_x86_64.pkg" }, + ]; + + const platforms: LocalAppSnippet[] = [ + ...platformConfigs.map(({ title, filename }) => ({ title, setup: downloadSetup(filename), content: command })), + { title: "Install on Linux (x86_64)", setup: curlSetup("x86_64"), content: command }, + { title: "Install on Linux (arm64)", setup: curlSetup("arm64"), content: command }, + ]; + + return [ + ...platforms, + { + title: "OpenAI-compatible Server Mode", + content: [ + "# Start OpenAI-compatible server:", + "nexa serve --host 127.0.0.1:8080", + "", + "# Open the Swagger UI at: http://localhost:8080/docs/ui", + ].join("\n"), + }, + ]; +}; + /** * Add your new local app here. * @@ -545,6 +581,18 @@ export const LOCAL_APPS = { displayOnModelPage: (model) => isLlamaCppGgufModel(model) || isAmdRyzenModel(model), snippet: snippetLemonade, }, + "nexa-sdk": { + prettyLabel: "Nexa SDK", + docsUrl: "https://docs.nexa.ai/", + mainTask: "text-generation", + displayOnModelPage: (model) => + (model.id.startsWith("NexaAI/") || isLlamaCppGgufModel(model) || isMlxModel(model) || isAmdRyzenModel(model)) && + (model.pipeline_tag === "text-generation" || + model.pipeline_tag === "text-to-speech" || + model.pipeline_tag === "automatic-speech-recognition" || + model.pipeline_tag === "text-to-image"), + snippet: snippetNexaSdk, + }, } satisfies Record; export type LocalAppKey = keyof typeof LOCAL_APPS; From 13e8da25fa8f7980c7b272bf20022684c4c94b3b Mon Sep 17 00:00:00 2001 From: Mengsheng Wu Date: Tue, 14 Oct 2025 15:31:10 +0800 Subject: [PATCH 2/2] refactor(local-apps): Simplify nexa-sdk snippet and enhance model display logic --- packages/tasks/src/local-apps.ts | 61 +++++++++++--------------------- 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/packages/tasks/src/local-apps.ts b/packages/tasks/src/local-apps.ts index e6152aa38e..fffdf8eb29 100644 --- a/packages/tasks/src/local-apps.ts +++ b/packages/tasks/src/local-apps.ts @@ -361,40 +361,8 @@ const snippetLemonade = (model: ModelData, filepath?: string): LocalAppSnippet[] ]; }; -const snippetNexaSdk = (model: ModelData): LocalAppSnippet[] => { - const command = `nexa infer ${model.id} --prompt "NexaAI embraces HuggingFace and open source."`; - const releaseUrl = "https://github.com/NexaAI/nexa-sdk/releases/latest"; - - const downloadSetup = (filename: string) => `# Download installer from:\n# ${releaseUrl}/download/${filename}`; - const curlSetup = (arch: string) => - `curl -fsSL ${releaseUrl}/download/nexa-cli_linux_${arch}.sh -o install.sh && chmod +x install.sh && ./install.sh && rm install.sh`; - - const platformConfigs = [ - { title: "Install on Windows (x86_64)", filename: "nexa-cli_windows_x86_64.exe" }, - { title: "Install on Windows (x86_64 CUDA)", filename: "nexa-cli_windows_x86_64_cuda.exe" }, - { title: "Install on Windows (arm64)", filename: "nexa-cli_windows_arm64.exe" }, - { title: "Install on macOS (arm64)", filename: "nexa-cli_macos_arm64.pkg" }, - { title: "Install on macOS (x86_64)", filename: "nexa-cli_macos_x86_64.pkg" }, - ]; - - const platforms: LocalAppSnippet[] = [ - ...platformConfigs.map(({ title, filename }) => ({ title, setup: downloadSetup(filename), content: command })), - { title: "Install on Linux (x86_64)", setup: curlSetup("x86_64"), content: command }, - { title: "Install on Linux (arm64)", setup: curlSetup("arm64"), content: command }, - ]; - - return [ - ...platforms, - { - title: "OpenAI-compatible Server Mode", - content: [ - "# Start OpenAI-compatible server:", - "nexa serve --host 127.0.0.1:8080", - "", - "# Open the Swagger UI at: http://localhost:8080/docs/ui", - ].join("\n"), - }, - ]; +const snippetNexaSdk = (model: ModelData): string => { + return `nexa infer ${model.id}`; }; /** @@ -585,12 +553,25 @@ export const LOCAL_APPS = { prettyLabel: "Nexa SDK", docsUrl: "https://docs.nexa.ai/", mainTask: "text-generation", - displayOnModelPage: (model) => - (model.id.startsWith("NexaAI/") || isLlamaCppGgufModel(model) || isMlxModel(model) || isAmdRyzenModel(model)) && - (model.pipeline_tag === "text-generation" || - model.pipeline_tag === "text-to-speech" || - model.pipeline_tag === "automatic-speech-recognition" || - model.pipeline_tag === "text-to-image"), + displayOnModelPage: (model) => { + const supportedPipelineTags = new Set([ + "text-generation", + "text-to-speech", + "automatic-speech-recognition", + "image-text-to-text", + "audio-text-to-text", + "text-ranking", + "text-to-image", + "image-classification", + "object-detection", + ]); + return ( + model.id.startsWith("NexaAI/") || + ((isLlamaCppGgufModel(model) || isMlxModel(model) || isAmdRyzenModel(model)) && + model.pipeline_tag !== undefined && + supportedPipelineTags.has(model.pipeline_tag)) + ); + }, snippet: snippetNexaSdk, }, } satisfies Record;