Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions web-app/src/containers/ModelSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,47 @@
}

export function ModelSetting({
model,
provider,
smallIcon,
}: ModelSettingProps) {
const { updateProvider } = useModelProvider()
const { t } = useTranslation()
const serviceHub = useServiceHub()

Check warning on line 33 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

27-33 lines are not covered with tests

const [isPlanning, setIsPlanning] = useState(false)

Check warning on line 35 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

35 line is not covered with tests

// Create a debounced version of stopModel that waits 500ms after the last call
const debouncedStopModel = debounce((modelId: string) => {
serviceHub.models().stopModel(modelId)
}, 500)

Check warning on line 40 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

38-40 lines are not covered with tests

const handlePlanModelLoad = async () => {
if (provider.provider !== 'llamacpp') {
console.warn('planModelLoad is only available for llamacpp provider')
return
}
setIsPlanning(true)
try {

Check warning on line 48 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

42-48 lines are not covered with tests
// Read the model config to get the actual model path
const modelConfig = await serviceHub.app().readYaml<{

Check warning on line 50 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

50 line is not covered with tests
model_path: string
}>(`llamacpp/models/${model.id}/model.yml`)

Check warning on line 52 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

52 line is not covered with tests

if (modelConfig && modelConfig.model_path) {
const result = await serviceHub
.models()
.planModelLoad(modelConfig.model_path)

Check warning on line 57 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

54-57 lines are not covered with tests

// Apply the recommended settings to the model sequentially to avoid race conditions
const settingsToUpdate: Array<{

Check warning on line 60 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

60 line is not covered with tests
key: string
value: number | boolean
}> = []

Check warning on line 63 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

63 line is not covered with tests

if (model.settings?.ngl && result.gpuLayers !== undefined) {
settingsToUpdate.push({ key: 'ngl', value: result.gpuLayers })
}

Check warning on line 67 in web-app/src/containers/ModelSetting.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

65-67 lines are not covered with tests

if (model.settings?.ctx_len && result.maxContextLength !== undefined) {
settingsToUpdate.push({
Expand Down Expand Up @@ -242,11 +242,18 @@
{provider.provider === 'llamacpp' && (
<div className="pb-4 border-b border-main-view-fg/10 my-4">
<div>
<h3 className="font-medium mb-1">Optimize Settings</h3>
<p className="text-main-view-fg/70 text-xs mb-3">
Analyze your system and model, then apply optimal loading
settings automatically
</p>
<div>
<div className="flex items-center gap-2 mb-1">
<h3 className="font-medium">Optimize Settings</h3>
<div className="text-xs bg-main-view-fg/10 border border-main-view-fg/20 text-main-view-fg/70 rounded-full py-0.5 px-2">
<span>{t('mcp-servers:experimental')}</span>
</div>
</div>
<p className="text-main-view-fg/70 text-xs mb-3">
Analyze your system and model, then apply optimal loading
settings automatically
</p>
</div>
<Button
onClick={handlePlanModelLoad}
disabled={isPlanning}
Expand Down
Loading