-
-
Notifications
You must be signed in to change notification settings - Fork 80.9k
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (45 loc) · 1.45 KB
/
Copy pathindex.ts
File metadata and controls
47 lines (45 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
import { PROVIDER_LABELS } from "openclaw/plugin-sdk/provider-usage";
import { applyXiaomiConfig, XIAOMI_DEFAULT_MODEL_REF } from "./onboard.js";
import { buildXiaomiProvider } from "./provider-catalog.js";
import { buildXiaomiSpeechProvider } from "./speech-provider.js";
const PROVIDER_ID = "xiaomi";
export default defineSingleProviderPluginEntry({
id: PROVIDER_ID,
name: "Xiaomi Provider",
description: "Bundled Xiaomi provider plugin",
provider: {
label: "Xiaomi",
docsPath: "/providers/xiaomi",
auth: [
{
methodId: "api-key",
label: "Xiaomi API key",
hint: "API key",
optionKey: "xiaomiApiKey",
flagName: "--xiaomi-api-key",
envVar: "XIAOMI_API_KEY",
promptMessage: "Enter Xiaomi API key",
defaultModel: XIAOMI_DEFAULT_MODEL_REF,
applyConfig: (cfg) => applyXiaomiConfig(cfg),
},
],
catalog: {
buildProvider: buildXiaomiProvider,
},
resolveUsageAuth: async (ctx) => {
const apiKey = ctx.resolveApiKeyFromConfigAndStore({
envDirect: [ctx.env.XIAOMI_API_KEY],
});
return apiKey ? { token: apiKey } : null;
},
fetchUsageSnapshot: async () => ({
provider: "xiaomi",
displayName: PROVIDER_LABELS.xiaomi,
windows: [],
}),
},
register(api) {
api.registerSpeechProvider(buildXiaomiSpeechProvider());
},
});