File size: 7,693 Bytes
1425cf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'
import { Slider } from '@/components/ui/slider'
import { Label } from '@/components/ui/label'
import { Badge } from '@/components/ui/badge'
import { 
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/select'
import { Cloud, Brain, Zap } from 'lucide-react'

interface ModelInfo {
  model_name: string
  name: string
  supports_thinking: boolean
  description: string
  size_gb: string
  is_loaded: boolean
  type: 'local' | 'api'
}

interface ModelParametersTabProps {
  models: ModelInfo[]
  selectedModel: string | null
  setSelectedModel: (model: string) => void
  autoLoadingModel: string | null
  temperature: number
  setTemperature: (temp: number) => void
  maxTokens: number
  setMaxTokens: (tokens: number) => void
}

export function ModelParametersTab({
  models,
  selectedModel,
  setSelectedModel,
  autoLoadingModel,
  temperature,
  setTemperature,
  maxTokens,
  setMaxTokens
}: ModelParametersTabProps) {
  return (
    <>
      {/* Model Selection */}
      <Card>
        <CardHeader>
          <CardTitle className="text-base">Model</CardTitle>
        </CardHeader>
        <CardContent className="space-y-4">
          <div>
            <Select value={selectedModel || ""} onValueChange={setSelectedModel}>
              <SelectTrigger className="w-full">
                <SelectValue placeholder="Select a model...">
                  {selectedModel && (() => {
                    const model = models.find(m => m.model_name === selectedModel)
                    if (!model) return selectedModel
                    const isApiModel = model.type === 'api'
                    return (
                      <div className="flex items-center gap-2">
                        {isApiModel ? (
                          <Cloud className="h-4 w-4 text-blue-500" />
                        ) : model.supports_thinking ? (
                          <Brain className="h-4 w-4 text-purple-500" />
                        ) : (
                          <Zap className="h-4 w-4 text-green-500" />
                        )}
                        <span className="truncate">{model.name}</span>
                        {autoLoadingModel === selectedModel ? (
                          <Badge variant="outline" className="text-xs">
                            Loading...
                          </Badge>
                        ) : (
                          <Badge variant="outline" className="text-xs">
                            {isApiModel ? "API" : model.is_loaded ? "Loaded" : "Available"}
                          </Badge>
                        )}
                      </div>
                    )
                  })()}
                </SelectValue>
              </SelectTrigger>
              <SelectContent>
                <SelectGroup>
                  <SelectLabel>🌐 API Models</SelectLabel>
                  {models.filter(m => m.type === 'api').map((model) => (
                    <SelectItem key={model.model_name} value={model.model_name}>
                      <div className="flex items-center gap-2">
                        <Cloud className="h-4 w-4 text-blue-500" />
                        <span>{model.name}</span>
                        <Badge variant="outline" className="text-xs bg-blue-50">API</Badge>
                      </div>
                    </SelectItem>
                  ))}
                </SelectGroup>
                <SelectGroup>
                  <SelectLabel>πŸ’» Local Models</SelectLabel>
                  {models.filter(m => m.type === 'local').map((model) => (
                    <SelectItem key={model.model_name} value={model.model_name}>
                      <div className="flex items-center gap-2">
                        {model.supports_thinking ? (
                          <Brain className="h-4 w-4 text-purple-500" />
                        ) : (
                          <Zap className="h-4 w-4 text-green-500" />
                        )}
                        <span>{model.name}</span>
                        {autoLoadingModel === model.model_name ? (
                          <Badge variant="outline" className="text-xs bg-yellow-50">Loading...</Badge>
                        ) : model.is_loaded ? (
                          <Badge variant="outline" className="text-xs bg-green-50">Loaded</Badge>
                        ) : (
                          <Badge variant="outline" className="text-xs bg-gray-50">Available</Badge>
                        )}
                      </div>
                    </SelectItem>
                  ))}
                </SelectGroup>
              </SelectContent>
            </Select>
          </div>
        </CardContent>
      </Card>

      {/* Generation Parameters */}
      <Card>
        <CardHeader>
          <CardTitle className="text-base">Parameters</CardTitle>
        </CardHeader>
        <CardContent className="space-y-6">
          {/* Temperature Slider */}
          <div>
            <div className="flex items-center justify-between mb-3">
              <Label className="text-sm font-medium">Temperature</Label>
              <Badge variant="outline" className="text-xs">
                {temperature}
              </Badge>
            </div>
            <Slider
              value={[temperature]}
              onValueChange={(value) => setTemperature(value[0])}
              max={2}
              min={0}
              step={0.1}
              className="w-full mb-3"
            />
            <div className="flex justify-between text-xs text-gray-500 mb-2">
              <span>0.0 (Focused)</span>
              <span>1.0 (Balanced)</span>
              <span>2.0 (Creative)</span>
            </div>
            <div className="text-xs text-muted-foreground bg-gray-50 p-2 rounded">
              {temperature <= 0.3 
                ? "🎯 Very focused and deterministic responses"
                : temperature <= 0.7 
                  ? "βš–οΈ Balanced creativity and consistency"
                  : temperature <= 1.2
                    ? "🎨 More creative and varied responses"
                    : "πŸš€ Highly creative, unpredictable responses"
              }
            </div>
          </div>

          {/* Max Tokens Slider */}
          <div>
            <div className="flex items-center justify-between mb-3">
              <Label className="text-sm font-medium">Max Tokens</Label>
              <Badge variant="outline" className="text-xs">
                {maxTokens}
              </Badge>
            </div>
            <Slider
              value={[maxTokens]}
              onValueChange={(value) => setMaxTokens(value[0])}
              max={4000}
              min={50}
              step={50}
              className="w-full mb-3"
            />
            <div className="flex justify-between text-xs text-gray-500 mb-2">
              <span>50 (Short)</span>
              <span>1024 (Medium)</span>
              <span>4000 (Long)</span>
            </div>
            <div className="text-xs text-muted-foreground bg-gray-50 p-2 rounded">
              {maxTokens <= 200 
                ? "πŸ“ Brief responses, good for quick answers"
                : maxTokens <= 1000 
                  ? "πŸ“„ Medium responses, balanced length"
                  : maxTokens <= 2000
                    ? "πŸ“‹ Long responses, detailed explanations"
                    : "πŸ“š Very long responses, comprehensive content"
              }
            </div>
          </div>
        </CardContent>
      </Card>
    </>
  )
}