@madh-io/alfred-ai 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/bundle/index.js +24 -7
  2. package/package.json +1 -1
package/bundle/index.js CHANGED
@@ -993,8 +993,17 @@ var init_ollama = __esm({
993
993
  constructor(config) {
994
994
  super(config);
995
995
  }
996
+ apiKey = "";
996
997
  async initialize() {
997
998
  this.baseUrl = this.config.baseUrl ?? "http://localhost:11434";
999
+ this.apiKey = this.config.apiKey ?? "";
1000
+ }
1001
+ getHeaders() {
1002
+ const headers = { "Content-Type": "application/json" };
1003
+ if (this.apiKey) {
1004
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
1005
+ }
1006
+ return headers;
998
1007
  }
999
1008
  async complete(request) {
1000
1009
  const messages = this.buildMessages(request.messages, request.system);
@@ -1010,7 +1019,7 @@ var init_ollama = __esm({
1010
1019
  }
1011
1020
  const res = await fetch(`${this.baseUrl}/api/chat`, {
1012
1021
  method: "POST",
1013
- headers: { "Content-Type": "application/json" },
1022
+ headers: this.getHeaders(),
1014
1023
  body: JSON.stringify(body)
1015
1024
  });
1016
1025
  if (!res.ok) {
@@ -1034,7 +1043,7 @@ var init_ollama = __esm({
1034
1043
  }
1035
1044
  const res = await fetch(`${this.baseUrl}/api/chat`, {
1036
1045
  method: "POST",
1037
- headers: { "Content-Type": "application/json" },
1046
+ headers: this.getHeaders(),
1038
1047
  body: JSON.stringify(body)
1039
1048
  });
1040
1049
  if (!res.ok) {
@@ -3497,8 +3506,15 @@ ${bold("Which LLM provider would you like to use?")}`);
3497
3506
  console.log("");
3498
3507
  apiKey = await askRequired(rl, `Enter your ${provider.name.charAt(0).toUpperCase() + provider.name.slice(1)} API key`);
3499
3508
  console.log(` ${green(">")} API key set: ${dim(maskKey(apiKey))}`);
3500
- } else {
3501
- console.log(` ${dim("No API key needed for Ollama.")}`);
3509
+ }
3510
+ let baseUrl = provider.baseUrl ?? "";
3511
+ if (provider.name === "ollama") {
3512
+ console.log("");
3513
+ baseUrl = await askWithDefault(rl, "Ollama URL (use a remote address if Ollama runs on another machine)", "http://localhost:11434");
3514
+ if (!baseUrl.endsWith("/v1")) {
3515
+ baseUrl = baseUrl.replace(/\/+$/, "") + "/v1";
3516
+ }
3517
+ console.log(` ${green(">")} Ollama URL: ${dim(baseUrl)}`);
3502
3518
  }
3503
3519
  console.log("");
3504
3520
  const model = await askWithDefault(rl, "Which model?", provider.defaultModel);
@@ -3575,13 +3591,14 @@ ${bold("Writing configuration files...")}`);
3575
3591
  `ALFRED_LLM_PROVIDER=${provider.name}`
3576
3592
  ];
3577
3593
  if (apiKey) {
3578
- envLines.push(`${provider.envKeyName}=${apiKey}`);
3594
+ const envKeyName = provider.envKeyName || "ALFRED_OLLAMA_API_KEY";
3595
+ envLines.push(`${envKeyName}=${apiKey}`);
3579
3596
  }
3580
3597
  if (model !== provider.defaultModel) {
3581
3598
  envLines.push(`ALFRED_LLM_MODEL=${model}`);
3582
3599
  }
3583
- if (provider.baseUrl) {
3584
- envLines.push(`ALFRED_LLM_BASE_URL=${provider.baseUrl}`);
3600
+ if (baseUrl) {
3601
+ envLines.push(`ALFRED_LLM_BASE_URL=${baseUrl}`);
3585
3602
  }
3586
3603
  envLines.push("", "# === Messaging Platforms ===", "");
3587
3604
  for (const [envKey, envVal] of Object.entries(envOverrides)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madh-io/alfred-ai",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Alfred — Personal AI Assistant across Telegram, Discord, WhatsApp, Matrix & Signal",
5
5
  "type": "module",
6
6
  "bin": {