@nick848/sf-cli 1.0.15 → 1.0.16
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/cli/index.js +613 -643
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7601,25 +7601,21 @@ ${chalk9__default.default.yellow("\u793A\u4F8B:")}
|
|
|
7601
7601
|
|
|
7602
7602
|
// src/commands/model.ts
|
|
7603
7603
|
init_cjs_shims();
|
|
7604
|
-
|
|
7605
|
-
// src/services/index.ts
|
|
7606
|
-
init_cjs_shims();
|
|
7607
|
-
|
|
7608
|
-
// src/commands/model.ts
|
|
7609
7604
|
async function handleModel(args, ctx) {
|
|
7610
7605
|
const subCommand = args[0];
|
|
7611
7606
|
const configManager = ctx.configManager;
|
|
7607
|
+
const modelService = ctx.modelService;
|
|
7612
7608
|
switch (subCommand) {
|
|
7613
7609
|
case "list":
|
|
7614
7610
|
return listModels();
|
|
7615
7611
|
case "current":
|
|
7616
7612
|
return showCurrentModel(configManager);
|
|
7617
7613
|
case "set":
|
|
7618
|
-
return setModelDirectly(args[1], configManager);
|
|
7614
|
+
return setModelDirectly(args[1], configManager, modelService);
|
|
7619
7615
|
case "verify":
|
|
7620
7616
|
return verifyCurrentModel(configManager);
|
|
7621
7617
|
default:
|
|
7622
|
-
return selectModel(configManager);
|
|
7618
|
+
return selectModel(configManager, modelService);
|
|
7623
7619
|
}
|
|
7624
7620
|
}
|
|
7625
7621
|
async function listModels() {
|
|
@@ -7660,7 +7656,7 @@ async function showCurrentModel(configManager) {
|
|
|
7660
7656
|
];
|
|
7661
7657
|
return { output: lines.join("\n") };
|
|
7662
7658
|
}
|
|
7663
|
-
async function setModelDirectly(modelId, configManager) {
|
|
7659
|
+
async function setModelDirectly(modelId, configManager, modelService) {
|
|
7664
7660
|
if (!modelId) {
|
|
7665
7661
|
return {
|
|
7666
7662
|
output: chalk9__default.default.red("\u8BF7\u6307\u5B9A\u6A21\u578BID\uFF0C\u4F8B\u5982: /model set gpt-4o")
|
|
@@ -7675,11 +7671,22 @@ async function setModelDirectly(modelId, configManager) {
|
|
|
7675
7671
|
}
|
|
7676
7672
|
configManager.set("model", modelId);
|
|
7677
7673
|
await configManager.save();
|
|
7674
|
+
const apiKey = configManager.get("apiKey");
|
|
7675
|
+
if (apiKey) {
|
|
7676
|
+
try {
|
|
7677
|
+
await modelService.configureModel({
|
|
7678
|
+
provider: modelInfo.provider,
|
|
7679
|
+
model: modelId,
|
|
7680
|
+
apiKey
|
|
7681
|
+
});
|
|
7682
|
+
} catch {
|
|
7683
|
+
}
|
|
7684
|
+
}
|
|
7678
7685
|
return {
|
|
7679
7686
|
output: chalk9__default.default.green(`\u2713 \u5DF2\u5207\u6362\u5230\u6A21\u578B: ${modelInfo.name} (${modelInfo.provider})`)
|
|
7680
7687
|
};
|
|
7681
7688
|
}
|
|
7682
|
-
async function verifyCurrentModel(configManager) {
|
|
7689
|
+
async function verifyCurrentModel(configManager, modelService) {
|
|
7683
7690
|
const currentModel = configManager.get("model");
|
|
7684
7691
|
const apiKey = configManager.get("apiKey");
|
|
7685
7692
|
if (!apiKey) {
|
|
@@ -7712,7 +7719,7 @@ async function verifyCurrentModel(configManager) {
|
|
|
7712
7719
|
};
|
|
7713
7720
|
}
|
|
7714
7721
|
}
|
|
7715
|
-
async function selectModel(configManager) {
|
|
7722
|
+
async function selectModel(configManager, modelService) {
|
|
7716
7723
|
try {
|
|
7717
7724
|
const currentModel = configManager.get("model");
|
|
7718
7725
|
const currentApiKey = configManager.get("apiKey");
|
|
@@ -7776,6 +7783,11 @@ async function selectModel(configManager) {
|
|
|
7776
7783
|
configManager.set("model", modelResponse.model);
|
|
7777
7784
|
configManager.set("apiKey", apiKeyResponse.apiKey);
|
|
7778
7785
|
await configManager.save();
|
|
7786
|
+
await modelService.configureModel({
|
|
7787
|
+
provider: selectedModel.provider,
|
|
7788
|
+
model: modelResponse.model,
|
|
7789
|
+
apiKey: apiKeyResponse.apiKey
|
|
7790
|
+
});
|
|
7779
7791
|
return {
|
|
7780
7792
|
output: chalk9__default.default.green(`
|
|
7781
7793
|
\u2713 \u6A21\u578B\u914D\u7F6E\u5B8C\u6210
|