Skip to content

Commit e289b61

Browse files
committed
fix: remove useAllModels()
1 parent d6f8321 commit e289b61

File tree

5 files changed

+11
-35
lines changed

5 files changed

+11
-35
lines changed

app/client/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export interface ModelRecord {
5858
size?: string;
5959
quantization?: string;
6060
context_length?: string;
61-
is_default?: boolean;
6261
family?: string;
6362
vram_required_MB?: number;
6463
buffer_size_required_bytes?: number;

app/components/chat.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import { ContextPrompts, TemplateAvatar, TemplateConfig } from "./template";
9191
import { ChatCommandPrefix, useChatCommand, useCommand } from "../command";
9292
import { prettyObject } from "../utils/format";
9393
import { ExportMessageModal } from "./exporter";
94-
import { useAllModels } from "../utils/hooks";
9594
import { MultimodalContent } from "../client/api";
9695
import { WebLLMContext } from "../client/webllm";
9796
import { Template, useTemplateStore } from "../store/template";
@@ -494,20 +493,7 @@ export function ChatActions(props: {
494493

495494
// switch model
496495
const currentModel = config.modelConfig.model;
497-
const allModels = useAllModels();
498-
const models = useMemo(() => {
499-
const defaultModel = allModels.find((m) => m.is_default);
500-
501-
if (defaultModel) {
502-
const arr = [
503-
defaultModel,
504-
...allModels.filter((m) => m !== defaultModel),
505-
];
506-
return arr;
507-
} else {
508-
return allModels;
509-
}
510-
}, [allModels]);
496+
const models = config.models;
511497
const [showModelSelector, setShowModelSelector] = useState(false);
512498
const [showUploadImage, setShowUploadImage] = useState(false);
513499

app/components/model-config.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
import { ModalConfigValidator, ModelConfig, ModelType } from "../store";
1+
import {
2+
ModalConfigValidator,
3+
ModelConfig,
4+
ModelType,
5+
useAppConfig,
6+
} from "../store";
27

38
import Locale from "../locales";
49
import { InputRange } from "./input-range";
510
import { ListItem, Select } from "./ui-lib";
6-
import { useAllModels } from "../utils/hooks";
711
import React from "react";
812

913
export function ModelConfigList(props: {
1014
modelConfig: ModelConfig;
1115
selectModel: (model: ModelType) => void;
1216
updateConfig: (updater: (config: ModelConfig) => void) => void;
1317
}) {
14-
const allModels = useAllModels();
18+
const config = useAppConfig();
19+
const models = config.models;
1520

1621
return (
1722
<>
@@ -22,9 +27,9 @@ export function ModelConfigList(props: {
2227
props.selectModel(e.target.value);
2328
}}
2429
>
25-
{allModels.map((v, i) => (
30+
{models.map((v, i) => (
2631
<React.Fragment key={i}>
27-
{i > 0 && v.family !== allModels[i - 1].family && <hr />}
32+
{i > 0 && v.family !== models[i - 1].family && <hr />}
2833
<option value={v.name}>
2934
{v.name}
3035
{v.provider ? ` (${v.provider})` : ""}

app/store/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const DEFAULT_CONFIG = {
4747

4848
cacheType: "cache" as CacheType,
4949
logLevel: "INFO" as LogLevel,
50-
customModels: "",
5150
models: DEFAULT_MODELS as any as ModelRecord[],
5251

5352
modelConfig: {

app/utils/hooks.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)