-
Notifications
You must be signed in to change notification settings - Fork 60.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Solve the problem of using openai interface protocol for user-d… #4480
Conversation
…efined claude model & add some famous webdav endpoints
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Your build has completed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just letting you know
@@ -173,7 +174,7 @@ export function useLoadData() { | |||
var api: ClientApi; | |||
if (config.modelConfig.model.startsWith("gemini")) { | |||
api = new ClientApi(ModelProvider.GeminiPro); | |||
} else if (config.modelConfig.model.startsWith("claude")) { | |||
} else if (identifyDefaultClaudeModel(config.modelConfig.model)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way you can simplicity it by using this method
remove this
var api: ClientApi;
if (config.modelConfig.model.startsWith("gemini")) {
api = new ClientApi(ModelProvider.GeminiPro);
} else if (identifyDefaultClaudeModel(config.modelConfig.model)) {
api = new ClientApi(ModelProvider.Claude);
} else {
api = new ClientApi(ModelProvider.GPT);
}
then replace with this
const modelProviderMap: Record<string, ModelProvider> = {
gemini: ModelProvider.GeminiPro,
claude: ModelProvider.Claude,
};
const defaultModelProvider = ModelProvider.GPT;
const modelPrefix = config.modelConfig.model.split("-")[0];
const api = new ClientApi(
modelProviderMap[modelPrefix] || identifyDefaultClaudeModel(config.modelConfig.model)
? ModelProvider.Claude
: defaultModelProvider
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some users invoke the claude model using openai's interface protocol, possibly with a proxy service in between, so the problem I'm actually trying to solve with this code is: Only the default claude model provided by our system (marked anthropic on the corresponding provider) can use the anthropic interface protocol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, semantically, this code of yours does not solve the problem,but, you mentioned a very important point, that is the importance of "provider", next, the entity relationships will be sorted out, refactoring the logic, making it easier for the application to extend the new model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, semantically, this code of yours does not solve the problem,but, you mentioned a very important point, that is the importance of "provider", next, the entity relationships will be sorted out, refactoring the logic, making it easier for the application to extend the new model
it's looks bad so many if else if else statement, can't imagine if there is lot's of service provider
var api: ClientApi;
if (config.modelConfig.model.startsWith("gemini")) {
api = new ClientApi(ModelProvider.GeminiPro);
} else if (identifyDefaultClaudeModel(config.modelConfig.model)) {
api = new ClientApi(ModelProvider.Claude);
} else {
api = new ClientApi(ModelProvider.GPT);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this one as well
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"
);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, semantically, this code of yours does not solve the problem,but, you mentioned a very important point, that is the importance of "provider", next, the entity relationships will be sorted out, refactoring the logic, making it easier for the application to extend the new model
I think you can judge which protocol to use based on the secret key of the AI model, because the secret key formats of different models are different.
feat: Solve the problem of using openai interface protocol for user-d…
…efined claude model & add some famous webdav endpoints