Skip to content

Commit

Permalink
Merge pull request #4986 from ConnectAI-E/hotfix/cf-ai-gateway
Browse files Browse the repository at this point in the history
hotfix: using custom models, create custom provider
  • Loading branch information
LiuElric authored Jul 12, 2024
2 parents e8088d6 + 9203870 commit 4ea8c08
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/utils/model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DEFAULT_MODELS } from "../constant";
import { LLMModel } from "../client/api";

const customProvider = (modelName: string) => ({
id: modelName,
providerName: "Custom",
const customProvider = (providerName: string) => ({
id: providerName.toLowerCase(),
providerName: providerName,
providerType: "custom",
});

Expand Down Expand Up @@ -71,10 +71,13 @@ export function collectModelTable(
}
// 2. if model not exists, create new model with available value
if (count === 0) {
const provider = customProvider(name);
modelTable[`${name}@${provider?.id}`] = {
name,
displayName: displayName || name,
const [customModelName, customProviderName] = name.split("@");
const provider = customProvider(
customProviderName || customModelName,
);
modelTable[`${customModelName}@${provider?.id}`] = {
name: customModelName,
displayName: displayName || customModelName,
available,
provider, // Use optional chaining
};
Expand Down

0 comments on commit 4ea8c08

Please sign in to comment.