Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/ai/cerebras/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@profullstack/sh1pt-ai-cerebras",
"version": "0.1.15",
"type": "module",
"main": "./src/index.ts",
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@profullstack/sh1pt-core": "workspace:*"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/profullstack/sh1pt.git",
"directory": "packages/ai/cerebras"
},
"homepage": "https://sh1pt.com",
"bugs": "https://github.com/profullstack/sh1pt/issues",
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
}
}
}
68 changes: 68 additions & 0 deletions packages/ai/cerebras/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineAi, tokenSetup } from '@profullstack/sh1pt-core';

// Cerebras — wafer-scale chip inference, extremely fast throughput.
// OpenAI-compatible Chat Completions API.
// Base URL: https://api.cerebras.ai (append /v1/chat/completions)
// Docs: https://inference-docs.cerebras.ai/api-reference/chat-completions
interface Config {
baseUrl?: string;
}

const DEFAULT_BASE = 'https://api.cerebras.ai';

export default defineAi<Config>({
id: 'ai-cerebras',
label: 'Cerebras',
defaultModel: 'llama-3.3-70b',
models: ['llama-3.3-70b', 'llama-3.1-8b'],

async generate(ctx, prompt, opts, config) {
const apiKey = ctx.secret('CEREBRAS_API_KEY');
if (!apiKey) throw new Error('CEREBRAS_API_KEY not in vault — run `sh1pt promote ai setup`');
const model = opts.model ?? 'llama-3.3-70b';
ctx.log(`cerebras · model=${model} · ${prompt.length} chars in`);
if (ctx.dryRun) return { text: '[dry-run]', model };

const messages: Array<{ role: string; content: string }> = [];
if (opts.system) messages.push({ role: 'system', content: opts.system });
messages.push({ role: 'user', content: prompt });

const res = await fetch(`${config.baseUrl ?? DEFAULT_BASE}/v1/chat/completions`, {
method: 'POST',
headers: {
authorization: `Bearer ${apiKey}`,
'content-type': 'application/json',
},
body: JSON.stringify({
model,
messages,
...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}),
...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}),
...opts.extra,
}),
});
if (!res.ok) throw new Error(`Cerebras ${res.status}: ${(await res.text()).slice(0, 200)}`);
const data = (await res.json()) as {
choices: Array<{ message?: { content?: string } }>;
model: string;
usage?: { prompt_tokens?: number; completion_tokens?: number };
};
return {
text: data.choices[0]?.message?.content ?? '',
model: data.model,
inputTokens: data.usage?.prompt_tokens,
outputTokens: data.usage?.completion_tokens,
};
},

setup: tokenSetup<Config>({
secretKey: 'CEREBRAS_API_KEY',
label: 'Cerebras',
vendorDocUrl: 'https://cloud.cerebras.ai',
steps: [
'Open cloud.cerebras.ai → API Keys → Create new key',
'Copy the key',
'Paste below; sh1pt encrypts it in the vault',
],
}),
});
10 changes: 10 additions & 0 deletions packages/ai/cerebras/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": [
"src/**/*"
]
}
36 changes: 36 additions & 0 deletions packages/ai/deepseek/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@profullstack/sh1pt-ai-deepseek",
"version": "0.1.15",
"type": "module",
"main": "./src/index.ts",
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@profullstack/sh1pt-core": "workspace:*"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/profullstack/sh1pt.git",
"directory": "packages/ai/deepseek"
},
"homepage": "https://sh1pt.com",
"bugs": "https://github.com/profullstack/sh1pt/issues",
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
}
}
}
68 changes: 68 additions & 0 deletions packages/ai/deepseek/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineAi, tokenSetup } from '@profullstack/sh1pt-core';

// DeepSeek — high-capability models with competitive pricing.
// OpenAI-compatible Chat Completions API.
// Base URL: https://api.deepseek.com (append /v1/chat/completions)
// Docs: https://platform.deepseek.com/api-docs
interface Config {
baseUrl?: string;
}

const DEFAULT_BASE = 'https://api.deepseek.com';

export default defineAi<Config>({
id: 'ai-deepseek',
label: 'DeepSeek',
defaultModel: 'deepseek-chat',
models: ['deepseek-chat', 'deepseek-reasoner'],

async generate(ctx, prompt, opts, config) {
const apiKey = ctx.secret('DEEPSEEK_API_KEY');
if (!apiKey) throw new Error('DEEPSEEK_API_KEY not in vault — run `sh1pt promote ai setup`');
const model = opts.model ?? 'deepseek-chat';
ctx.log(`deepseek · model=${model} · ${prompt.length} chars in`);
if (ctx.dryRun) return { text: '[dry-run]', model };

const messages: Array<{ role: string; content: string }> = [];
if (opts.system) messages.push({ role: 'system', content: opts.system });
messages.push({ role: 'user', content: prompt });

const res = await fetch(`${config.baseUrl ?? DEFAULT_BASE}/v1/chat/completions`, {
method: 'POST',
headers: {
authorization: `Bearer ${apiKey}`,
'content-type': 'application/json',
},
body: JSON.stringify({
model,
messages,
...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}),
...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}),
...opts.extra,
}),
});
if (!res.ok) throw new Error(`DeepSeek ${res.status}: ${(await res.text()).slice(0, 200)}`);
const data = (await res.json()) as {
choices: Array<{ message?: { content?: string } }>;
model: string;
usage?: { prompt_tokens?: number; completion_tokens?: number };
};
return {
text: data.choices[0]?.message?.content ?? '',
model: data.model,
inputTokens: data.usage?.prompt_tokens,
outputTokens: data.usage?.completion_tokens,
};
},

setup: tokenSetup<Config>({
secretKey: 'DEEPSEEK_API_KEY',
label: 'DeepSeek',
vendorDocUrl: 'https://platform.deepseek.com/api-docs',
steps: [
'Open platform.deepseek.com → API Keys → Create new API key',
'Copy the key',
'Paste below; sh1pt encrypts it in the vault',
],
}),
});
10 changes: 10 additions & 0 deletions packages/ai/deepseek/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": [
"src/**/*"
]
}
36 changes: 36 additions & 0 deletions packages/ai/groq/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@profullstack/sh1pt-ai-groq",
"version": "0.1.15",
"type": "module",
"main": "./src/index.ts",
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@profullstack/sh1pt-core": "workspace:*"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/profullstack/sh1pt.git",
"directory": "packages/ai/groq"
},
"homepage": "https://sh1pt.com",
"bugs": "https://github.com/profullstack/sh1pt/issues",
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
}
}
}
67 changes: 67 additions & 0 deletions packages/ai/groq/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { defineAi, tokenSetup } from '@profullstack/sh1pt-core';

// Groq — ultra-fast LPU inference. OpenAI-compatible Chat Completions API.
// Base URL: https://api.groq.com/openai (append /v1/chat/completions)
// Docs: https://console.groq.com/docs/openai
interface Config {
baseUrl?: string;
}

const DEFAULT_BASE = 'https://api.groq.com/openai';

export default defineAi<Config>({
id: 'ai-groq',
label: 'Groq',
defaultModel: 'llama-3.3-70b-versatile',
models: ['llama-3.3-70b-versatile', 'llama-3.1-8b-instant', 'mixtral-8x7b-32768', 'gemma2-9b-it'],

async generate(ctx, prompt, opts, config) {
const apiKey = ctx.secret('GROQ_API_KEY');
if (!apiKey) throw new Error('GROQ_API_KEY not in vault — run `sh1pt promote ai setup`');
const model = opts.model ?? 'llama-3.3-70b-versatile';
ctx.log(`groq · model=${model} · ${prompt.length} chars in`);
if (ctx.dryRun) return { text: '[dry-run]', model };

const messages: Array<{ role: string; content: string }> = [];
if (opts.system) messages.push({ role: 'system', content: opts.system });
messages.push({ role: 'user', content: prompt });

const res = await fetch(`${config.baseUrl ?? DEFAULT_BASE}/v1/chat/completions`, {
method: 'POST',
headers: {
authorization: `Bearer ${apiKey}`,
'content-type': 'application/json',
},
body: JSON.stringify({
model,
messages,
...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}),
...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}),
...opts.extra,
}),
});
if (!res.ok) throw new Error(`Groq ${res.status}: ${(await res.text()).slice(0, 200)}`);
const data = (await res.json()) as {
choices: Array<{ message?: { content?: string } }>;
model: string;
usage?: { prompt_tokens?: number; completion_tokens?: number };
};
return {
text: data.choices[0]?.message?.content ?? '',
model: data.model,
inputTokens: data.usage?.prompt_tokens,
outputTokens: data.usage?.completion_tokens,
};
},

setup: tokenSetup<Config>({
secretKey: 'GROQ_API_KEY',
label: 'Groq',
vendorDocUrl: 'https://console.groq.com/keys',
steps: [
'Open console.groq.com → API Keys → Create API Key',
'Copy the key (starts with gsk_…)',
'Paste below; sh1pt encrypts it in the vault',
],
}),
});
10 changes: 10 additions & 0 deletions packages/ai/groq/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": [
"src/**/*"
]
}
36 changes: 36 additions & 0 deletions packages/ai/mistral/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@profullstack/sh1pt-ai-mistral",
"version": "0.1.15",
"type": "module",
"main": "./src/index.ts",
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@profullstack/sh1pt-core": "workspace:*"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/profullstack/sh1pt.git",
"directory": "packages/ai/mistral"
},
"homepage": "https://sh1pt.com",
"bugs": "https://github.com/profullstack/sh1pt/issues",
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
}
}
}
Loading