Skip to content

Commit

Permalink
fix: 修复没有正确处理选择模型时分割 name/provider 的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
rxliuli committed Aug 26, 2024
1 parent 4d8047d commit e42cdd0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/components/model-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import { InputRange } from "./input-range";
import { ListItem, Select } from "./ui-lib";
import { useAllModels } from "../utils/hooks";

function getModelName(model: { model: string; providerName: string }) {
return `${model.model}----${model.providerName}`;
}

export function ModelConfigList(props: {
modelConfig: ModelConfig;
updateConfig: (updater: (config: ModelConfig) => void) => void;
}) {
const allModels = useAllModels();
const value = `${props.modelConfig.model}@${props.modelConfig?.providerName}`;
const value = getModelName(props.modelConfig);

return (
<>
Expand All @@ -20,7 +24,7 @@ export function ModelConfigList(props: {
aria-label={Locale.Settings.Model}
value={value}
onChange={(e) => {
const [model, providerName] = e.currentTarget.value.split("@");
const [model, providerName] = e.currentTarget.value.split("----");
props.updateConfig((config) => {
config.model = ModalConfigValidator.model(model);
config.providerName = providerName as ServiceProvider;
Expand All @@ -30,7 +34,13 @@ export function ModelConfigList(props: {
{allModels
.filter((v) => v.available)
.map((v, i) => (
<option value={`${v.name}@${v.provider?.providerName}`} key={i}>
<option
value={getModelName({
model: v.name,
providerName: v.provider?.providerName!,
})}
key={i}
>
{v.displayName}({v.provider?.providerName})
</option>
))}
Expand Down

0 comments on commit e42cdd0

Please sign in to comment.