Add protocol selection to Claude and Codex provider forms referencing CCSwitch
This commit is contained in:
1 parent
bae24cc439
commit
16957decb2
14 files changed
+274
-25
No files matched your search
@@ -48,6 +48,8 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
export interface ProviderInput {
|
||||
name: string;
|
||||
preset?: string;
|
||||
protocol?: string;
|
||||
api_format?: string;
|
||||
base_url: string;
|
||||
api_key: string;
|
||||
models: Models;
|
||||
|
||||
@@ -6,6 +6,19 @@ export interface Models {
|
||||
extra?: Record<string, string>;
|
||||
}
|
||||
|
||||
export type ClaudeProtocol =
|
||||
| "anthropic"
|
||||
| "openai_chat"
|
||||
| "openai_responses"
|
||||
| "gemini_native";
|
||||
|
||||
export type CodexProtocol =
|
||||
| "openai_responses"
|
||||
| "openai_chat"
|
||||
| "anthropic";
|
||||
|
||||
export type ProviderProtocol = ClaudeProtocol | CodexProtocol;
|
||||
|
||||
export interface Provider {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -13,6 +26,8 @@ export interface Provider {
|
||||
base_url: string;
|
||||
api_key: string;
|
||||
models: Models;
|
||||
protocol?: string;
|
||||
api_format?: string;
|
||||
enabled_for_claude: boolean;
|
||||
enabled_for_codex: boolean;
|
||||
target: "claude" | "codex";
|
||||
@@ -31,6 +46,7 @@ export interface ActiveProvider {
|
||||
name: string;
|
||||
base_url: string;
|
||||
models: Models;
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
export interface Status {
|
||||
@@ -91,6 +107,7 @@ export interface Injection {
|
||||
export interface Preset {
|
||||
key: string;
|
||||
base_url: string;
|
||||
protocol?: string;
|
||||
models: Models;
|
||||
}
|
||||
|
||||
@@ -100,6 +117,7 @@ export const PRESETS: Preset[] = [
|
||||
{
|
||||
key: "deepseek",
|
||||
base_url: "https://api.deepseek.com/v1",
|
||||
protocol: "openai_chat",
|
||||
models: withCodexExtras({
|
||||
default: "deepseek-chat",
|
||||
sonnet: "deepseek-chat",
|
||||
@@ -110,6 +128,7 @@ export const PRESETS: Preset[] = [
|
||||
{
|
||||
key: "moonshot",
|
||||
base_url: "https://api.moonshot.cn/v1",
|
||||
protocol: "openai_chat",
|
||||
models: withCodexExtras(
|
||||
{
|
||||
default: "kimi-k2-0905-preview",
|
||||
@@ -123,6 +142,7 @@ export const PRESETS: Preset[] = [
|
||||
{
|
||||
key: "zhipu",
|
||||
base_url: "https://open.bigmodel.cn/api/paas/v4",
|
||||
protocol: "openai_chat",
|
||||
models: withCodexExtras(
|
||||
{
|
||||
default: "glm-4.6",
|
||||
|
||||
@@ -4,3 +4,18 @@ import { twMerge } from "tailwind-merge";
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export function formatProtocolBadge(protocol?: string): string {
|
||||
switch (protocol) {
|
||||
case "anthropic":
|
||||
return "Anthropic";
|
||||
case "openai_chat":
|
||||
return "Chat";
|
||||
case "openai_responses":
|
||||
return "Responses";
|
||||
case "gemini_native":
|
||||
return "Gemini";
|
||||
default:
|
||||
return protocol ?? "";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user