Merge remote-tracking branch 'upstream/main' into dev

# Conflicts:
#	app/constant.ts
#	app/store/chat.ts
#	app/utils/model.ts
This commit is contained in:
sijinhui
2024-04-10 23:23:17 +08:00
7 changed files with 50 additions and 6 deletions

21
app/utils/checkers.ts Normal file
View File

@@ -0,0 +1,21 @@
import { useAccessStore } from "../store/access";
import { useAppConfig } from "../store/config";
import { collectModels } from "./model";
export function identifyDefaultClaudeModel(modelName: string) {
const accessStore = useAccessStore.getState();
const configStore = useAppConfig.getState();
const allModals = collectModels(
configStore.models,
[configStore.customModels, accessStore.customModels].join(","),
);
const modelMeta = allModals.find((m) => m.name === modelName);
return (
modelName.startsWith("claude") &&
modelMeta &&
modelMeta.provider?.providerType === "anthropic"
);
}

View File

@@ -23,6 +23,12 @@ export function collectModelTable(
};
});
const customProvider = (modelName: string) => ({
id: modelName,
providerName: "",
providerType: "custom",
});
// server custom models
customModels
.split(",")
@@ -44,7 +50,7 @@ export function collectModelTable(
displayName: displayName || name,
available,
describe: "",
provider: modelTable[name]?.provider, // Use optional chaining
provider: modelTable[name]?.provider ?? customProvider(name), // Use optional chaining
};
}
});