@miphamai/cli 0.30.0 → 0.31.0

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/src/ui/picker.tsx CHANGED
@@ -8,6 +8,7 @@ interface PickerProps {
8
8
  currentProvider: string
9
9
  currentModel: string
10
10
  onSelect: (providerId: string, modelId: string) => void
11
+ onNeedsApiKey?: (providerId: string, modelId: string, providerName: string) => void
11
12
  onClose: () => void
12
13
  }
13
14
 
@@ -18,6 +19,7 @@ export function ModelPicker({
18
19
  currentProvider,
19
20
  currentModel,
20
21
  onSelect,
22
+ onNeedsApiKey,
21
23
  onClose,
22
24
  }: PickerProps) {
23
25
  const { t } = useI18n()
@@ -60,9 +62,17 @@ export function ModelPicker({
60
62
  if (!selectedProvider) return
61
63
  const model = models[modelIdx]
62
64
  if (model) {
65
+ // Check API key before confirming switch
66
+ const apiKey = selectedProvider.apiKey
67
+ if (!apiKey || apiKey.trim() === '' || /^\$\{[A-Z_]+\}$/.test(apiKey.trim())) {
68
+ if (selectedProvider.id !== 'ollama' && onNeedsApiKey) {
69
+ onNeedsApiKey(selectedProvider.id, model.id, selectedProvider.name)
70
+ return
71
+ }
72
+ }
63
73
  onSelect(selectedProvider.id, model.id)
64
74
  }
65
- }, [selectedProvider, models, modelIdx, onSelect])
75
+ }, [selectedProvider, models, modelIdx, onSelect, onNeedsApiKey])
66
76
 
67
77
  useInput((input, key) => {
68
78
  // Global keys