Add new provider OpenRouter

This commit is contained in:
wyfyjc
2025-03-02 14:36:16 +08:00
parent f7cde17919
commit 636b234079
13 changed files with 550 additions and 2 deletions

View File

@@ -64,11 +64,17 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) {
LlmIcon = BotIconGemini;
} else if (modelName.startsWith("gemma")) {
LlmIcon = BotIconGemma;
} else if (modelName.startsWith("claude")) {
} else if (
modelName.startsWith("claude") ||
modelName.startsWith("anthropic")
) {
LlmIcon = BotIconClaude;
} else if (modelName.includes("llama")) {
LlmIcon = BotIconMeta;
} else if (modelName.startsWith("mixtral") || modelName.startsWith("codestral")) {
} else if (
modelName.startsWith("mixtral") ||
modelName.startsWith("codestral")
) {
LlmIcon = BotIconMistral;
} else if (modelName.includes("deepseek")) {
LlmIcon = BotIconDeepseek;

View File

@@ -75,6 +75,7 @@ import {
ChatGLM,
DeepSeek,
SiliconFlow,
OpenRouter,
} from "../constant";
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
import { ErrorBoundary } from "./error";
@@ -1458,6 +1459,48 @@ export function Settings() {
</>
);
const openRouterConfigComponent = accessStore.provider ===
ServiceProvider.OpenRouter && (
<>
<ListItem
title={Locale.Settings.Access.OpenRouter.Endpoint.Title}
subTitle={
Locale.Settings.Access.OpenRouter.Endpoint.SubTitle +
OpenRouter.ExampleEndpoint
}
>
<input
aria-label={Locale.Settings.Access.OpenRouter.Endpoint.Title}
type="text"
value={accessStore.openrouterUrl}
placeholder={OpenRouter.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.openrouterUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.OpenRouter.ApiKey.Title}
subTitle={Locale.Settings.Access.OpenRouter.ApiKey.SubTitle}
>
<PasswordInput
aria={Locale.Settings.ShowPassword}
aria-label={Locale.Settings.Access.OpenRouter.ApiKey.Title}
value={accessStore.openrouterApiKey}
type="text"
placeholder={Locale.Settings.Access.OpenRouter.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.openrouterApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);
return (
<ErrorBoundary>
<div className="window-header" data-tauri-drag-region>
@@ -1822,6 +1865,7 @@ export function Settings() {
{XAIConfigComponent}
{chatglmConfigComponent}
{siliconflowConfigComponent}
{openRouterConfigComponent}
</>
)}
</>