@phi-code-admin/phi-code 0.62.0 → 0.62.1
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.
|
@@ -80,13 +80,29 @@ export default function smartRouterExtension(pi: ExtensionAPI) {
|
|
|
80
80
|
const recommendation = router.getRecommendation(event.text);
|
|
81
81
|
|
|
82
82
|
if (recommendation.category !== "general") {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
// Find the recommended model in the registry
|
|
84
|
+
const available = ctx.modelRegistry?.getAvailable?.() || [];
|
|
85
|
+
const targetModel = available.find((m: any) => m.id === recommendation.model);
|
|
86
|
+
const fallbackRoute = (router as any).config?.routes?.[recommendation.category];
|
|
87
|
+
const fallbackModel = fallbackRoute?.fallback
|
|
88
|
+
? available.find((m: any) => m.id === fallbackRoute.fallback)
|
|
89
|
+
: undefined;
|
|
90
|
+
|
|
91
|
+
const modelToUse = targetModel || fallbackModel;
|
|
92
|
+
|
|
93
|
+
if (modelToUse && modelToUse.id !== ctx.model?.id) {
|
|
94
|
+
// Actually switch the model
|
|
95
|
+
const switched = await pi.setModel(modelToUse);
|
|
96
|
+
if (switched && extConfig.notifyOnRecommendation) {
|
|
97
|
+
ctx.ui.notify(
|
|
98
|
+
`🔀 ${recommendation.category} → \`${modelToUse.id}\`${modelToUse.id !== recommendation.model ? ` (fallback)` : ""}`,
|
|
99
|
+
"info"
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
} else if (extConfig.notifyOnRecommendation && !modelToUse) {
|
|
103
|
+
// Model not available — just notify
|
|
88
104
|
ctx.ui.notify(
|
|
89
|
-
`🔀 ${recommendation.category} → \`${recommendation.model}
|
|
105
|
+
`🔀 ${recommendation.category} → \`${recommendation.model}\` (not available, keeping current)`,
|
|
90
106
|
"info"
|
|
91
107
|
);
|
|
92
108
|
}
|