- Rename directory keep-notes -> memento-note with all code references - Prisma: SQLite -> PostgreSQL (both app and MCP server schemas) - Sync MCP schema with main app (add missing fields, relations, indexes) - Delete 17 SQLite migrations (clean slate for PostgreSQL) - Remove SQLite dependencies (@libsql/client, better-sqlite3, etc.) - Fix MCP server: hardcoded Windows DB paths -> DATABASE_URL env var - Fix MCP server: .dockerignore excluded index-sse.js (SSE mode broken) - MCP Dockerfile: node:20 -> node:22 - Docker Compose: add postgres service, remove SQLite volume - Generate favicon.ico, icon-192.png, icon-512.png, apple-icon.png - Update layout.tsx icons and manifest.json for PNG icons - Update all .env files for PostgreSQL - Rewrite README.md with updated sections - Remove mcp-server/node_modules and prisma/client-generated from git tracking Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
'use server'
|
|
|
|
interface OllamaModel {
|
|
name: string
|
|
modified_at: string
|
|
size: number
|
|
digest: string
|
|
details: {
|
|
format: string
|
|
family: string
|
|
families: string[]
|
|
parameter_size: string
|
|
quantization_level: string
|
|
}
|
|
}
|
|
|
|
interface OllamaTagsResponse {
|
|
models: OllamaModel[]
|
|
}
|
|
|
|
export async function getOllamaModels(baseUrl: string): Promise<{ success: boolean; models: string[]; error?: string }> {
|
|
if (!baseUrl) {
|
|
return { success: false, models: [], error: 'Base URL is required' }
|
|
}
|
|
|
|
// Ensure URL doesn't end with slash
|
|
const cleanUrl = baseUrl.replace(/\/$/, '')
|
|
|
|
try {
|
|
const response = await fetch(`${cleanUrl}/api/tags`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
// Set a reasonable timeout
|
|
signal: AbortSignal.timeout(5000)
|
|
})
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Ollama API returned ${response.status}: ${response.statusText}`)
|
|
}
|
|
|
|
const data = await response.json() as OllamaTagsResponse
|
|
|
|
// Extract model names
|
|
const modelNames = data.models?.map(m => m.name) || []
|
|
|
|
return { success: true, models: modelNames }
|
|
} catch (error: any) {
|
|
console.error('Failed to fetch Ollama models:', error)
|
|
return {
|
|
success: false,
|
|
models: [],
|
|
error: error.message || 'Failed to connect to Ollama'
|
|
}
|
|
}
|
|
}
|