feat: enhance remote model search to use dynamic catalog
Replace hardcoded list of popular models with dynamic catalog from getCatalogModels(). Enable searching by model name or description and include model descriptions in results. Improves discoverability and maintains up-to-date model list without manual updates. Database files updated accordingly.
This commit is contained in:
1 parent
7b2386876a
commit
30290ae87a
10 files changed
+2003
-50
No files matched your search
+19
-50
@@ -1,6 +1,7 @@
|
||||
import { Ollama } from "ollama";
|
||||
import os from "node:os";
|
||||
import { spawn } from "node:child_process";
|
||||
import { getCatalogModels } from "./catalog";
|
||||
|
||||
export const OLLAMA_HOST = process.env.OLLAMA_HOST || "http://localhost:11434";
|
||||
|
||||
@@ -166,60 +167,28 @@ export async function deleteModel(modelName: string): Promise<void> {
|
||||
|
||||
export async function searchRemoteModels(query?: string): Promise<any[]> {
|
||||
try {
|
||||
// Ollama não tem API oficial para buscar modelos remotos
|
||||
// Vamos usar uma lista conhecida de modelos populares
|
||||
const popularModels = [
|
||||
"llama3.2:1b",
|
||||
"llama3.2:3b",
|
||||
"llama3.2:11b",
|
||||
"llama3.2:70b",
|
||||
"llama3.1:8b",
|
||||
"llama3.1:70b",
|
||||
"llama3.1:405b",
|
||||
"qwen2.5:1.5b",
|
||||
"qwen2.5:3b",
|
||||
"qwen2.5:7b",
|
||||
"qwen2.5:14b",
|
||||
"qwen2.5:32b",
|
||||
"qwen2.5:72b",
|
||||
"qwen2:0.5b",
|
||||
"qwen2:1.5b",
|
||||
"qwen2:3b",
|
||||
"qwen2:7b",
|
||||
"qwen2:14b",
|
||||
"qwen2:32b",
|
||||
"qwen2:72b",
|
||||
"mistral:7b",
|
||||
"mixtral:8x7b",
|
||||
"mixtral:8x22b",
|
||||
"phi3:mini",
|
||||
"phi3:medium",
|
||||
"phi3:large",
|
||||
"gemma2:2b",
|
||||
"gemma2:9b",
|
||||
"gemma2:27b",
|
||||
"codellama:7b",
|
||||
"codellama:13b",
|
||||
"codellama:34b",
|
||||
"deepseek-coder:1.3b",
|
||||
"deepseek-coder:6.7b",
|
||||
"deepseek-coder:33b",
|
||||
];
|
||||
const catalog = await getCatalogModels();
|
||||
|
||||
// Filtrar por query se fornecida
|
||||
const filteredModels = query
|
||||
? popularModels.filter((model) =>
|
||||
model.toLowerCase().includes(query.toLowerCase())
|
||||
)
|
||||
: popularModels;
|
||||
// Normalizar pesquisa
|
||||
const q = (query || "").trim().toLowerCase();
|
||||
|
||||
// Verificar quais já estão instalados
|
||||
const filtered = q
|
||||
? catalog.filter((m) => {
|
||||
const name = m.name?.toLowerCase() || "";
|
||||
const desc = m.description?.toLowerCase() || "";
|
||||
return name.includes(q) || desc.includes(q);
|
||||
})
|
||||
: catalog;
|
||||
|
||||
// Modelos instalados
|
||||
const installedModels = await listModelsViaSdk();
|
||||
const installedNames = installedModels.map((m) => m.name);
|
||||
const installedNames = new Set(installedModels.map((m) => m.name));
|
||||
|
||||
return filteredModels.map((modelName) => ({
|
||||
name: modelName,
|
||||
installed: installedNames.includes(modelName),
|
||||
// Retorno no formato esperado pelo frontend
|
||||
return filtered.map((m) => ({
|
||||
name: m.name,
|
||||
description: m.description,
|
||||
installed: installedNames.has(m.name),
|
||||
remote: true,
|
||||
}));
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user