File size: 24,944 Bytes
48850f1
27615c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
27615c9
 
 
 
 
 
 
 
759f89f
 
bd13e9f
27615c9
 
 
 
bd13e9f
 
759f89f
27615c9
 
759f89f
27615c9
 
759f89f
 
27615c9
 
 
 
 
 
bd13e9f
27615c9
 
 
 
759f89f
48850f1
 
 
 
 
 
 
 
3db2966
 
27615c9
3db2966
27615c9
3db2966
27615c9
 
3db2966
 
27615c9
 
 
 
 
3db2966
27615c9
 
 
 
 
3db2966
 
27615c9
 
 
 
3db2966
27615c9
3db2966
27615c9
3db2966
 
 
 
 
 
 
27615c9
 
 
3db2966
27615c9
 
 
 
 
3db2966
 
 
 
27615c9
 
3db2966
 
27615c9
3db2966
2f1da60
 
27615c9
2f1da60
27615c9
 
2f1da60
27615c9
2f1da60
759f89f
 
 
 
 
 
 
 
 
 
 
27615c9
 
759f89f
27615c9
 
759f89f
48850f1
 
 
 
 
759f89f
 
27615c9
 
 
 
 
 
 
 
 
 
 
759f89f
 
 
 
27615c9
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
 
 
27615c9
 
 
 
 
759f89f
27615c9
759f89f
27615c9
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
 
 
27615c9
 
 
 
 
759f89f
 
 
27615c9
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
9d6c22c
759f89f
27615c9
759f89f
 
 
 
 
 
 
 
27615c9
759f89f
 
 
 
 
 
 
27615c9
 
 
 
 
 
 
759f89f
3db2966
759f89f
 
3db2966
 
 
 
 
 
 
759f89f
 
3db2966
 
27615c9
3db2966
759f89f
 
 
 
 
 
 
 
 
27615c9
759f89f
 
27615c9
 
 
 
 
 
 
 
759f89f
 
 
 
 
27615c9
 
 
 
 
 
 
 
 
759f89f
 
 
 
 
 
 
 
 
 
 
27615c9
 
 
 
 
 
759f89f
 
 
 
 
 
 
 
 
27615c9
 
 
759f89f
 
 
27615c9
 
 
 
 
 
759f89f
 
 
 
 
 
 
 
 
27615c9
759f89f
 
27615c9
 
759f89f
 
 
27615c9
 
 
759f89f
 
 
 
 
 
 
 
 
 
27615c9
 
 
759f89f
 
 
 
 
 
 
 
 
 
27615c9
 
 
 
 
 
759f89f
 
 
 
 
 
bd13e9f
759f89f
27615c9
 
 
bd13e9f
 
 
 
 
 
 
759f89f
 
 
27615c9
 
759f89f
27615c9
 
 
 
 
759f89f
 
 
 
 
 
27615c9
759f89f
 
 
8ac864c
759f89f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27615c9
 
 
 
 
 
 
 
759f89f
 
 
27615c9
48850f1
759f89f
 
 
27615c9
 
 
 
 
 
759f89f
 
 
 
 
 
27615c9
 
 
759f89f
 
 
27615c9
 
 
759f89f
 
 
 
 
 
 
 
 
 
 
 
27615c9
 
 
 
 
 
 
 
759f89f
 
 
 
48850f1
759f89f
 
 
 
 
 
 
 
 
27615c9
 
759f89f
27615c9
 
 
 
759f89f
 
 
 
27615c9
759f89f
 
27615c9
 
 
 
759f89f
 
 
 
 
 
 
 
 
 
 
 
 
4c642a2
27615c9
759f89f
 
27615c9
 
759f89f
 
9d6c22c
759f89f
 
 
27615c9
759f89f
 
 
 
 
 
27615c9
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
27615c9
 
 
759f89f
27615c9
 
759f89f
 
 
 
 
 
 
27615c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
27615c9
759f89f
 
27615c9
 
 
 
 
 
 
 
 
 
 
 
759f89f
 
27615c9
 
759f89f
 
 
 
 
 
 
9d6c22c
759f89f
27615c9
 
 
 
 
759f89f
 
 
 
 
27615c9
759f89f
 
 
 
 
 
8d2dad2
759f89f
27615c9
 
 
8d2dad2
759f89f
27615c9
 
759f89f
 
 
 
27615c9
 
759f89f
 
 
 
27615c9
 
759f89f
 
 
 
27615c9
 
759f89f
 
 
 
27615c9
759f89f
 
 
 
 
 
 
 
 
 
27615c9
759f89f
 
 
 
 
27615c9
759f89f
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
import { useState, useEffect, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
import { Slider } from "@/components/ui/slider";
import { Badge } from "@/components/ui/badge";
import { ASSISTANT_CONFIGS } from "@/config/assistants";
import { useChat } from "@/hooks/useChat";
import { DocumentsTab } from "@/components/playground/DocumentsTab";

interface DeviceConfig {
  assistantId: string;
  model: string;
  temperature: number;
  maxTokens: number;
  role: string;
  goal: string;
  description: string;
  document: string;
}

interface SelectedAssistant {
  id: string;
  name: string;
  type: "user" | "template" | "new";
  originalTemplate?: string;
}

export function MyDevice() {
  const navigate = useNavigate();
  const [currentStep, setCurrentStep] = useState(1);
  const [deviceConfig, setDeviceConfig] = useState<DeviceConfig>({
    assistantId: "",
    model: "Qwen/Qwen3-30B-A3B",
    temperature: 0.7,
    maxTokens: 1024,
    role: "",
    goal: "",
    description: "",
    document: "",
  });

  // RAG document state
  const [ragEnabled, setRagEnabled] = useState(false);
  const [retrievalCount, setRetrievalCount] = useState(3);
  const [currentAssistant, setCurrentAssistant] =
    useState<SelectedAssistant | null>(null);

  // Ref for auto-scrolling
  const messagesEndRef = useRef<HTMLDivElement>(null);

  // Auto-scroll to bottom when messages change
  const scrollToBottom = () => {
    messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
  };

  // Load assistant configuration when selected
  const handleAssistantSelect = (assistantId: string) => {
    if (assistantId === "create-new") {
      // Reset to blank configuration for new assistant
      setDeviceConfig((prev) => ({
        ...prev,
        assistantId: "create-new",
        model: "Qwen/Qwen3-30B-A3B",
        temperature: 0.7,
        maxTokens: 1024,
        role: "",
        goal: "",
        description: "",
      }));

      // Reset chat settings
      setSelectedModel("Qwen/Qwen3-30B-A3B");
      setSystemPrompt("");
      setTemperature(0.7);
      setMaxTokens(1024);

      // Set current assistant for RAG
      setCurrentAssistant({
        id: "create-new",
        name: "New Custom Assistant",
        type: "new",
      });
    } else {
      const config = assistantConfigs.find((c) => c.id === assistantId);
      if (config) {
        setDeviceConfig((prev) => ({
          ...prev,
          assistantId,
          model: config.model,
          temperature: config.temperature,
          maxTokens: config.maxTokens,
          role: config.description,
          goal: config.category,
          description: config.systemPrompt,
        }));

        // Also update chat settings for Step 2
        setSelectedModel(config.model);
        setSystemPrompt(config.systemPrompt);
        setTemperature(config.temperature);
        setMaxTokens(config.maxTokens);

        // Set current assistant for RAG
        setCurrentAssistant({
          id: assistantId,
          name: config.name,
          type: "template",
        });
      }
    }
  };

  // Check for pre-selected use case from Use Cases page
  useEffect(() => {
    const selectedUseCase = localStorage.getItem("selectedUseCase");
    if (selectedUseCase) {
      handleAssistantSelect(selectedUseCase);
      localStorage.removeItem("selectedUseCase"); // Clear after use
    }
  }, []);

  // Chat functionality for Step 2
  const {
    currentSession,
    createNewSession,
    sendMessage,
    isLoading,
    setSystemPrompt,
    setTemperature,
    setMaxTokens,
    setSelectedModel,
    input,
    setInput,
  } = useChat();

  const assistantConfigs = ASSISTANT_CONFIGS;
  const messages = currentSession?.messages || [];

  // Auto-scroll to bottom when messages change
  useEffect(() => {
    scrollToBottom();
  }, [messages]);

  // Sync deviceConfig changes to chat settings
  useEffect(() => {
    setSelectedModel(deviceConfig.model);
    setSystemPrompt(deviceConfig.description);
    setTemperature(deviceConfig.temperature);
    setMaxTokens(deviceConfig.maxTokens);
  }, [
    deviceConfig,
    setSelectedModel,
    setSystemPrompt,
    setTemperature,
    setMaxTokens,
  ]);

  const renderStepIndicator = () => (
    <div className="flex items-center justify-between mb-8 max-w-4xl mx-auto">
      <div className="flex items-center">
        <div
          className={`flex items-center ${
            currentStep >= 1 ? "text-purple-600" : "text-gray-400"
          }`}
        >
          <div
            className={`w-8 h-8 rounded-full border-2 flex items-center justify-center text-sm font-medium ${
              currentStep >= 1
                ? "bg-purple-600 text-white border-purple-600"
                : "border-gray-300"
            }`}
          >
            1
          </div>
          <span className="ml-2 font-medium">Configuration</span>
        </div>
        <div
          className={`w-32 h-0.5 mx-4 ${
            currentStep >= 2 ? "bg-purple-600" : "bg-gray-300"
          }`}
        />
      </div>

      <div className="flex items-center">
        <div
          className={`flex items-center ${
            currentStep >= 2 ? "text-purple-600" : "text-gray-400"
          }`}
        >
          <div
            className={`w-8 h-8 rounded-full border-2 flex items-center justify-center text-sm font-medium ${
              currentStep >= 2
                ? "bg-purple-600 text-white border-purple-600"
                : "border-gray-300"
            }`}
          >
            2
          </div>
          <span className="ml-2 font-medium">Test performance</span>
        </div>
        <div
          className={`w-32 h-0.5 mx-4 ${
            currentStep >= 3 ? "bg-purple-600" : "bg-gray-300"
          }`}
        />
      </div>

      <div className="flex items-center">
        <div
          className={`flex items-center ${
            currentStep >= 3 ? "text-purple-600" : "text-gray-400"
          }`}
        >
          <div
            className={`w-8 h-8 rounded-full border-2 flex items-center justify-center text-sm font-medium ${
              currentStep >= 3
                ? "bg-purple-600 text-white border-purple-600"
                : "border-gray-300"
            }`}
          >
            3
          </div>
          <span className="ml-2 font-medium">Deploy to device</span>
        </div>
        <Button
          className="ml-8 bg-purple-600 hover:bg-purple-700 text-white px-8"
          onClick={() => setCurrentStep(3)}
          disabled={currentStep < 2}
        >
          Connect
        </Button>
      </div>
    </div>
  );

  const renderStep1 = () => (
    <div className="max-w-2xl mx-auto">
      <Card className="p-8">
        <div className="space-y-6">
          {/* Load Assistant */}
          <div>
            <Label className="text-sm font-medium text-gray-700 mb-2 block">
              Load Assistant
            </Label>
            <Select
              onValueChange={handleAssistantSelect}
              value={deviceConfig.assistantId}
            >
              <SelectTrigger>
                <SelectValue placeholder="Select an assistant or create new" />
              </SelectTrigger>
              <SelectContent>
                <SelectItem value="create-new">
                  <div className="flex items-center gap-2">
                    <span className="text-lg">✨</span>
                    <span>Create New Assistant</span>
                  </div>
                </SelectItem>
                <div className="border-b my-1"></div>
                {assistantConfigs.map((config) => (
                  <SelectItem key={config.id} value={config.id}>
                    <div className="flex items-center gap-2">
                      <span>{config.icon}</span>
                      <span>{config.name.replace(/πŸ”οΈ|πŸ₯|🧸/g, "").trim()}</span>
                    </div>
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
          </div>

          {/* Parameters */}
          <div>
            <h3 className="text-lg font-semibold mb-4">Parameters</h3>

            {/* Model Selection */}
            <div className="mb-4">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Select a model
              </Label>
              <Select
                value={deviceConfig.model}
                onValueChange={(value) =>
                  setDeviceConfig((prev) => ({ ...prev, model: value }))
                }
              >
                <SelectTrigger>
                  <SelectValue />
                </SelectTrigger>
                <SelectContent>
                  <SelectItem value="Qwen/Qwen3-30B-A3B">
                    Qwen3-30B-A3B
                  </SelectItem>
                  <SelectItem value="Qwen/Qwen2.5-32B-Instruct">
                    Qwen2.5-32B-Instruct
                  </SelectItem>
                  <SelectItem value="deepseek-ai/DeepSeek-V2.5">
                    DeepSeek-V2.5
                  </SelectItem>
                </SelectContent>
              </Select>
            </div>

            {/* Temperature */}
            <div className="mb-4">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Temperature: {deviceConfig.temperature}
              </Label>
              <Slider
                value={[deviceConfig.temperature]}
                onValueChange={(value) =>
                  setDeviceConfig((prev) => ({
                    ...prev,
                    temperature: value[0],
                  }))
                }
                max={1}
                min={0}
                step={0.1}
                className="w-full"
              />
            </div>

            {/* Max Tokens */}
            <div className="mb-6">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Max Tokens
              </Label>
              <Input
                type="number"
                value={deviceConfig.maxTokens}
                onChange={(e) =>
                  setDeviceConfig((prev) => ({
                    ...prev,
                    maxTokens: parseInt(e.target.value) || 1024,
                  }))
                }
                min={1}
                max={4096}
              />
            </div>
          </div>

          {/* Description */}
          <div>
            <h3 className="text-lg font-semibold mb-4">Description</h3>

            <div className="mb-4">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Which role do you want your assistant to be? (Senior data
                researcher, journalist, lawyer, etc.)
              </Label>
              <Input
                value={deviceConfig.role}
                onChange={(e) =>
                  setDeviceConfig((prev) => ({ ...prev, role: e.target.value }))
                }
                placeholder="e.g., Senior data researcher, journalist, lawyer"
              />
            </div>

            <div className="mb-4">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Which goal would you expect your assistant to achieve
              </Label>
              <Input
                value={deviceConfig.goal}
                onChange={(e) =>
                  setDeviceConfig((prev) => ({ ...prev, goal: e.target.value }))
                }
                placeholder="Describe the main goal or objective"
              />
            </div>

            <div className="mb-6">
              <Label className="text-sm font-medium text-gray-700 mb-2 block">
                Description (Tasks, outputs)
              </Label>
              <Textarea
                value={deviceConfig.description}
                onChange={(e) =>
                  setDeviceConfig((prev) => ({
                    ...prev,
                    description: e.target.value,
                  }))
                }
                placeholder="Describe the tasks and expected outputs..."
                rows={4}
              />
            </div>
          </div>

          {/* Document - RAG Integration */}
          <div>
            <Label className="text-sm font-medium text-gray-700 mb-2 block">
              Documents & Knowledge Base
            </Label>
            <DocumentsTab
              isLoading={isLoading}
              ragEnabled={ragEnabled}
              setRagEnabled={setRagEnabled}
              retrievalCount={retrievalCount}
              setRetrievalCount={setRetrievalCount}
              currentAssistant={currentAssistant}
            />
          </div>

          <Button
            onClick={() => setCurrentStep(2)}
            className="w-full bg-purple-600 hover:bg-purple-700 text-white"
            disabled={
              !deviceConfig.assistantId ||
              (deviceConfig.assistantId === "create-new" &&
                !deviceConfig.description.trim())
            }
          >
            Continue to Test Performance
          </Button>
        </div>
      </Card>
    </div>
  );

  const renderStep2 = () => (
    <div className="max-w-6xl mx-auto">
      <div className="grid grid-cols-1 lg:grid-cols-4 gap-6 h-[500px]">
        {/* Chat Sessions Sidebar */}
        <div className="lg:col-span-1">
          <Card className="h-full p-4">
            <h3 className="font-semibold mb-4">Chat sessions</h3>
            <div className="space-y-2">
              <Button
                variant="ghost"
                className="w-full justify-start text-left"
                onClick={createNewSession}
              >
                New Chat
              </Button>
              {messages.length > 0 && (
                <div className="p-2 bg-gray-50 rounded text-sm">
                  Current Session ({messages.length} messages)
                </div>
              )}
            </div>
          </Card>
        </div>

        {/* Chat Interface */}
        <div className="lg:col-span-3">
          <Card className="h-full flex flex-col">
            <div className="p-4 border-b">
              <div className="flex items-center justify-between">
                <h3 className="font-semibold">Test Performance</h3>
                <Badge variant="secondary">
                  {deviceConfig.assistantId === "create-new"
                    ? "Custom Assistant"
                    : deviceConfig.assistantId
                    ? assistantConfigs
                        .find((c) => c.id === deviceConfig.assistantId)
                        ?.name.replace(/πŸ”οΈ|πŸ₯|🧸/g, "")
                        .trim()
                    : "No Assistant"}
                </Badge>
              </div>
            </div>

            <div className="flex-1 overflow-y-auto p-4 space-y-4 max-h-96 min-h-0">
              {messages.length === 0 ? (
                <div className="flex items-center justify-center h-full text-gray-500">
                  <div className="text-center">
                    <p className="mb-2">
                      Start testing your assistant configuration
                    </p>
                    <p className="text-sm">
                      Send a message to see how your assistant responds
                    </p>
                  </div>
                </div>
              ) : (
                messages.map((message, index) => (
                  <div
                    key={index}
                    className={`flex ${
                      message.role === "user" ? "justify-end" : "justify-start"
                    }`}
                  >
                    <div
                      className={`max-w-[80%] p-3 rounded-lg ${
                        message.role === "user"
                          ? "bg-purple-600 text-white"
                          : "bg-gray-100 text-gray-900"
                      }`}
                    >
                      <p className="whitespace-pre-wrap">{message.content}</p>
                    </div>
                  </div>
                ))
              )}
              {isLoading && (
                <div className="flex justify-start">
                  <div className="bg-gray-100 p-3 rounded-lg">
                    <div className="flex items-center space-x-2">
                      <div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce"></div>
                      <div
                        className="w-2 h-2 bg-gray-400 rounded-full animate-bounce"
                        style={{ animationDelay: "0.1s" }}
                      ></div>
                      <div
                        className="w-2 h-2 bg-gray-400 rounded-full animate-bounce"
                        style={{ animationDelay: "0.2s" }}
                      ></div>
                    </div>
                  </div>
                </div>
              )}
              <div ref={messagesEndRef} />
            </div>

            <div className="p-4 border-t">
              <div className="flex space-x-2">
                <Input
                  placeholder="Type your message..."
                  value={input}
                  onChange={(e) => setInput(e.target.value)}
                  onKeyPress={(e) => {
                    if (e.key === "Enter" && !e.shiftKey) {
                      e.preventDefault();
                      if (input.trim()) {
                        sendMessage(undefined, {
                          useRag: ragEnabled,
                          retrievalCount,
                        });
                      }
                    }
                  }}
                />
                <Button
                  onClick={() => {
                    if (input.trim()) {
                      sendMessage(undefined, {
                        useRag: ragEnabled,
                        retrievalCount,
                      });
                    }
                  }}
                  disabled={isLoading}
                  className="bg-purple-600 hover:bg-purple-700"
                >
                  Send
                </Button>
              </div>
            </div>
          </Card>
        </div>
      </div>

      <div className="mt-4 flex justify-between max-w-6xl mx-auto">
        <Button variant="outline" onClick={() => setCurrentStep(1)}>
          Back to Configuration
        </Button>
        <Button
          onClick={() => setCurrentStep(3)}
          className="bg-purple-600 hover:bg-purple-700 text-white"
        >
          Continue to Deploy Device
        </Button>
      </div>
    </div>
  );

  const renderStep3 = () => (
    <div className="max-w-2xl mx-auto">
      <Card className="p-8 text-center">
        <div className="mb-6">
          <div className="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
            <svg
              className="w-8 h-8 text-purple-600"
              fill="none"
              stroke="currentColor"
              viewBox="0 0 24 24"
            >
              <path
                strokeLinecap="round"
                strokeLinejoin="round"
                strokeWidth={2}
                d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.212 0"
              />
            </svg>
          </div>
          <h2 className="text-2xl font-bold text-gray-900 mb-2">
            Deploy to Device
          </h2>
          <p className="text-gray-600">
            Your assistant configuration is ready to be deployed to your edge
            device.
          </p>
        </div>

        <div className="space-y-4 text-left mb-8">
          <div className="bg-gray-50 p-4 rounded-lg">
            <h3 className="font-semibold mb-2">Configuration Summary</h3>
            <div className="space-y-1 text-sm">
              <p>
                <span className="font-medium">Assistant:</span>{" "}
                {deviceConfig.assistantId === "create-new"
                  ? "Custom Assistant"
                  : assistantConfigs
                      .find((c) => c.id === deviceConfig.assistantId)
                      ?.name.replace(/πŸ”οΈ|πŸ₯|🧸/g, "")
                      .trim() || "None"}
              </p>
              <p>
                <span className="font-medium">Model:</span> {deviceConfig.model}
              </p>
              <p>
                <span className="font-medium">Temperature:</span>{" "}
                {deviceConfig.temperature}
              </p>
              <p>
                <span className="font-medium">Max Tokens:</span>{" "}
                {deviceConfig.maxTokens}
              </p>
              {deviceConfig.role && (
                <p>
                  <span className="font-medium">Role:</span> {deviceConfig.role}
                </p>
              )}
              <p>
                <span className="font-medium">RAG Enabled:</span>{" "}
                {ragEnabled ? "Yes" : "No"}
              </p>
              {ragEnabled && (
                <p>
                  <span className="font-medium">Retrieval Count:</span>{" "}
                  {retrievalCount}
                </p>
              )}
            </div>
          </div>

          <div className="bg-blue-50 p-4 rounded-lg border border-blue-200">
            <div className="flex items-center">
              <svg
                className="w-5 h-5 text-blue-600 mr-2"
                fill="none"
                stroke="currentColor"
                viewBox="0 0 24 24"
              >
                <path
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  strokeWidth={2}
                  d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
                />
              </svg>
              <p className="text-blue-800 text-sm">
                <span className="font-medium">Ready to deploy:</span> Your
                assistant configuration has been optimized for edge deployment.
              </p>
            </div>
          </div>
        </div>

        <div className="space-y-3">
          <Button className="w-full bg-purple-600 hover:bg-purple-700 text-white py-3">
            Deploy to Device
          </Button>
          <Button
            variant="outline"
            className="w-full"
            onClick={() => setCurrentStep(2)}
          >
            Back to Testing
          </Button>
        </div>
      </Card>
    </div>
  );

  return (
    <div className="min-h-screen bg-gray-50">
      {/* Header */}
      <header className="bg-white border-b border-gray-200">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="flex items-center justify-between h-20">
            <div className="flex items-center space-x-2">
              <img
                src="/assets/logo.png"
                alt="EdgeLLM Logo"
                className="h-16 w-16"
                onError={(e) => {
                  console.error("Logo failed to load");
                  e.currentTarget.style.display = "none";
                }}
              />
            </div>
            <nav className="flex space-x-8">
              <button
                onClick={() => navigate("/")}
                className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium"
              >
                Home
              </button>
              <button
                onClick={() => navigate("/technology")}
                className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium"
              >
                Technology
              </button>
              <button
                onClick={() => navigate("/usecases")}
                className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium"
              >
                Use Case
              </button>
              <button className="bg-purple-600 text-white px-4 py-2 text-sm font-medium rounded">
                My Device
              </button>
            </nav>
          </div>
        </div>
      </header>

      {/* Main Content */}
      <main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        {renderStepIndicator()}

        {currentStep === 1 && renderStep1()}
        {currentStep === 2 && renderStep2()}
        {currentStep === 3 && renderStep3()}
      </main>
    </div>
  );
}