fix: reverse setting local provider (#5140)

* fix: reverse setting local provider

* fix conflict
This commit is contained in:
Faisal Amir 2025-05-30 00:00:07 +07:00 committed by GitHub
parent e9c9205544
commit 27c2a360f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -240,6 +240,14 @@ function ProviderDetail() {
/> />
</div> </div>
<div
className={cn(
'flex flex-col gap-3',
provider &&
provider.provider === 'llama.cpp' &&
'flex-col-reverse'
)}
>
{/* Settings */} {/* Settings */}
<Card> <Card>
{provider?.settings.map((setting, settingIndex) => { {provider?.settings.map((setting, settingIndex) => {
@ -369,7 +377,9 @@ function ProviderDetail() {
/> />
)} )}
<span className="text-main-view-fg/70"> <span className="text-main-view-fg/70">
{refreshingModels ? 'Refreshing...' : 'Refresh'} {refreshingModels
? 'Refreshing...'
: 'Refresh'}
</span> </span>
</div> </div>
</Button> </Button>
@ -397,7 +407,10 @@ function ProviderDetail() {
try { try {
await importModel(selectedFile) await importModel(selectedFile)
} catch (error) { } catch (error) {
console.error('Failed to import model:', error) console.error(
'Failed to import model:',
error
)
} finally { } finally {
// Refresh the provider to update the models list // Refresh the provider to update the models list
getProviders().then(setProviders) getProviders().then(setProviders)
@ -409,12 +422,14 @@ function ProviderDetail() {
} }
}} }}
> >
<div className="cursor-pointer flex items-center justify-center rounded hover:bg-main-view-fg/15 bg-main-view-fg/10 transition-all duration-200 ease-in-out px-1.5 py-1 gap-1"> <div className="cursor-pointer flex items-center justify-center rounded hover:bg-main-view-fg/15 bg-main-view-fg/10 transition-all duration-200 ease-in-out p-1.5 py-1 gap-1 -mr-2">
<IconFolderPlus <IconFolderPlus
size={18} size={18}
className="text-main-view-fg/50" className="text-main-view-fg/50"
/> />
<span className="text-main-view-fg/70">Import</span> <span className="text-main-view-fg/70">
Import
</span>
</div> </div>
</Button> </Button>
)} )}
@ -436,23 +451,45 @@ function ProviderDetail() {
} }
actions={ actions={
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{provider && provider.provider === 'llama.cpp' && ( <DialogEditModel
<div className="mr-1"> provider={provider}
modelId={model.id}
/>
{model.settings && (
<ModelSetting
provider={provider}
model={model}
/>
)}
<DialogDeleteModel
provider={provider}
modelId={model.id}
/>
{provider &&
provider.provider === 'llama.cpp' && (
<div className="ml-2">
{activeModels.some( {activeModels.some(
(activeModel) => activeModel.id === model.id (activeModel) =>
activeModel.id === model.id
) ? ( ) ? (
<Button <Button
size="sm" size="sm"
variant="destructive" variant="destructive"
onClick={() => handleStopModel(model.id)} onClick={() =>
handleStopModel(model.id)
}
> >
Stop Stop
</Button> </Button>
) : ( ) : (
<Button <Button
size="sm" size="sm"
disabled={loadingModels.includes(model.id)} disabled={loadingModels.includes(
onClick={() => handleStartModel(model.id)} model.id
)}
onClick={() =>
handleStartModel(model.id)
}
> >
{loadingModels.includes(model.id) ? ( {loadingModels.includes(model.id) ? (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
@ -468,17 +505,6 @@ function ProviderDetail() {
)} )}
</div> </div>
)} )}
<DialogEditModel
provider={provider}
modelId={model.id}
/>
{model.settings && (
<ModelSetting provider={provider} model={model} />
)}
<DialogDeleteModel
provider={provider}
modelId={model.id}
/>
</div> </div>
} }
/> />
@ -487,7 +513,9 @@ function ProviderDetail() {
) : ( ) : (
<div className="-mt-2"> <div className="-mt-2">
<div className="flex items-center gap-2 text-left-panel-fg/80"> <div className="flex items-center gap-2 text-left-panel-fg/80">
<h6 className="font-medium text-base">No model found</h6> <h6 className="font-medium text-base">
No model found
</h6>
</div> </div>
<p className="text-left-panel-fg/60 mt-1 text-xs leading-relaxed"> <p className="text-left-panel-fg/60 mt-1 text-xs leading-relaxed">
Available models will be listed here. If you don't have Available models will be listed here. If you don't have
@ -502,6 +530,7 @@ function ProviderDetail() {
</div> </div>
</div> </div>
</div> </div>
</div>
</> </>
) )
} }