2024-10-12 19:05:21 +05:30
|
|
|
import { getAllOpenAIModels } from "@/libs/openai"
|
2024-10-12 18:28:29 +05:30
|
|
|
import {
|
|
|
|
|
getAllOpenAIConfig,
|
|
|
|
|
getOpenAIConfigById as providerInfo
|
|
|
|
|
} from "./openai"
|
2024-09-29 19:12:19 +05:30
|
|
|
|
|
|
|
|
type Model = {
|
|
|
|
|
id: string
|
|
|
|
|
model_id: string
|
|
|
|
|
name: string
|
|
|
|
|
provider_id: string
|
|
|
|
|
lookup: string
|
2024-10-13 16:10:52 +05:30
|
|
|
model_type: string
|
2024-09-29 19:12:19 +05:30
|
|
|
db_type: string
|
|
|
|
|
}
|
|
|
|
|
export const generateID = () => {
|
|
|
|
|
return "model-xxxx-xxxx-xxx-xxxx".replace(/[x]/g, () => {
|
|
|
|
|
const r = Math.floor(Math.random() * 16)
|
|
|
|
|
return r.toString(16)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 16:53:42 +05:30
|
|
|
export const removeModelSuffix = (id: string) => {
|
2024-10-13 18:22:16 +05:30
|
|
|
return id
|
|
|
|
|
.replace(/_model-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{3,4}-[a-f0-9]{4}/, "")
|
|
|
|
|
.replace(/_lmstudio_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/, "")
|
2024-11-10 14:02:44 +05:30
|
|
|
.replace(/_llamafile_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/, "")
|
2024-11-10 15:31:28 +05:30
|
|
|
.replace(/_ollama2_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/, "")
|
2024-10-12 19:05:21 +05:30
|
|
|
}
|
|
|
|
|
export const isLMStudioModel = (model: string) => {
|
2024-10-13 18:22:16 +05:30
|
|
|
const lmstudioModelRegex =
|
|
|
|
|
/_lmstudio_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
2024-10-12 19:05:21 +05:30
|
|
|
return lmstudioModelRegex.test(model)
|
2024-09-29 19:12:19 +05:30
|
|
|
}
|
2024-09-29 19:57:26 +05:30
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
export const isLlamafileModel = (model: string) => {
|
|
|
|
|
const llamafileModelRegex =
|
|
|
|
|
/_llamafile_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
|
|
|
|
return llamafileModelRegex.test(model)
|
|
|
|
|
}
|
2024-11-10 15:31:28 +05:30
|
|
|
export const isOllamaModel = (model: string) => {
|
|
|
|
|
const ollamaModelRegex =
|
|
|
|
|
/_ollama2_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
|
|
|
|
return ollamaModelRegex.test(model)
|
|
|
|
|
}
|
2024-10-13 18:22:16 +05:30
|
|
|
export const getLMStudioModelId = (
|
|
|
|
|
model: string
|
|
|
|
|
): { model_id: string; provider_id: string } => {
|
|
|
|
|
const lmstudioModelRegex =
|
|
|
|
|
/_lmstudio_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
2024-10-12 19:05:21 +05:30
|
|
|
const match = model.match(lmstudioModelRegex)
|
|
|
|
|
if (match) {
|
|
|
|
|
const modelId = match[0]
|
|
|
|
|
const providerId = match[0].replace("_lmstudio_openai-", "")
|
|
|
|
|
return { model_id: modelId, provider_id: providerId }
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
2024-11-10 15:31:28 +05:30
|
|
|
export const getOllamaModelId = (
|
|
|
|
|
model: string
|
|
|
|
|
): { model_id: string; provider_id: string } => {
|
|
|
|
|
const ollamaModelRegex =
|
|
|
|
|
/_ollama2_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
|
|
|
|
const match = model.match(ollamaModelRegex)
|
|
|
|
|
if (match) {
|
|
|
|
|
const modelId = match[0]
|
|
|
|
|
const providerId = match[0].replace("_ollama2_openai-", "")
|
|
|
|
|
return { model_id: modelId, provider_id: providerId }
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
2024-11-10 14:02:44 +05:30
|
|
|
export const getLlamafileModelId = (
|
|
|
|
|
model: string
|
|
|
|
|
): { model_id: string; provider_id: string } => {
|
|
|
|
|
const llamafileModelRegex =
|
|
|
|
|
/_llamafile_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/
|
|
|
|
|
const match = model.match(llamafileModelRegex)
|
|
|
|
|
if (match) {
|
|
|
|
|
const modelId = match[0]
|
|
|
|
|
const providerId = match[0].replace("_llamafile_openai-", "")
|
|
|
|
|
return { model_id: modelId, provider_id: providerId }
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
2024-09-29 19:57:26 +05:30
|
|
|
export const isCustomModel = (model: string) => {
|
2024-10-12 19:05:21 +05:30
|
|
|
if (isLMStudioModel(model)) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2024-11-10 14:02:44 +05:30
|
|
|
|
|
|
|
|
if (isLlamafileModel(model)) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
if (isOllamaModel(model)) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 18:28:29 +05:30
|
|
|
const customModelRegex =
|
|
|
|
|
/_model-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{3,4}-[a-f0-9]{4}/
|
2024-09-29 19:57:26 +05:30
|
|
|
return customModelRegex.test(model)
|
|
|
|
|
}
|
2024-09-29 19:12:19 +05:30
|
|
|
export class ModelDb {
|
|
|
|
|
db: chrome.storage.StorageArea
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.db = chrome.storage.local
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getAll = async (): Promise<Model[]> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.get(null, (result) => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
const data = Object.keys(result).map((key) => result[key])
|
|
|
|
|
resolve(data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
create = async (model: Model): Promise<void> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.set({ [model.id]: model }, () => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
resolve()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getById = async (id: string): Promise<Model> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.get(id, (result) => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
resolve(result[id])
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update = async (model: Model): Promise<void> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.set({ [model.id]: model }, () => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
resolve()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete = async (id: string): Promise<void> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.remove(id, () => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
resolve()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteAll = async (): Promise<void> => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.db.clear(() => {
|
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
|
reject(chrome.runtime.lastError)
|
|
|
|
|
} else {
|
|
|
|
|
resolve()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createManyModels = async (
|
2024-10-13 18:22:16 +05:30
|
|
|
data: { model_id: string; name: string; provider_id: string, model_type: string }[]
|
2024-09-29 19:12:19 +05:30
|
|
|
) => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
|
|
|
|
|
const models = data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
lookup: `${item.model_id}_${item.provider_id}`,
|
|
|
|
|
id: `${item.model_id}_${generateID()}`,
|
2024-10-12 16:53:42 +05:30
|
|
|
db_type: "openai_model",
|
2024-10-13 16:10:52 +05:30
|
|
|
name: item.name.replaceAll(/accounts\/[^\/]+\/models\//g, ""),
|
2024-09-29 19:12:19 +05:30
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
for (const model of models) {
|
|
|
|
|
const isExist = await isLookupExist(model.lookup)
|
|
|
|
|
|
|
|
|
|
if (isExist) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await db.create(model)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createModel = async (
|
|
|
|
|
model_id: string,
|
|
|
|
|
name: string,
|
2024-10-13 18:22:16 +05:30
|
|
|
provider_id: string,
|
|
|
|
|
model_type: string
|
2024-09-29 19:12:19 +05:30
|
|
|
) => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
const id = generateID()
|
|
|
|
|
const model: Model = {
|
|
|
|
|
id: `${model_id}_${id}`,
|
|
|
|
|
model_id,
|
|
|
|
|
name,
|
|
|
|
|
provider_id,
|
|
|
|
|
lookup: `${model_id}_${provider_id}`,
|
2024-10-13 16:10:52 +05:30
|
|
|
db_type: "openai_model",
|
2024-10-13 18:22:16 +05:30
|
|
|
model_type: model_type
|
2024-09-29 19:12:19 +05:30
|
|
|
}
|
|
|
|
|
await db.create(model)
|
|
|
|
|
return model
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getModelInfo = async (id: string) => {
|
|
|
|
|
const db = new ModelDb()
|
2024-10-12 19:05:21 +05:30
|
|
|
|
|
|
|
|
if (isLMStudioModel(id)) {
|
|
|
|
|
const lmstudioId = getLMStudioModelId(id)
|
|
|
|
|
if (!lmstudioId) {
|
|
|
|
|
throw new Error("Invalid LMStudio model ID")
|
|
|
|
|
}
|
|
|
|
|
return {
|
2024-10-13 18:22:16 +05:30
|
|
|
model_id: id.replace(
|
|
|
|
|
/_lmstudio_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
),
|
2024-10-12 19:05:21 +05:30
|
|
|
provider_id: `openai-${lmstudioId.provider_id}`,
|
2024-10-13 18:22:16 +05:30
|
|
|
name: id.replace(
|
|
|
|
|
/_lmstudio_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
)
|
2024-10-12 19:05:21 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
|
|
|
|
|
if (isLlamafileModel(id)) {
|
|
|
|
|
const llamafileId = getLlamafileModelId(id)
|
|
|
|
|
if (!llamafileId) {
|
|
|
|
|
throw new Error("Invalid LMStudio model ID")
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
model_id: id.replace(
|
|
|
|
|
/_llamafile_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
),
|
|
|
|
|
provider_id: `openai-${llamafileId.provider_id}`,
|
|
|
|
|
name: id.replace(
|
|
|
|
|
/_llamafile_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
|
|
|
|
|
if (isOllamaModel(id)) {
|
|
|
|
|
const ollamaId = getOllamaModelId(id)
|
|
|
|
|
if (!ollamaId) {
|
|
|
|
|
throw new Error("Invalid LMStudio model ID")
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
model_id: id.replace(
|
|
|
|
|
/_ollama2_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
),
|
|
|
|
|
provider_id: `openai-${ollamaId.provider_id}`,
|
|
|
|
|
name: id.replace(
|
|
|
|
|
/_ollama2_openai-[a-f0-9]{4}-[a-f0-9]{3}-[a-f0-9]{4}/,
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-29 19:12:19 +05:30
|
|
|
const model = await db.getById(id)
|
|
|
|
|
return model
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getAllCustomModels = async () => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
const models = (await db.getAll()).filter(
|
|
|
|
|
(model) => model.db_type === "openai_model"
|
|
|
|
|
)
|
|
|
|
|
const modelsWithProvider = await Promise.all(
|
|
|
|
|
models.map(async (model) => {
|
|
|
|
|
const provider = await providerInfo(model.provider_id)
|
|
|
|
|
return { ...model, provider }
|
|
|
|
|
})
|
|
|
|
|
)
|
2024-10-13 18:22:16 +05:30
|
|
|
|
2024-09-29 19:12:19 +05:30
|
|
|
return modelsWithProvider
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const deleteModel = async (id: string) => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
await db.delete(id)
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 18:28:29 +05:30
|
|
|
export const deleteAllModelsByProviderId = async (provider_id: string) => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
const models = await db.getAll()
|
|
|
|
|
const modelsToDelete = models.filter(
|
|
|
|
|
(model) => model.provider_id === provider_id
|
|
|
|
|
)
|
|
|
|
|
for (const model of modelsToDelete) {
|
|
|
|
|
await db.delete(model.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-29 19:12:19 +05:30
|
|
|
export const isLookupExist = async (lookup: string) => {
|
|
|
|
|
const db = new ModelDb()
|
|
|
|
|
const models = await db.getAll()
|
|
|
|
|
const model = models.find((model) => model.lookup === lookup)
|
|
|
|
|
return model ? true : false
|
|
|
|
|
}
|
2024-09-29 19:57:26 +05:30
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
export const dynamicFetchLMStudio = async ({
|
|
|
|
|
baseUrl,
|
|
|
|
|
providerId
|
|
|
|
|
}: {
|
|
|
|
|
baseUrl: string
|
|
|
|
|
providerId: string
|
|
|
|
|
}) => {
|
|
|
|
|
const models = await getAllOpenAIModels(baseUrl)
|
|
|
|
|
const lmstudioModels = models.map((e) => {
|
|
|
|
|
return {
|
|
|
|
|
name: e?.name || e?.id,
|
|
|
|
|
id: `${e?.id}_lmstudio_${providerId}`,
|
|
|
|
|
provider: providerId,
|
|
|
|
|
lookup: `${e?.id}_${providerId}`,
|
2024-10-13 18:22:16 +05:30
|
|
|
provider_id: providerId
|
2024-10-12 19:05:21 +05:30
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return lmstudioModels
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
export const dynamicFetchOllama2 = async ({
|
|
|
|
|
baseUrl,
|
|
|
|
|
providerId
|
|
|
|
|
}: {
|
|
|
|
|
baseUrl: string
|
|
|
|
|
providerId: string
|
|
|
|
|
}) => {
|
|
|
|
|
const models = await getAllOpenAIModels(baseUrl)
|
|
|
|
|
const ollama2Models = models.map((e) => {
|
|
|
|
|
return {
|
|
|
|
|
name: e?.name || e?.id,
|
|
|
|
|
id: `${e?.id}_ollama2_${providerId}`,
|
|
|
|
|
provider: providerId,
|
|
|
|
|
lookup: `${e?.id}_${providerId}`,
|
|
|
|
|
provider_id: providerId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return ollama2Models
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
export const dynamicFetchLlamafile = async ({
|
|
|
|
|
baseUrl,
|
|
|
|
|
providerId
|
|
|
|
|
}: {
|
|
|
|
|
baseUrl: string
|
|
|
|
|
providerId: string
|
|
|
|
|
}) => {
|
|
|
|
|
const models = await getAllOpenAIModels(baseUrl)
|
|
|
|
|
const llamafileModels = models.map((e) => {
|
|
|
|
|
return {
|
|
|
|
|
name: e?.name || e?.id,
|
|
|
|
|
id: `${e?.id}_llamafile_${providerId}`,
|
|
|
|
|
provider: providerId,
|
|
|
|
|
lookup: `${e?.id}_${providerId}`,
|
|
|
|
|
provider_id: providerId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return llamafileModels
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-13 18:22:16 +05:30
|
|
|
export const ollamaFormatAllCustomModels = async (
|
|
|
|
|
modelType: "all" | "chat" | "embedding" = "all"
|
|
|
|
|
) => {
|
2024-10-12 19:05:21 +05:30
|
|
|
const [allModles, allProviders] = await Promise.all([
|
|
|
|
|
getAllCustomModels(),
|
|
|
|
|
getAllOpenAIConfig()
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const lmstudioProviders = allProviders.filter(
|
|
|
|
|
(provider) => provider.provider === "lmstudio"
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
const llamafileProviders = allProviders.filter(
|
|
|
|
|
(provider) => provider.provider === "llamafile"
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
const lmModelsPromises = lmstudioProviders.map((provider) =>
|
|
|
|
|
dynamicFetchLMStudio({
|
|
|
|
|
baseUrl: provider.baseUrl,
|
|
|
|
|
providerId: provider.id
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
const llamafileModelsPromises = llamafileProviders.map((provider) =>
|
|
|
|
|
dynamicFetchLlamafile({
|
|
|
|
|
baseUrl: provider.baseUrl,
|
|
|
|
|
providerId: provider.id
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
const ollamaModelsPromises = allProviders.map((provider) => (
|
|
|
|
|
dynamicFetchOllama2({
|
|
|
|
|
baseUrl: provider.baseUrl,
|
|
|
|
|
providerId: provider.id
|
|
|
|
|
})
|
|
|
|
|
))
|
|
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
const lmModelsFetch = await Promise.all(lmModelsPromises)
|
|
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
const llamafileModelsFetch = await Promise.all(llamafileModelsPromises)
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
const ollamaModelsFetch = await Promise.all(ollamaModelsPromises)
|
|
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
const lmModels = lmModelsFetch.flat()
|
2024-09-29 19:57:26 +05:30
|
|
|
|
2024-11-10 14:02:44 +05:30
|
|
|
const llamafileModels = llamafileModelsFetch.flat()
|
|
|
|
|
|
2024-11-10 15:31:28 +05:30
|
|
|
const ollama2Models = ollamaModelsFetch.flat()
|
|
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
// merge allModels and lmModels
|
2024-10-13 18:22:16 +05:30
|
|
|
const allModlesWithLMStudio = [
|
|
|
|
|
...(modelType !== "all"
|
|
|
|
|
? allModles.filter((model) => model.model_type === modelType)
|
|
|
|
|
: allModles),
|
2024-11-10 14:02:44 +05:30
|
|
|
...lmModels,
|
2024-11-10 15:31:28 +05:30
|
|
|
...llamafileModels,
|
|
|
|
|
...ollama2Models
|
2024-10-13 18:22:16 +05:30
|
|
|
]
|
2024-10-12 18:28:29 +05:30
|
|
|
|
2024-10-12 19:05:21 +05:30
|
|
|
const ollamaModels = allModlesWithLMStudio.map((model) => {
|
2024-09-29 19:57:26 +05:30
|
|
|
return {
|
|
|
|
|
name: model.name,
|
|
|
|
|
model: model.id,
|
|
|
|
|
modified_at: "",
|
2024-10-12 18:28:29 +05:30
|
|
|
provider:
|
|
|
|
|
allProviders.find((provider) => provider.id === model.provider_id)
|
|
|
|
|
?.provider || "custom",
|
2024-09-29 19:57:26 +05:30
|
|
|
size: 0,
|
|
|
|
|
digest: "",
|
|
|
|
|
details: {
|
|
|
|
|
parent_model: "",
|
|
|
|
|
format: "",
|
|
|
|
|
family: "",
|
|
|
|
|
families: [],
|
|
|
|
|
parameter_size: "",
|
|
|
|
|
quantization_level: ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return ollamaModels
|
2024-10-12 18:28:29 +05:30
|
|
|
}
|