@juspay/neurolink 1.6.0 → 1.10.0
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/CHANGELOG.md +200 -7
- package/README.md +101 -18
- package/dist/agent/direct-tools.d.ts +1203 -0
- package/dist/agent/direct-tools.js +387 -0
- package/dist/cli/commands/agent-generate.d.ts +2 -0
- package/dist/cli/commands/agent-generate.js +70 -0
- package/dist/cli/commands/config.d.ts +6 -6
- package/dist/cli/commands/config.js +326 -273
- package/dist/cli/commands/mcp.d.ts +2 -1
- package/dist/cli/commands/mcp.js +874 -146
- package/dist/cli/commands/ollama.d.ts +1 -1
- package/dist/cli/commands/ollama.js +153 -143
- package/dist/cli/index.js +687 -325
- package/dist/cli/utils/complete-setup.d.ts +19 -0
- package/dist/cli/utils/complete-setup.js +81 -0
- package/dist/cli/utils/env-manager.d.ts +44 -0
- package/dist/cli/utils/env-manager.js +226 -0
- package/dist/cli/utils/interactive-setup.d.ts +48 -0
- package/dist/cli/utils/interactive-setup.js +302 -0
- package/dist/core/dynamic-models.d.ts +208 -0
- package/dist/core/dynamic-models.js +250 -0
- package/dist/core/factory.d.ts +13 -6
- package/dist/core/factory.js +177 -62
- package/dist/core/types.d.ts +4 -2
- package/dist/core/types.js +4 -4
- package/dist/index.d.ts +16 -16
- package/dist/index.js +16 -16
- package/dist/lib/agent/direct-tools.d.ts +1203 -0
- package/dist/lib/agent/direct-tools.js +387 -0
- package/dist/lib/core/dynamic-models.d.ts +208 -0
- package/dist/lib/core/dynamic-models.js +250 -0
- package/dist/lib/core/factory.d.ts +13 -6
- package/dist/lib/core/factory.js +177 -62
- package/dist/lib/core/types.d.ts +4 -2
- package/dist/lib/core/types.js +4 -4
- package/dist/lib/index.d.ts +16 -16
- package/dist/lib/index.js +16 -16
- package/dist/lib/mcp/auto-discovery.d.ts +120 -0
- package/dist/lib/mcp/auto-discovery.js +793 -0
- package/dist/lib/mcp/client.d.ts +66 -0
- package/dist/lib/mcp/client.js +245 -0
- package/dist/lib/mcp/config.d.ts +31 -0
- package/dist/lib/mcp/config.js +74 -0
- package/dist/lib/mcp/context-manager.d.ts +4 -4
- package/dist/lib/mcp/context-manager.js +24 -18
- package/dist/lib/mcp/factory.d.ts +28 -11
- package/dist/lib/mcp/factory.js +36 -29
- package/dist/lib/mcp/function-calling.d.ts +51 -0
- package/dist/lib/mcp/function-calling.js +510 -0
- package/dist/lib/mcp/index.d.ts +190 -0
- package/dist/lib/mcp/index.js +156 -0
- package/dist/lib/mcp/initialize-tools.d.ts +28 -0
- package/dist/lib/mcp/initialize-tools.js +209 -0
- package/dist/lib/mcp/initialize.d.ts +17 -0
- package/dist/lib/mcp/initialize.js +51 -0
- package/dist/lib/mcp/logging.d.ts +71 -0
- package/dist/lib/mcp/logging.js +183 -0
- package/dist/lib/mcp/manager.d.ts +67 -0
- package/dist/lib/mcp/manager.js +176 -0
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +96 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +417 -0
- package/dist/lib/mcp/orchestrator.d.ts +3 -3
- package/dist/lib/mcp/orchestrator.js +46 -43
- package/dist/lib/mcp/registry.d.ts +12 -4
- package/dist/lib/mcp/registry.js +64 -37
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +142 -102
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
- package/dist/lib/mcp/servers/utilities/utility-server.d.ts +8 -0
- package/dist/lib/mcp/servers/utilities/utility-server.js +326 -0
- package/dist/lib/mcp/tool-integration.d.ts +67 -0
- package/dist/lib/mcp/tool-integration.js +179 -0
- package/dist/lib/mcp/unified-registry.d.ts +269 -0
- package/dist/lib/mcp/unified-registry.js +1411 -0
- package/dist/lib/neurolink.d.ts +68 -6
- package/dist/lib/neurolink.js +304 -42
- package/dist/lib/providers/agent-enhanced-provider.d.ts +59 -0
- package/dist/lib/providers/agent-enhanced-provider.js +242 -0
- package/dist/lib/providers/amazonBedrock.d.ts +3 -3
- package/dist/lib/providers/amazonBedrock.js +54 -50
- package/dist/lib/providers/anthropic.d.ts +2 -2
- package/dist/lib/providers/anthropic.js +92 -84
- package/dist/lib/providers/azureOpenAI.d.ts +2 -2
- package/dist/lib/providers/azureOpenAI.js +97 -86
- package/dist/lib/providers/function-calling-provider.d.ts +70 -0
- package/dist/lib/providers/function-calling-provider.js +359 -0
- package/dist/lib/providers/googleAIStudio.d.ts +10 -5
- package/dist/lib/providers/googleAIStudio.js +60 -38
- package/dist/lib/providers/googleVertexAI.d.ts +3 -3
- package/dist/lib/providers/googleVertexAI.js +96 -86
- package/dist/lib/providers/huggingFace.d.ts +3 -3
- package/dist/lib/providers/huggingFace.js +70 -63
- package/dist/lib/providers/index.d.ts +11 -11
- package/dist/lib/providers/index.js +18 -18
- package/dist/lib/providers/mcp-provider.d.ts +62 -0
- package/dist/lib/providers/mcp-provider.js +183 -0
- package/dist/lib/providers/mistralAI.d.ts +3 -3
- package/dist/lib/providers/mistralAI.js +42 -36
- package/dist/lib/providers/ollama.d.ts +4 -4
- package/dist/lib/providers/ollama.js +128 -98
- package/dist/lib/providers/openAI.d.ts +7 -3
- package/dist/lib/providers/openAI.js +45 -33
- package/dist/lib/utils/logger.js +2 -2
- package/dist/lib/utils/providerUtils-fixed.d.ts +8 -0
- package/dist/lib/utils/providerUtils-fixed.js +75 -0
- package/dist/lib/utils/providerUtils.d.ts +8 -1
- package/dist/lib/utils/providerUtils.js +63 -32
- package/dist/mcp/auto-discovery.d.ts +120 -0
- package/dist/mcp/auto-discovery.js +794 -0
- package/dist/mcp/client.d.ts +66 -0
- package/dist/mcp/client.js +245 -0
- package/dist/mcp/config.d.ts +31 -0
- package/dist/mcp/config.js +74 -0
- package/dist/mcp/context-manager.d.ts +4 -4
- package/dist/mcp/context-manager.js +24 -18
- package/dist/mcp/factory.d.ts +28 -11
- package/dist/mcp/factory.js +36 -29
- package/dist/mcp/function-calling.d.ts +51 -0
- package/dist/mcp/function-calling.js +510 -0
- package/dist/mcp/index.d.ts +190 -0
- package/dist/mcp/index.js +156 -0
- package/dist/mcp/initialize-tools.d.ts +28 -0
- package/dist/mcp/initialize-tools.js +210 -0
- package/dist/mcp/initialize.d.ts +17 -0
- package/dist/mcp/initialize.js +51 -0
- package/dist/mcp/logging.d.ts +71 -0
- package/dist/mcp/logging.js +183 -0
- package/dist/mcp/manager.d.ts +67 -0
- package/dist/mcp/manager.js +176 -0
- package/dist/mcp/neurolink-mcp-client.d.ts +96 -0
- package/dist/mcp/neurolink-mcp-client.js +417 -0
- package/dist/mcp/orchestrator.d.ts +3 -3
- package/dist/mcp/orchestrator.js +46 -43
- package/dist/mcp/registry.d.ts +12 -4
- package/dist/mcp/registry.js +64 -37
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
- package/dist/mcp/servers/ai-providers/ai-core-server.js +142 -102
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
- package/dist/mcp/servers/utilities/utility-server.d.ts +8 -0
- package/dist/mcp/servers/utilities/utility-server.js +326 -0
- package/dist/mcp/tool-integration.d.ts +67 -0
- package/dist/mcp/tool-integration.js +179 -0
- package/dist/mcp/unified-registry.d.ts +269 -0
- package/dist/mcp/unified-registry.js +1411 -0
- package/dist/neurolink.d.ts +68 -6
- package/dist/neurolink.js +304 -42
- package/dist/providers/agent-enhanced-provider.d.ts +59 -0
- package/dist/providers/agent-enhanced-provider.js +242 -0
- package/dist/providers/amazonBedrock.d.ts +3 -3
- package/dist/providers/amazonBedrock.js +54 -50
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +92 -84
- package/dist/providers/azureOpenAI.d.ts +2 -2
- package/dist/providers/azureOpenAI.js +97 -86
- package/dist/providers/function-calling-provider.d.ts +70 -0
- package/dist/providers/function-calling-provider.js +359 -0
- package/dist/providers/googleAIStudio.d.ts +10 -5
- package/dist/providers/googleAIStudio.js +60 -38
- package/dist/providers/googleVertexAI.d.ts +3 -3
- package/dist/providers/googleVertexAI.js +96 -86
- package/dist/providers/huggingFace.d.ts +3 -3
- package/dist/providers/huggingFace.js +70 -63
- package/dist/providers/index.d.ts +11 -11
- package/dist/providers/index.js +18 -18
- package/dist/providers/mcp-provider.d.ts +62 -0
- package/dist/providers/mcp-provider.js +183 -0
- package/dist/providers/mistralAI.d.ts +3 -3
- package/dist/providers/mistralAI.js +42 -36
- package/dist/providers/ollama.d.ts +4 -4
- package/dist/providers/ollama.js +128 -98
- package/dist/providers/openAI.d.ts +7 -3
- package/dist/providers/openAI.js +45 -33
- package/dist/utils/logger.js +2 -2
- package/dist/utils/providerUtils-fixed.d.ts +8 -0
- package/dist/utils/providerUtils-fixed.js +75 -0
- package/dist/utils/providerUtils.d.ts +8 -1
- package/dist/utils/providerUtils.js +63 -32
- package/package.json +182 -160
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { execSync } from
|
|
2
|
-
import chalk from
|
|
3
|
-
import ora from
|
|
4
|
-
import inquirer from
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
5
|
export const ollamaCommand = {
|
|
6
|
-
command:
|
|
7
|
-
describe:
|
|
6
|
+
command: "ollama <command>",
|
|
7
|
+
describe: "Manage Ollama local AI models",
|
|
8
8
|
builder: (yargs) => {
|
|
9
9
|
return yargs
|
|
10
|
-
.command(
|
|
11
|
-
.command(
|
|
10
|
+
.command("list-models", "List installed Ollama models", {}, listModelsHandler)
|
|
11
|
+
.command("pull <model>", "Download an Ollama model", {
|
|
12
12
|
model: {
|
|
13
|
-
describe:
|
|
14
|
-
type:
|
|
15
|
-
demandOption: true
|
|
16
|
-
}
|
|
13
|
+
describe: "Model name to download",
|
|
14
|
+
type: "string",
|
|
15
|
+
demandOption: true,
|
|
16
|
+
},
|
|
17
17
|
}, pullModelHandler)
|
|
18
|
-
.command(
|
|
18
|
+
.command("remove <model>", "Remove an Ollama model", {
|
|
19
19
|
model: {
|
|
20
|
-
describe:
|
|
21
|
-
type:
|
|
22
|
-
demandOption: true
|
|
23
|
-
}
|
|
20
|
+
describe: "Model name to remove",
|
|
21
|
+
type: "string",
|
|
22
|
+
demandOption: true,
|
|
23
|
+
},
|
|
24
24
|
}, removeModelHandler)
|
|
25
|
-
.command(
|
|
26
|
-
.command(
|
|
27
|
-
.command(
|
|
28
|
-
.command(
|
|
29
|
-
.demandCommand(1,
|
|
25
|
+
.command("status", "Check Ollama service status", {}, statusHandler)
|
|
26
|
+
.command("start", "Start Ollama service", {}, startHandler)
|
|
27
|
+
.command("stop", "Stop Ollama service", {}, stopHandler)
|
|
28
|
+
.command("setup", "Interactive Ollama setup", {}, setupHandler)
|
|
29
|
+
.demandCommand(1, "Please specify a command");
|
|
30
30
|
},
|
|
31
|
-
handler: () => { } // No-op handler as subcommands handle everything
|
|
31
|
+
handler: () => { }, // No-op handler as subcommands handle everything
|
|
32
32
|
};
|
|
33
33
|
async function listModelsHandler() {
|
|
34
|
-
const spinner = ora(
|
|
34
|
+
const spinner = ora("Fetching installed models...").start();
|
|
35
35
|
try {
|
|
36
|
-
const output = execSync(
|
|
37
|
-
spinner.succeed(
|
|
36
|
+
const output = execSync("ollama list", { encoding: "utf8" });
|
|
37
|
+
spinner.succeed("Installed models:");
|
|
38
38
|
if (output.trim()) {
|
|
39
39
|
console.log(output);
|
|
40
40
|
}
|
|
@@ -43,24 +43,24 @@ async function listModelsHandler() {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
spinner.fail(
|
|
47
|
-
console.error(chalk.red(
|
|
48
|
-
console.log(chalk.blue(
|
|
46
|
+
spinner.fail("Failed to list models. Is Ollama installed?");
|
|
47
|
+
console.error(chalk.red("Error:", error.message));
|
|
48
|
+
console.log(chalk.blue("\nTip: Install Ollama from https://ollama.ai"));
|
|
49
49
|
process.exit(1);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
async function pullModelHandler(argv) {
|
|
53
53
|
const { model } = argv;
|
|
54
54
|
console.log(chalk.blue(`Downloading model: ${model}`));
|
|
55
|
-
console.log(chalk.gray(
|
|
55
|
+
console.log(chalk.gray("This may take several minutes..."));
|
|
56
56
|
try {
|
|
57
|
-
execSync(`ollama pull ${model}`, { stdio:
|
|
57
|
+
execSync(`ollama pull ${model}`, { stdio: "inherit" });
|
|
58
58
|
console.log(chalk.green(`\n✅ Successfully downloaded ${model}`));
|
|
59
59
|
console.log(chalk.blue(`\nTest it with: npx @juspay/neurolink generate-text "Hello!" --provider ollama --model ${model}`));
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
62
|
console.error(chalk.red(`\n❌ Failed to download ${model}`));
|
|
63
|
-
console.error(chalk.red(
|
|
63
|
+
console.error(chalk.red("Error:", error.message));
|
|
64
64
|
process.exit(1);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -69,36 +69,38 @@ async function removeModelHandler(argv) {
|
|
|
69
69
|
// Confirm removal
|
|
70
70
|
const { confirm } = await inquirer.prompt([
|
|
71
71
|
{
|
|
72
|
-
type:
|
|
73
|
-
name:
|
|
72
|
+
type: "confirm",
|
|
73
|
+
name: "confirm",
|
|
74
74
|
message: `Are you sure you want to remove model "${model}"?`,
|
|
75
|
-
default: false
|
|
76
|
-
}
|
|
75
|
+
default: false,
|
|
76
|
+
},
|
|
77
77
|
]);
|
|
78
78
|
if (!confirm) {
|
|
79
|
-
console.log(chalk.yellow(
|
|
79
|
+
console.log(chalk.yellow("Removal cancelled."));
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
const spinner = ora(`Removing model ${model}...`).start();
|
|
83
83
|
try {
|
|
84
|
-
execSync(`ollama rm ${model}`, { encoding:
|
|
84
|
+
execSync(`ollama rm ${model}`, { encoding: "utf8" });
|
|
85
85
|
spinner.succeed(`Successfully removed ${model}`);
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
88
|
spinner.fail(`Failed to remove ${model}`);
|
|
89
|
-
console.error(chalk.red(
|
|
89
|
+
console.error(chalk.red("Error:", error.message));
|
|
90
90
|
process.exit(1);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
async function statusHandler() {
|
|
94
|
-
const spinner = ora(
|
|
94
|
+
const spinner = ora("Checking Ollama service status...").start();
|
|
95
95
|
try {
|
|
96
96
|
// Try to run a simple command
|
|
97
|
-
execSync(
|
|
98
|
-
spinner.succeed(
|
|
97
|
+
execSync("ollama list", { encoding: "utf8" });
|
|
98
|
+
spinner.succeed("Ollama service is running");
|
|
99
99
|
// Get additional info
|
|
100
100
|
try {
|
|
101
|
-
const response = execSync(
|
|
101
|
+
const response = execSync("curl -s http://localhost:11434/api/tags", {
|
|
102
|
+
encoding: "utf8",
|
|
103
|
+
});
|
|
102
104
|
const data = JSON.parse(response);
|
|
103
105
|
if (data.models && data.models.length > 0) {
|
|
104
106
|
console.log(chalk.green(`\n${data.models.length} models available`));
|
|
@@ -109,156 +111,156 @@ async function statusHandler() {
|
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
catch (error) {
|
|
112
|
-
spinner.fail(
|
|
113
|
-
console.log(chalk.yellow(
|
|
114
|
-
console.log(chalk.blue(
|
|
114
|
+
spinner.fail("Ollama service is not running");
|
|
115
|
+
console.log(chalk.yellow("\nStart Ollama with: ollama serve"));
|
|
116
|
+
console.log(chalk.blue("Or restart the Ollama app if using the desktop version"));
|
|
115
117
|
process.exit(1);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
async function startHandler() {
|
|
119
|
-
console.log(chalk.blue(
|
|
121
|
+
console.log(chalk.blue("Starting Ollama service..."));
|
|
120
122
|
try {
|
|
121
123
|
// Check if already running
|
|
122
124
|
try {
|
|
123
|
-
execSync(
|
|
124
|
-
console.log(chalk.yellow(
|
|
125
|
+
execSync("ollama list", { encoding: "utf8" });
|
|
126
|
+
console.log(chalk.yellow("Ollama service is already running!"));
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
129
|
catch {
|
|
128
130
|
// Not running, continue to start
|
|
129
131
|
}
|
|
130
132
|
// Different approaches for different platforms
|
|
131
|
-
if (process.platform ===
|
|
133
|
+
if (process.platform === "darwin") {
|
|
132
134
|
// macOS
|
|
133
|
-
console.log(chalk.gray(
|
|
135
|
+
console.log(chalk.gray("Starting Ollama on macOS..."));
|
|
134
136
|
try {
|
|
135
|
-
execSync(
|
|
136
|
-
console.log(chalk.green(
|
|
137
|
+
execSync("open -a Ollama");
|
|
138
|
+
console.log(chalk.green("✅ Ollama app started"));
|
|
137
139
|
}
|
|
138
140
|
catch {
|
|
139
141
|
// Try service command
|
|
140
|
-
execSync(
|
|
141
|
-
console.log(chalk.green(
|
|
142
|
+
execSync("ollama serve > /dev/null 2>&1 &", { stdio: "ignore" });
|
|
143
|
+
console.log(chalk.green("✅ Ollama service started"));
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
|
-
else if (process.platform ===
|
|
146
|
+
else if (process.platform === "linux") {
|
|
145
147
|
// Linux
|
|
146
|
-
console.log(chalk.gray(
|
|
148
|
+
console.log(chalk.gray("Starting Ollama service on Linux..."));
|
|
147
149
|
try {
|
|
148
|
-
execSync(
|
|
149
|
-
console.log(chalk.green(
|
|
150
|
+
execSync("systemctl start ollama", { encoding: "utf8" });
|
|
151
|
+
console.log(chalk.green("✅ Ollama service started"));
|
|
150
152
|
}
|
|
151
153
|
catch {
|
|
152
154
|
// Try direct command
|
|
153
|
-
execSync(
|
|
154
|
-
console.log(chalk.green(
|
|
155
|
+
execSync("ollama serve > /dev/null 2>&1 &", { stdio: "ignore" });
|
|
156
|
+
console.log(chalk.green("✅ Ollama service started"));
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
else {
|
|
158
160
|
// Windows
|
|
159
|
-
console.log(chalk.gray(
|
|
160
|
-
execSync(
|
|
161
|
-
console.log(chalk.green(
|
|
161
|
+
console.log(chalk.gray("Starting Ollama on Windows..."));
|
|
162
|
+
execSync("start ollama serve", { stdio: "ignore" });
|
|
163
|
+
console.log(chalk.green("✅ Ollama service started"));
|
|
162
164
|
}
|
|
163
|
-
console.log(chalk.blue(
|
|
165
|
+
console.log(chalk.blue("\nWait a few seconds for the service to initialize..."));
|
|
164
166
|
}
|
|
165
167
|
catch (error) {
|
|
166
|
-
console.error(chalk.red(
|
|
167
|
-
console.error(chalk.red(
|
|
168
|
-
console.log(chalk.blue(
|
|
168
|
+
console.error(chalk.red("Failed to start Ollama service"));
|
|
169
|
+
console.error(chalk.red("Error:", error.message));
|
|
170
|
+
console.log(chalk.blue("\nTry starting Ollama manually or check installation"));
|
|
169
171
|
process.exit(1);
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
async function stopHandler() {
|
|
173
|
-
const spinner = ora(
|
|
175
|
+
const spinner = ora("Stopping Ollama service...").start();
|
|
174
176
|
try {
|
|
175
|
-
if (process.platform ===
|
|
177
|
+
if (process.platform === "darwin") {
|
|
176
178
|
// macOS
|
|
177
179
|
try {
|
|
178
|
-
execSync(
|
|
180
|
+
execSync("pkill ollama", { encoding: "utf8" });
|
|
179
181
|
}
|
|
180
182
|
catch {
|
|
181
|
-
execSync(
|
|
183
|
+
execSync("killall Ollama", { encoding: "utf8" });
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
else if (process.platform ===
|
|
186
|
+
else if (process.platform === "linux") {
|
|
185
187
|
// Linux
|
|
186
188
|
try {
|
|
187
|
-
execSync(
|
|
189
|
+
execSync("systemctl stop ollama", { encoding: "utf8" });
|
|
188
190
|
}
|
|
189
191
|
catch {
|
|
190
|
-
execSync(
|
|
192
|
+
execSync("pkill ollama", { encoding: "utf8" });
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
else {
|
|
194
196
|
// Windows
|
|
195
|
-
execSync(
|
|
197
|
+
execSync("taskkill /F /IM ollama.exe", { encoding: "utf8" });
|
|
196
198
|
}
|
|
197
|
-
spinner.succeed(
|
|
199
|
+
spinner.succeed("Ollama service stopped");
|
|
198
200
|
}
|
|
199
201
|
catch (error) {
|
|
200
|
-
spinner.fail(
|
|
201
|
-
console.error(chalk.red(
|
|
202
|
+
spinner.fail("Failed to stop Ollama service");
|
|
203
|
+
console.error(chalk.red("It may not be running or requires manual stop"));
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
async function setupHandler() {
|
|
205
|
-
console.log(chalk.blue(
|
|
207
|
+
console.log(chalk.blue("🦙 Welcome to Ollama Setup!\n"));
|
|
206
208
|
// Check if Ollama is installed
|
|
207
|
-
const checkSpinner = ora(
|
|
209
|
+
const checkSpinner = ora("Checking Ollama installation...").start();
|
|
208
210
|
let isInstalled = false;
|
|
209
211
|
try {
|
|
210
|
-
execSync(
|
|
212
|
+
execSync("ollama --version", { encoding: "utf8" });
|
|
211
213
|
isInstalled = true;
|
|
212
|
-
checkSpinner.succeed(
|
|
214
|
+
checkSpinner.succeed("Ollama is installed");
|
|
213
215
|
}
|
|
214
216
|
catch {
|
|
215
|
-
checkSpinner.fail(
|
|
217
|
+
checkSpinner.fail("Ollama is not installed");
|
|
216
218
|
}
|
|
217
219
|
if (!isInstalled) {
|
|
218
|
-
console.log(chalk.yellow(
|
|
219
|
-
console.log(chalk.blue(
|
|
220
|
-
if (process.platform ===
|
|
221
|
-
console.log(
|
|
222
|
-
console.log(chalk.gray(
|
|
223
|
-
console.log(chalk.gray(
|
|
220
|
+
console.log(chalk.yellow("\nOllama needs to be installed first."));
|
|
221
|
+
console.log(chalk.blue("\nInstallation instructions:"));
|
|
222
|
+
if (process.platform === "darwin") {
|
|
223
|
+
console.log("\nFor macOS:");
|
|
224
|
+
console.log(chalk.gray(" brew install ollama"));
|
|
225
|
+
console.log(chalk.gray(" # or download from https://ollama.ai"));
|
|
224
226
|
}
|
|
225
|
-
else if (process.platform ===
|
|
226
|
-
console.log(
|
|
227
|
-
console.log(chalk.gray(
|
|
227
|
+
else if (process.platform === "linux") {
|
|
228
|
+
console.log("\nFor Linux:");
|
|
229
|
+
console.log(chalk.gray(" curl -fsSL https://ollama.ai/install.sh | sh"));
|
|
228
230
|
}
|
|
229
231
|
else {
|
|
230
|
-
console.log(
|
|
231
|
-
console.log(chalk.gray(
|
|
232
|
+
console.log("\nFor Windows:");
|
|
233
|
+
console.log(chalk.gray(" Download from https://ollama.ai"));
|
|
232
234
|
}
|
|
233
235
|
const { proceedAnyway } = await inquirer.prompt([
|
|
234
236
|
{
|
|
235
|
-
type:
|
|
236
|
-
name:
|
|
237
|
-
message:
|
|
238
|
-
default: false
|
|
239
|
-
}
|
|
237
|
+
type: "confirm",
|
|
238
|
+
name: "proceedAnyway",
|
|
239
|
+
message: "Would you like to continue with setup anyway?",
|
|
240
|
+
default: false,
|
|
241
|
+
},
|
|
240
242
|
]);
|
|
241
243
|
if (!proceedAnyway) {
|
|
242
|
-
console.log(chalk.blue(
|
|
244
|
+
console.log(chalk.blue("\nInstall Ollama and run setup again!"));
|
|
243
245
|
return;
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
// Check if service is running
|
|
247
249
|
let serviceRunning = false;
|
|
248
250
|
try {
|
|
249
|
-
execSync(
|
|
251
|
+
execSync("ollama list", { encoding: "utf8" });
|
|
250
252
|
serviceRunning = true;
|
|
251
|
-
console.log(chalk.green(
|
|
253
|
+
console.log(chalk.green("\n✅ Ollama service is running"));
|
|
252
254
|
}
|
|
253
255
|
catch {
|
|
254
|
-
console.log(chalk.yellow(
|
|
256
|
+
console.log(chalk.yellow("\n⚠️ Ollama service is not running"));
|
|
255
257
|
const { startService } = await inquirer.prompt([
|
|
256
258
|
{
|
|
257
|
-
type:
|
|
258
|
-
name:
|
|
259
|
-
message:
|
|
260
|
-
default: true
|
|
261
|
-
}
|
|
259
|
+
type: "confirm",
|
|
260
|
+
name: "startService",
|
|
261
|
+
message: "Would you like to start the Ollama service?",
|
|
262
|
+
default: true,
|
|
263
|
+
},
|
|
262
264
|
]);
|
|
263
265
|
if (startService) {
|
|
264
266
|
await startHandler();
|
|
@@ -267,45 +269,51 @@ async function setupHandler() {
|
|
|
267
269
|
}
|
|
268
270
|
if (serviceRunning) {
|
|
269
271
|
// List available models
|
|
270
|
-
console.log(chalk.blue(
|
|
271
|
-
console.log(
|
|
272
|
-
console.log(
|
|
273
|
-
console.log(
|
|
274
|
-
console.log(
|
|
275
|
-
console.log(
|
|
272
|
+
console.log(chalk.blue("\n📦 Popular Ollama models:"));
|
|
273
|
+
console.log(" • llama2 (7B) - General purpose");
|
|
274
|
+
console.log(" • codellama (7B) - Code generation");
|
|
275
|
+
console.log(" • mistral (7B) - Fast and efficient");
|
|
276
|
+
console.log(" • tinyllama (1B) - Lightweight");
|
|
277
|
+
console.log(" • phi (2.7B) - Microsoft's compact model");
|
|
276
278
|
const { downloadModel } = await inquirer.prompt([
|
|
277
279
|
{
|
|
278
|
-
type:
|
|
279
|
-
name:
|
|
280
|
-
message:
|
|
281
|
-
default: true
|
|
282
|
-
}
|
|
280
|
+
type: "confirm",
|
|
281
|
+
name: "downloadModel",
|
|
282
|
+
message: "Would you like to download a model?",
|
|
283
|
+
default: true,
|
|
284
|
+
},
|
|
283
285
|
]);
|
|
284
286
|
if (downloadModel) {
|
|
285
287
|
const { selectedModel } = await inquirer.prompt([
|
|
286
288
|
{
|
|
287
|
-
type:
|
|
288
|
-
name:
|
|
289
|
-
message:
|
|
289
|
+
type: "list",
|
|
290
|
+
name: "selectedModel",
|
|
291
|
+
message: "Select a model to download:",
|
|
290
292
|
choices: [
|
|
291
|
-
{
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
{
|
|
294
|
+
name: "llama2 (7B) - Recommended for general use",
|
|
295
|
+
value: "llama2",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "codellama (7B) - Best for code generation",
|
|
299
|
+
value: "codellama",
|
|
300
|
+
},
|
|
301
|
+
{ name: "mistral (7B) - Fast and efficient", value: "mistral" },
|
|
302
|
+
{ name: "tinyllama (1B) - Lightweight, fast", value: "tinyllama" },
|
|
303
|
+
{ name: "phi (2.7B) - Microsoft's compact model", value: "phi" },
|
|
304
|
+
{ name: "Other (enter manually)", value: "other" },
|
|
305
|
+
],
|
|
306
|
+
},
|
|
299
307
|
]);
|
|
300
308
|
let modelToDownload = selectedModel;
|
|
301
|
-
if (selectedModel ===
|
|
309
|
+
if (selectedModel === "other") {
|
|
302
310
|
const { customModel } = await inquirer.prompt([
|
|
303
311
|
{
|
|
304
|
-
type:
|
|
305
|
-
name:
|
|
306
|
-
message:
|
|
307
|
-
validate: (input) => input.trim().length > 0 ||
|
|
308
|
-
}
|
|
312
|
+
type: "input",
|
|
313
|
+
name: "customModel",
|
|
314
|
+
message: "Enter the model name:",
|
|
315
|
+
validate: (input) => input.trim().length > 0 || "Model name is required",
|
|
316
|
+
},
|
|
309
317
|
]);
|
|
310
318
|
modelToDownload = customModel;
|
|
311
319
|
}
|
|
@@ -313,11 +321,13 @@ async function setupHandler() {
|
|
|
313
321
|
}
|
|
314
322
|
}
|
|
315
323
|
// Final instructions
|
|
316
|
-
console.log(chalk.green(
|
|
317
|
-
console.log(chalk.blue(
|
|
318
|
-
console.log(
|
|
319
|
-
console.log(
|
|
320
|
-
|
|
321
|
-
console.log(
|
|
324
|
+
console.log(chalk.green("\n✅ Setup complete!\n"));
|
|
325
|
+
console.log(chalk.blue("Next steps:"));
|
|
326
|
+
console.log("1. List models: " + chalk.gray("neurolink ollama list-models"));
|
|
327
|
+
console.log("2. Generate text: " +
|
|
328
|
+
chalk.gray('neurolink generate-text "Hello!" --provider ollama'));
|
|
329
|
+
console.log("3. Use specific model: " +
|
|
330
|
+
chalk.gray('neurolink generate-text "Hello!" --provider ollama --model codellama'));
|
|
331
|
+
console.log(chalk.gray("\nFor more information, see: https://docs.neurolink.ai/providers/ollama"));
|
|
322
332
|
}
|
|
323
333
|
export default ollamaCommand;
|