@jz92/ai-provider 0.2.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/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@jz92/ai-provider",
3
+ "version": "0.2.0",
4
+ "description": "Environment-aware AI provider for portfolio projects. Local dev → Ollama, deployed → any cloud provider.",
5
+ "author": "Jithin Zachariah",
6
+ "license": "MIT",
7
+ "private": false,
8
+ "type": "module",
9
+
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "modelfiles-template",
23
+ "scripts",
24
+ "README.md"
25
+ ],
26
+
27
+ "scripts": {
28
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
29
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
30
+ "type-check": "tsc --noEmit",
31
+ "test": "NODE_ENV=development npx tsx --tsconfig tsconfig.test.json test/smoke.ts",
32
+ "postinstall": "node scripts/postinstall.js",
33
+ "setup:local": "bash scripts/setup-local.sh",
34
+ "prepublishOnly": "npm run build && npm run type-check"
35
+ },
36
+
37
+ "peerDependencies": {
38
+ "ai": ">=4.0.0",
39
+ "zod": ">=3.0.0",
40
+ "@ai-sdk/anthropic": ">=1.0.0",
41
+ "@ai-sdk/openai": ">=1.0.0",
42
+ "@ai-sdk/google": ">=1.0.0",
43
+ "@ai-sdk/groq": ">=1.0.0",
44
+ "@ai-sdk/mistral": ">=1.0.0",
45
+ "ollama-ai-provider": ">=0.16.0"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "@ai-sdk/anthropic": { "optional": true },
49
+ "@ai-sdk/openai": { "optional": true },
50
+ "@ai-sdk/google": { "optional": true },
51
+ "@ai-sdk/groq": { "optional": true },
52
+ "@ai-sdk/mistral": { "optional": true },
53
+ "ollama-ai-provider": { "optional": true }
54
+ },
55
+ "devDependencies": {
56
+ "typescript": "^5.4.0",
57
+ "tsup": "^8.0.0",
58
+ "tsx": "^4.0.0",
59
+ "@types/node": "^20.0.0",
60
+ "ai": "^4.0.0",
61
+ "zod": "^3.23.0",
62
+ "@ai-sdk/anthropic": "^1.0.0",
63
+ "@ai-sdk/openai": "^1.0.0",
64
+ "@ai-sdk/google": "^1.0.0",
65
+ "@ai-sdk/groq": "^1.0.0",
66
+ "@ai-sdk/mistral": "^1.0.0",
67
+ "ollama-ai-provider": "^0.16.0"
68
+ },
69
+
70
+ "engines": { "node": ">=18.0.0" },
71
+ "keywords": ["ai", "ollama", "anthropic", "openai", "google", "groq", "mistral", "vercel-ai-sdk", "llm", "provider"]
72
+ }
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Runs after npm install — prints a clear setup guide
4
+ // so consumers know exactly which peer deps to install.
5
+
6
+ const reset = '\x1b[0m'
7
+ const bold = '\x1b[1m'
8
+ const cyan = '\x1b[36m'
9
+ const yellow = '\x1b[33m'
10
+ const green = '\x1b[32m'
11
+ const dim = '\x1b[2m'
12
+
13
+ console.log(`
14
+ ${bold}@jithin/ai-provider${reset} installed successfully.
15
+
16
+ ${yellow}Next: install the provider adapters you need.${reset}
17
+
18
+ ${bold}Local dev (Ollama — free, no API key):${reset}
19
+ ${cyan}npm install ollama-ai-provider${reset}
20
+ ${dim}Then: brew install ollama && ollama pull qwen2.5-coder:14b${reset}
21
+
22
+ ${bold}Cloud providers (install only what you use):${reset}
23
+ ${cyan}npm install @ai-sdk/anthropic${reset} ${dim}→ ANTHROPIC_API_KEY https://console.anthropic.com${reset}
24
+ ${cyan}npm install @ai-sdk/openai${reset} ${dim}→ OPENAI_API_KEY https://platform.openai.com/api-keys${reset}
25
+ ${cyan}npm install @ai-sdk/google${reset} ${dim}→ GOOGLE_GENERATIVE_AI_API_KEY https://aistudio.google.com${reset}
26
+ ${cyan}npm install @ai-sdk/groq${reset} ${dim}→ GROQ_API_KEY https://console.groq.com/keys${reset}
27
+ ${cyan}npm install @ai-sdk/mistral${reset} ${dim}→ MISTRAL_API_KEY https://console.mistral.ai${reset}
28
+
29
+ ${bold}Required in all cases:${reset}
30
+ ${cyan}npm install ai zod${reset}
31
+
32
+ ${bold}Set NODE_ENV in your .env:${reset}
33
+ ${dim}development${reset} → Ollama (free, local)
34
+ ${dim}test${reset} → cheapest cloud model (CI)
35
+ ${dim}production${reset} → best cloud model (deployed)
36
+
37
+ ${green}Docs: https://github.com/jithinjohnzachariah92/ai-provider (npm: @jz92/ai-provider)${reset}
38
+ `)
@@ -0,0 +1,73 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo ""
5
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
6
+ echo " @jithin/ai-provider — Local Setup"
7
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
8
+ echo ""
9
+
10
+ # ── Check Ollama ──────────────────────────────────────────────────────────────
11
+ if ! command -v ollama &> /dev/null; then
12
+ echo "✗ Ollama not found."
13
+ echo " Install: brew install ollama"
14
+ echo " Or: https://ollama.com/download"
15
+ exit 1
16
+ fi
17
+ echo "✓ Ollama installed"
18
+
19
+ # ── Start Ollama if not already running ──────────────────────────────────────
20
+ if ! curl -s http://localhost:11434 > /dev/null 2>&1; then
21
+ echo "→ Starting Ollama daemon..."
22
+ ollama serve > /dev/null 2>&1 &
23
+ sleep 3
24
+ fi
25
+ echo "✓ Ollama running at http://localhost:11434"
26
+
27
+ # ── Pull base model ───────────────────────────────────────────────────────────
28
+ echo ""
29
+ echo "→ Pulling qwen2.5-coder:14b (skip if already present)..."
30
+ ollama pull qwen2.5-coder:14b
31
+ echo "✓ Base model ready"
32
+
33
+ # ── Optional: pull embedding model for semantic cache ─────────────────────────
34
+ echo ""
35
+ echo "→ Pulling nomic-embed-text (used for semantic response cache)..."
36
+ ollama pull nomic-embed-text
37
+ echo "✓ Embedding model ready"
38
+
39
+ # ── Build project-specific model variants ────────────────────────────────────
40
+ # Looks for Modelfile.* in a ./modelfiles directory at the project root.
41
+ # Projects copy modelfiles-template/Modelfile.template and customise it.
42
+ MODELFILES_DIR="$(pwd)/modelfiles"
43
+
44
+ if [ -d "$MODELFILES_DIR" ]; then
45
+ echo ""
46
+ echo "→ Building project model variants from ./modelfiles/..."
47
+ for f in "$MODELFILES_DIR"/Modelfile.*; do
48
+ name="${f##*.}" # extracts the part after the last dot
49
+ echo " ollama create $name"
50
+ ollama create "$name" -f "$f"
51
+ done
52
+ echo "✓ Project variants ready"
53
+ else
54
+ echo ""
55
+ echo "ℹ No ./modelfiles directory found — skipping project variants."
56
+ echo " Copy modelfiles-template/Modelfile.template to get started."
57
+ fi
58
+
59
+ # ── Show installed models ─────────────────────────────────────────────────────
60
+ echo ""
61
+ echo "Installed models:"
62
+ ollama list
63
+
64
+ echo ""
65
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
66
+ echo " Done. Local AI endpoint: http://localhost:11434"
67
+ echo ""
68
+ echo " Next steps:"
69
+ echo " 1. Copy .env.development.example → .env.development"
70
+ echo " 2. Set OLLAMA_MODEL to your variant name"
71
+ echo " 3. npm run dev"
72
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
73
+ echo ""