@raingor/pi-web-switch 0.8.0 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/server/pi-reader.ts +114 -6
- package/src/components/dashboard/DashboardPage.tsx +69 -0
- package/src/components/providers/ProvidersModelsPage.tsx +266 -108
- package/src/components/settings/SettingsPage.tsx +23 -33
- package/src/components/speedtest/ModelSpeedTestPage.tsx +138 -4
- package/src/components/subagents/SubagentsPage.tsx +30 -21
- package/src/data/changelog.ts +15 -0
- package/src/index.css +1 -2
- package/src/lib/translations/en.ts +34 -8
- package/src/lib/translations/ja.ts +34 -8
- package/src/lib/translations/zh-CN.ts +34 -8
- package/src/lib/translations/zh-TW.ts +34 -8
- package/src/store/config-store.ts +3 -1
- package/src/types/index.ts +14 -0
- package/vite.config.ts +7 -0
|
@@ -42,6 +42,8 @@ function getCustomProviders(modelsJson: PiModelsJson | null): Provider[] {
|
|
|
42
42
|
baseUrl: cfg.baseUrl,
|
|
43
43
|
api: cfg.api,
|
|
44
44
|
apiKey: cfg.apiKey,
|
|
45
|
+
apiKeys: cfg.apiKeys,
|
|
46
|
+
activeKeyId: cfg.activeKeyId,
|
|
45
47
|
authHeader: cfg.authHeader,
|
|
46
48
|
headers: cfg.headers,
|
|
47
49
|
compat: cfg.compat,
|
|
@@ -400,7 +402,7 @@ export const useConfigStore = create<ConfigState>((set, get) => ({
|
|
|
400
402
|
}
|
|
401
403
|
newProviders[providerId] = {
|
|
402
404
|
...newProviders[providerId],
|
|
403
|
-
models: [...(newProviders[providerId]!.models ?? []), { ...model, enabled:
|
|
405
|
+
models: [...(newProviders[providerId]!.models ?? []), { ...model, enabled: false }],
|
|
404
406
|
};
|
|
405
407
|
const updated = { providers: newProviders };
|
|
406
408
|
set({ modelsJson: updated });
|
package/src/types/index.ts
CHANGED
|
@@ -75,6 +75,16 @@ export interface ProviderOAuth {
|
|
|
75
75
|
name: string;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* One entry in a custom provider's API key pool. Only the key referenced by
|
|
80
|
+
* `activeKeyId` is mirrored into `apiKey`, which is the field pi itself reads.
|
|
81
|
+
*/
|
|
82
|
+
export interface ProviderApiKey {
|
|
83
|
+
id: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
key: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
export interface Provider {
|
|
79
89
|
id: string;
|
|
80
90
|
name: string;
|
|
@@ -82,6 +92,8 @@ export interface Provider {
|
|
|
82
92
|
baseUrl?: string;
|
|
83
93
|
api?: ApiType;
|
|
84
94
|
apiKey?: string;
|
|
95
|
+
apiKeys?: ProviderApiKey[];
|
|
96
|
+
activeKeyId?: string;
|
|
85
97
|
authHeader?: boolean;
|
|
86
98
|
headers?: Record<string, string>;
|
|
87
99
|
models: Model[];
|
|
@@ -121,6 +133,8 @@ export interface CustomProviderConfig {
|
|
|
121
133
|
baseUrl?: string;
|
|
122
134
|
api?: ApiType;
|
|
123
135
|
apiKey?: string;
|
|
136
|
+
apiKeys?: ProviderApiKey[];
|
|
137
|
+
activeKeyId?: string;
|
|
124
138
|
authHeader?: boolean;
|
|
125
139
|
headers?: Record<string, string>;
|
|
126
140
|
models?: Model[];
|
package/vite.config.ts
CHANGED
|
@@ -49,6 +49,13 @@ function piApiPlugin(): Plugin {
|
|
|
49
49
|
res.setHeader("Content-Type", "application/json");
|
|
50
50
|
res.end(JSON.stringify(data ?? {}));
|
|
51
51
|
},
|
|
52
|
+
"GET /api/pi/codex-usage-status"(req, res) {
|
|
53
|
+
const force = new URL(req.url ?? "", "http://localhost").searchParams.get("refresh") === "1";
|
|
54
|
+
pi.getCodexUsageStatus(force).then((status) => {
|
|
55
|
+
res.setHeader("Content-Type", "application/json");
|
|
56
|
+
res.end(JSON.stringify(status));
|
|
57
|
+
});
|
|
58
|
+
},
|
|
52
59
|
"GET /api/pi/official-usage-config"(_, res) {
|
|
53
60
|
const config = pi.readOfficialUsageConfig();
|
|
54
61
|
res.setHeader("Content-Type", "application/json");
|