enhancement: rollback edit capabilities for local model
This commit is contained in:
parent
18351e3850
commit
86dcfc10cf
@ -104,17 +104,7 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => {
|
|||||||
if (selectedModel && selectedModel?.id) {
|
if (selectedModel && selectedModel?.id) {
|
||||||
try {
|
try {
|
||||||
// Only check mmproj for llamacpp provider
|
// Only check mmproj for llamacpp provider
|
||||||
if (selectedProvider === 'llamacpp') {
|
if (selectedModel?.capabilities?.includes('vision')) {
|
||||||
const hasLocalMmproj = await serviceHub
|
|
||||||
.models()
|
|
||||||
.checkMmprojExists(selectedModel.id)
|
|
||||||
setHasMmproj(hasLocalMmproj)
|
|
||||||
}
|
|
||||||
// For non-llamacpp providers, only check vision capability
|
|
||||||
else if (
|
|
||||||
selectedProvider !== 'llamacpp' &&
|
|
||||||
selectedModel?.capabilities?.includes('vision')
|
|
||||||
) {
|
|
||||||
setHasMmproj(true)
|
setHasMmproj(true)
|
||||||
} else {
|
} else {
|
||||||
setHasMmproj(false)
|
setHasMmproj(false)
|
||||||
|
|||||||
@ -119,13 +119,20 @@ const DropdownModelProvider = ({
|
|||||||
const model = provider.models[modelIndex]
|
const model = provider.models[modelIndex]
|
||||||
const capabilities = model.capabilities || []
|
const capabilities = model.capabilities || []
|
||||||
|
|
||||||
// Add 'vision' capability if not already present
|
// Add 'vision' capability if not already present AND if user hasn't manually configured capabilities
|
||||||
if (!capabilities.includes('vision')) {
|
// Check if model has a custom capabilities config flag
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const hasUserConfiguredCapabilities = (model as any)._userConfiguredCapabilities === true
|
||||||
|
|
||||||
|
if (!capabilities.includes('vision') && !hasUserConfiguredCapabilities) {
|
||||||
const updatedModels = [...provider.models]
|
const updatedModels = [...provider.models]
|
||||||
updatedModels[modelIndex] = {
|
updatedModels[modelIndex] = {
|
||||||
...model,
|
...model,
|
||||||
capabilities: [...capabilities, 'vision'],
|
capabilities: [...capabilities, 'vision'],
|
||||||
}
|
// Mark this as auto-detected, not user-configured
|
||||||
|
_autoDetectedVision: true,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any
|
||||||
|
|
||||||
updateProvider('llamacpp', { models: updatedModels })
|
updateProvider('llamacpp', { models: updatedModels })
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
IconPencil,
|
IconPencil,
|
||||||
IconEye,
|
IconEye,
|
||||||
IconTool,
|
IconTool,
|
||||||
|
IconAlertTriangle,
|
||||||
// IconWorld,
|
// IconWorld,
|
||||||
// IconAtom,
|
// IconAtom,
|
||||||
// IconCodeCircle2,
|
// IconCodeCircle2,
|
||||||
@ -105,6 +106,8 @@ export const DialogEditModel = ({
|
|||||||
return {
|
return {
|
||||||
...m,
|
...m,
|
||||||
capabilities: updatedCapabilities,
|
capabilities: updatedCapabilities,
|
||||||
|
// Mark that user has manually configured capabilities
|
||||||
|
_userConfiguredCapabilities: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
@ -145,6 +148,21 @@ export const DialogEditModel = ({
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
|
{/* Warning Banner */}
|
||||||
|
<div className="bg-main-view-fg/5 border border-main-view-fg/10 rounded-md p-3">
|
||||||
|
<div className="flex items-start space-x-3">
|
||||||
|
<IconAlertTriangle className="size-5 text-yellow-600 mt-0.5 flex-shrink-0" />
|
||||||
|
<div className="text-sm text-main-view-fg/80">
|
||||||
|
<p className="font-medium mb-1 text-base">
|
||||||
|
{t('providers:editModel.warning.title')}
|
||||||
|
</p>
|
||||||
|
<p className="text-main-view-fg/70">
|
||||||
|
{t('providers:editModel.warning.description')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="py-1">
|
<div className="py-1">
|
||||||
<h3 className="text-sm font-medium mb-3">
|
<h3 className="text-sm font-medium mb-3">
|
||||||
{t('providers:editModel.capabilities')}
|
{t('providers:editModel.capabilities')}
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "Werkzeuge",
|
"tools": "Werkzeuge",
|
||||||
"vision": "Vision",
|
"vision": "Vision",
|
||||||
"embeddings": "Einbettungen",
|
"embeddings": "Einbettungen",
|
||||||
"notAvailable": "Noch nicht verfügbar"
|
"notAvailable": "Noch nicht verfügbar",
|
||||||
|
"warning": {
|
||||||
|
"title": "Mit Vorsicht fortfahren",
|
||||||
|
"description": "Das Ändern von Modellfunktionen kann Leistung und Funktionalität beeinträchtigen. Falsche Einstellungen können zu unerwartetem Verhalten oder Fehlern führen."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "Anbieter hinzufügen",
|
"addProvider": "Anbieter hinzufügen",
|
||||||
"addOpenAIProvider": "OpenAI Anbieter hinzufügen",
|
"addOpenAIProvider": "OpenAI Anbieter hinzufügen",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "Tools",
|
"tools": "Tools",
|
||||||
"vision": "Vision",
|
"vision": "Vision",
|
||||||
"embeddings": "Embeddings",
|
"embeddings": "Embeddings",
|
||||||
"notAvailable": "Not available yet"
|
"notAvailable": "Not available yet",
|
||||||
|
"warning": {
|
||||||
|
"title": "Proceed with Caution",
|
||||||
|
"description": "Modifying model capabilities may affect performance and functionality. Incorrect settings could cause unexpected behavior or errors."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "Add Provider",
|
"addProvider": "Add Provider",
|
||||||
"addOpenAIProvider": "Add OpenAI Provider",
|
"addOpenAIProvider": "Add OpenAI Provider",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "Alat",
|
"tools": "Alat",
|
||||||
"vision": "Visi",
|
"vision": "Visi",
|
||||||
"embeddings": "Embedding",
|
"embeddings": "Embedding",
|
||||||
"notAvailable": "Belum tersedia"
|
"notAvailable": "Belum tersedia",
|
||||||
|
"warning": {
|
||||||
|
"title": "Lanjutkan dengan Hati-hati",
|
||||||
|
"description": "Memodifikasi kemampuan model dapat mempengaruhi kinerja dan fungsionalitas. Pengaturan yang salah dapat menyebabkan perilaku atau kesalahan yang tidak terduga."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "Tambah Penyedia",
|
"addProvider": "Tambah Penyedia",
|
||||||
"addOpenAIProvider": "Tambah Penyedia OpenAI",
|
"addOpenAIProvider": "Tambah Penyedia OpenAI",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "Narzędzia",
|
"tools": "Narzędzia",
|
||||||
"vision": "Wizja",
|
"vision": "Wizja",
|
||||||
"embeddings": "Osadzenia",
|
"embeddings": "Osadzenia",
|
||||||
"notAvailable": "Jeszcze nie dostępne"
|
"notAvailable": "Jeszcze nie dostępne",
|
||||||
|
"warning": {
|
||||||
|
"title": "Zachowaj Ostrożność",
|
||||||
|
"description": "Modyfikowanie możliwości modelu może wpłynąć na wydajność i funkcjonalność. Nieprawidłowe ustawienia mogą spowodować nieoczekiwane zachowanie lub błędy."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "Dodaj Dostawcę",
|
"addProvider": "Dodaj Dostawcę",
|
||||||
"addOpenAIProvider": "Dodaj Dostawcę OpenAI",
|
"addOpenAIProvider": "Dodaj Dostawcę OpenAI",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "Công cụ",
|
"tools": "Công cụ",
|
||||||
"vision": "Thị giác",
|
"vision": "Thị giác",
|
||||||
"embeddings": "Nhúng",
|
"embeddings": "Nhúng",
|
||||||
"notAvailable": "Chưa có"
|
"notAvailable": "Chưa có",
|
||||||
|
"warning": {
|
||||||
|
"title": "Hãy Thận Trọng",
|
||||||
|
"description": "Việc sửa đổi khả năng của mô hình có thể ảnh hưởng đến hiệu suất và chức năng. Cài đặt không chính xác có thể gây ra hành vi hoặc lỗi không mong muốn."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "Thêm nhà cung cấp",
|
"addProvider": "Thêm nhà cung cấp",
|
||||||
"addOpenAIProvider": "Thêm nhà cung cấp OpenAI",
|
"addOpenAIProvider": "Thêm nhà cung cấp OpenAI",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "工具",
|
"tools": "工具",
|
||||||
"vision": "视觉",
|
"vision": "视觉",
|
||||||
"embeddings": "嵌入",
|
"embeddings": "嵌入",
|
||||||
"notAvailable": "尚不可用"
|
"notAvailable": "尚不可用",
|
||||||
|
"warning": {
|
||||||
|
"title": "谨慎操作",
|
||||||
|
"description": "修改模型功能可能会影响性能和功能。错误的设置可能导致意外行为或错误。"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "添加提供商",
|
"addProvider": "添加提供商",
|
||||||
"addOpenAIProvider": "添加 OpenAI 提供商",
|
"addOpenAIProvider": "添加 OpenAI 提供商",
|
||||||
|
|||||||
@ -60,7 +60,11 @@
|
|||||||
"tools": "工具",
|
"tools": "工具",
|
||||||
"vision": "視覺",
|
"vision": "視覺",
|
||||||
"embeddings": "嵌入",
|
"embeddings": "嵌入",
|
||||||
"notAvailable": "尚不可用"
|
"notAvailable": "尚不可用",
|
||||||
|
"warning": {
|
||||||
|
"title": "請謹慎操作",
|
||||||
|
"description": "修改模型功能可能會影響效能和功能。錯誤的設定可能導致意外行為或錯誤。"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"addProvider": "新增提供者",
|
"addProvider": "新增提供者",
|
||||||
"addOpenAIProvider": "新增 OpenAI 提供者",
|
"addOpenAIProvider": "新增 OpenAI 提供者",
|
||||||
|
|||||||
@ -93,16 +93,19 @@ function ProviderDetail() {
|
|||||||
const handleModelImportSuccess = async (importedModelName?: string) => {
|
const handleModelImportSuccess = async (importedModelName?: string) => {
|
||||||
// Refresh the provider to update the models list
|
// Refresh the provider to update the models list
|
||||||
await serviceHub.providers().getProviders().then(setProviders)
|
await serviceHub.providers().getProviders().then(setProviders)
|
||||||
|
|
||||||
// If a model was imported and it might have vision capabilities, check and update
|
// If a model was imported and it might have vision capabilities, check and update
|
||||||
if (importedModelName && providerName === 'llamacpp') {
|
if (importedModelName && providerName === 'llamacpp') {
|
||||||
try {
|
try {
|
||||||
const mmprojExists = await serviceHub.models().checkMmprojExists(importedModelName)
|
const mmprojExists = await serviceHub
|
||||||
|
.models()
|
||||||
|
.checkMmprojExists(importedModelName)
|
||||||
if (mmprojExists) {
|
if (mmprojExists) {
|
||||||
// Get the updated provider after refresh
|
// Get the updated provider after refresh
|
||||||
const { getProviderByName, updateProvider: updateProviderState } = useModelProvider.getState()
|
const { getProviderByName, updateProvider: updateProviderState } =
|
||||||
|
useModelProvider.getState()
|
||||||
const llamacppProvider = getProviderByName('llamacpp')
|
const llamacppProvider = getProviderByName('llamacpp')
|
||||||
|
|
||||||
if (llamacppProvider) {
|
if (llamacppProvider) {
|
||||||
const modelIndex = llamacppProvider.models.findIndex(
|
const modelIndex = llamacppProvider.models.findIndex(
|
||||||
(m: Model) => m.id === importedModelName
|
(m: Model) => m.id === importedModelName
|
||||||
@ -111,16 +114,25 @@ function ProviderDetail() {
|
|||||||
const model = llamacppProvider.models[modelIndex]
|
const model = llamacppProvider.models[modelIndex]
|
||||||
const capabilities = model.capabilities || []
|
const capabilities = model.capabilities || []
|
||||||
|
|
||||||
// Add 'vision' capability if not already present
|
// Add 'vision' capability if not already present AND if user hasn't manually configured capabilities
|
||||||
if (!capabilities.includes('vision')) {
|
// Check if model has a custom capabilities config flag
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const hasUserConfiguredCapabilities = (model as any)._userConfiguredCapabilities === true
|
||||||
|
|
||||||
|
if (!capabilities.includes('vision') && !hasUserConfiguredCapabilities) {
|
||||||
const updatedModels = [...llamacppProvider.models]
|
const updatedModels = [...llamacppProvider.models]
|
||||||
updatedModels[modelIndex] = {
|
updatedModels[modelIndex] = {
|
||||||
...model,
|
...model,
|
||||||
capabilities: [...capabilities, 'vision'],
|
capabilities: [...capabilities, 'vision'],
|
||||||
}
|
// Mark this as auto-detected, not user-configured
|
||||||
|
_autoDetectedVision: true,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any
|
||||||
|
|
||||||
updateProviderState('llamacpp', { models: updatedModels })
|
updateProviderState('llamacpp', { models: updatedModels })
|
||||||
console.log(`Vision capability added to model after provider refresh: ${importedModelName}`)
|
console.log(
|
||||||
|
`Vision capability auto-added to model after provider refresh: ${importedModelName}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,12 +618,10 @@ function ProviderDetail() {
|
|||||||
}
|
}
|
||||||
actions={
|
actions={
|
||||||
<div className="flex items-center gap-0.5">
|
<div className="flex items-center gap-0.5">
|
||||||
{provider && provider.provider !== 'llamacpp' && (
|
<DialogEditModel
|
||||||
<DialogEditModel
|
provider={provider}
|
||||||
provider={provider}
|
modelId={model.id}
|
||||||
modelId={model.id}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{model.settings && (
|
{model.settings && (
|
||||||
<ModelSetting
|
<ModelSetting
|
||||||
provider={provider}
|
provider={provider}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user