File size: 33,957 Bytes
10674e9
 
 
 
 
a2f73e6
10674e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2f73e6
 
 
 
 
 
 
 
10674e9
 
a2f73e6
10674e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2f73e6
10674e9
 
 
 
 
 
a2f73e6
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
10674e9
 
a2f73e6
 
 
10674e9
 
 
 
 
 
 
 
 
 
 
a2f73e6
10674e9
 
 
 
 
 
 
 
 
 
 
a2f73e6
 
10674e9
 
a2f73e6
 
10674e9
 
a2f73e6
 
 
 
 
 
10674e9
 
a2f73e6
 
10674e9
a2f73e6
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
10674e9
 
 
 
 
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
 
 
 
 
a2f73e6
 
10674e9
 
 
a2f73e6
 
 
 
 
10674e9
 
 
a2f73e6
 
 
 
 
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2f73e6
 
 
10674e9
a2f73e6
 
 
 
 
 
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
a2f73e6
 
10674e9
a2f73e6
 
 
 
10674e9
a2f73e6
 
 
 
10674e9
a2f73e6
10674e9
 
a2f73e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10674e9
 
 
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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Model Runner - Claude Code Integration Guide</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .header {
            text-align: center;
            color: white;
            margin-bottom: 30px;
        }
        
        .header h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
        }
        
        .header p {
            font-size: 1.2rem;
            opacity: 0.9;
        }
        
        .content {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 8px 16px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .tabs {
            display: flex;
            background: #f8f9fa;
            border-radius: 10px 10px 0 0;
            overflow: hidden;
        }
        
        .tab {
            flex: 1;
            padding: 15px 20px;
            background: #f8f9fa;
            border: none;
            cursor: pointer;
            font-size: 16px;
            transition: background 0.3s;
        }
        
        .tab.active {
            background: white;
            color: #667eea;
            font-weight: bold;
        }
        
        .tab:hover {
            background: #e9ecef;
        }
        
        .tab.active:hover {
            background: white;
        }
        
        .tab-content {
            display: none;
            padding-top: 20px;
        }
        
        .tab-content.active {
            display: block;
        }
        
        .code-block {
            background: #2d3748;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 8px;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            overflow-x: auto;
            margin: 15px 0;
        }
        
        .code-block .copy-btn {
            background: #4299e1;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
            float: right;
            font-size: 12px;
        }
        
        .step {
            background: #f7fafc;
            border-left: 4px solid #667eea;
            padding: 15px;
            margin: 10px 0;
            border-radius: 0 8px 8px 0;
        }
        
        .step h4 {
            color: #667eea;
            margin-bottom: 8px;
        }
        
        .btn {
            background: #667eea;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            transition: background 0.3s;
            margin: 10px 5px;
        }
        
        .btn:hover {
            background: #5a6fd8;
        }
        
        .btn:disabled {
            background: #ccc;
            cursor: not-allowed;
        }
        
        .btn-secondary {
            background: #718096;
        }
        
        .btn-secondary:hover {
            background: #4a5568;
        }
        
        .api-endpoint {
            background: #edf2f7;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            padding: 15px;
            margin: 10px 0;
        }
        
        .api-endpoint .method {
            background: #48bb78;
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: bold;
        }
        
        .api-endpoint .method.get {
            background: #4299e1;
        }
        
        .api-endpoint .method.post {
            background: #48bb78;
        }
        
        .status {
            background: #d1edff;
            border: 1px solid #a8daff;
            color: #055160;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .warning {
            background: #fef3c7;
            border: 1px solid #fde68a;
            color: #92400e;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .success {
            background: #d1fae5;
            border: 1px solid #a7f3d0;
            color: #065f46;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        
        .card {
            background: #f7fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            padding: 20px;
        }
        
        .card h3 {
            color: #667eea;
            margin-bottom: 10px;
        }
        
        pre {
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        
        .curl-example {
            background: #2d3748;
            color: #e2e8f0;
            padding: 15px;
            border-radius: 6px;
            font-family: monospace;
            font-size: 13px;
            overflow-x: auto;
        }
        
        .setup-section {
            background: #f0fff4;
            border: 2px dashed #68d391;
            border-radius: 10px;
            padding: 20px;
            margin: 20px 0;
        }
        
        .setup-section h3 {
            color: #38a169;
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>πŸ€– AI Model Runner</h1>
            <p>Claude Code Integration Guide & API Documentation</p>
        </div>
        
        <div class="tabs">
            <button class="tab active" onclick="showTab('setup')">πŸš€ Setup</button>
            <button class="tab" onclick="showTab('config')">βš™οΈ Configuration</button>
            <button class="tab" onclick="showTab('api')">πŸ“‘ API Reference</button>
            <button class="tab" onclick="showTab('examples')">πŸ’‘ Examples</button>
            <button class="tab" onclick="showTab('troubleshooting')">πŸ”§ Troubleshooting</button>
        </div>
        
        <div class="content">
            <!-- Setup Tab -->
            <div id="setup" class="tab-content active">
                <h2>πŸš€ Quick Setup Guide</h2>
                
                <div class="status">
                    <strong>⚠️ Important:</strong> Your Hugging Face Space may still be building. 
                    Once ready, the API will be available at: 
                    <code>https://sheikhcoders-ai-model-runner.hf.space</code>
                </div>
                
                <h3>Step 1: Locate Your Claude Code Settings</h3>
                <div class="step">
                    <h4>Find the settings file</h4>
                    <p>The Claude Code settings file is located at:</p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyToClipboard('~/.claude/settings.json')">Copy</button>
                        ~/.claude/settings.json
                    </div>
                    <p><strong>macOS/Linux:</strong> <code>~/.claude/settings.json</code></p>
                    <p><strong>Windows:</strong> <code>%USERPROFILE%\.claude\settings.json</code></p>
                </div>
                
                <h3>Step 2: Add AI Model Runner Configuration</h3>
                <div class="step">
                    <h4>Basic Configuration</h4>
                    <p>Add the following to your settings.json file:</p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyToClipboard('basic-config')">Copy</button>
                        <div id="basic-config">
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - Code analysis, dialogue, and reasoning",
          "capabilities": {
            "code_analysis": ["explain", "refactor", "debug", "optimize"],
            "dialogue": "microsoft/DialoGPT-medium",
            "reasoning": "step-by-step problem solving",
            "sentiment": "text sentiment analysis"
          }
        }
      }
    }
  }
}
                        </div>
                    </div>
                </div>
                
                <h3>Step 3: Test the Connection</h3>
                <div class="step">
                    <h4>Verify the API is working</h4>
                    <p>Run this command to test connectivity:</p>
                    <div class="curl-example">
curl https://sheikhcoders-ai-model-runner.hf.space/health
                    </div>
                </div>
                
                <div class="setup-section">
                    <h3>πŸ› οΈ Automated Setup Script</h3>
                    <p>Run this script to automatically configure your Claude Code integration:</p>
                    
                    <h4>Python Script</h4>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyToClipboard('python-setup')">Copy</button>
                        <div id="python-setup">
import os
import json

# Create settings directory
settings_dir = os.path.expanduser("~/.claude")
os.makedirs(settings_dir, exist_ok=True)

# Configuration
config = {
    "claude": {
        "api": {
            "endpoints": {
                "ai_model_runner": {
                    "url": "https://sheikhcoders-ai-model-runner.hf.space",
                    "description": "AI Model Runner - Code analysis, dialogue, and reasoning"
                }
            }
        }
    }
}

# Save settings
settings_file = os.path.join(settings_dir, "settings.json")
with open(settings_file, 'w') as f:
    json.dump(config, f, indent=2)

print(f"βœ… Configuration saved to: {settings_file}")
                        </div>
                    </div>
                    
                    <h4>Shell Script (Bash)</h4>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyToClipboard('bash-setup')">Copy</button>
                        <div id="bash-setup">
#!/bin/bash
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - Code analysis, dialogue, and reasoning"
        }
      }
    }
  }
}
EOF
echo "βœ… Configuration created at ~/.claude/settings.json"
                        </div>
                    </div>
                    
                    <button class="btn" onclick="downloadSetupScripts()">πŸ“₯ Download Setup Scripts</button>
                </div>
            </div>
            
            <!-- Configuration Tab -->
            <div id="config" class="tab-content">
                <h2>βš™οΈ Advanced Configuration</h2>
                
                <h3>Basic Endpoint Configuration</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('basic-endpoint')">Copy</button>
                    <div id="basic-endpoint">
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - All AI capabilities"
        }
      }
    }
  }
}
                    </div>
                </div>
                
                <h3>Code Analysis Configuration</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('code-config')">Copy</button>
                    <div id="code-config">
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - Code understanding",
          "capabilities": {
            "code_analysis": {
              "tasks": ["explain", "refactor", "debug", "optimize"],
              "supported_languages": ["python", "javascript", "java", "cpp", "csharp"]
            }
          }
        }
      }
    }
  }
}
                    </div>
                </div>
                
                <h3>Dialogue System Configuration</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('dialogue-config')">Copy</button>
                    <div id="dialogue-config">
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - Multi-turn dialogue",
          "context": {
            "model": "microsoft/DialoGPT-medium",
            "max_length": 100,
            "temperature": 0.7
          }
        }
      }
    }
  }
}
                    </div>
                </div>
                
                <h3>Complete Integration Configuration</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('complete-config')">Copy</button>
                    <div id="complete-config">
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "Complete AI Model Runner integration",
          "context": {
            "models": {
              "dialogue": "microsoft/DialoGPT-medium",
              "text_generation": "gpt2",
              "sentiment": "distilbert-base-uncased-finetuned-sst-2-english"
            },
            "capabilities": {
              "code_analysis": {
                "tasks": ["explain", "refactor", "debug", "optimize"],
                "languages": ["python", "javascript", "java", "cpp", "csharp"]
              },
              "dialogue": {
                "model": "microsoft/DialoGPT-medium",
                "max_length": 100,
                "temperature": 0.7
              },
              "reasoning": {
                "max_steps": 5
              }
            }
          }
        }
      }
    }
  }
}
                    </div>
                </div>
            </div>
            
            <!-- API Reference Tab -->
            <div id="api" class="tab-content">
                <h2>πŸ“‘ API Reference</h2>
                
                <h3>Core Endpoints</h3>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method get">GET</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/health</h4>
                    </div>
                    <p>Check API health and model status</p>
                    <p><strong>Response:</strong></p>
                    <div class="code-block">
{
  "status": "healthy",
  "models_loaded": 3
}
                    </div>
                </div>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method get">GET</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/models</h4>
                    </div>
                    <p>List available AI models</p>
                </div>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method post">POST</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/chat</h4>
                    </div>
                    <p>Multi-turn dialogue with AI</p>
                    <p><strong>Request Body:</strong></p>
                    <div class="code-block">
{
  "messages": [
    {"role": "user", "content": "Hello!"}
  ],
  "model": "microsoft/DialoGPT-medium",
  "max_length": 100,
  "temperature": 0.7
}
                    </div>
                </div>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method post">POST</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/code</h4>
                    </div>
                    <p>Analyze code (explain, refactor, debug, optimize)</p>
                    <p><strong>Request Body:</strong></p>
                    <div class="code-block">
{
  "code": "def hello(): print('world')",
  "task": "explain",
  "language": "python"
}
                    </div>
                </div>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method post">POST</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/reasoning</h4>
                    </div>
                    <p>Step-by-step problem solving</p>
                </div>
                
                <div class="api-endpoint">
                    <div style="display: flex; align-items: center; margin-bottom: 10px;">
                        <span class="method post">POST</span>
                        <h4 style="margin-left: 10px; margin-bottom: 0;">/analyze-sentiment</h4>
                    </div>
                    <p>Analyze text sentiment</p>
                </div>
                
                <h3>cURL Examples</h3>
                
                <h4>Health Check</h4>
                <div class="curl-example">
curl https://sheikhcoders-ai-model-runner.hf.space/health
                </div>
                
                <h4>Code Analysis</h4>
                <div class="curl-example">
curl -X POST https://sheikhcoders-ai-model-runner.hf.space/code \
  -H "Content-Type: application/json" \
  -d '{"code": "def hello(): return \"world\"", "task": "explain", "language": "python"}'
                </div>
                
                <h4>Chat</h4>
                <div class="curl-example">
curl -X POST https://sheikhcoders-ai-model-runner.hf.space/chat \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Hello!"}]}'
                </div>
            </div>
            
            <!-- Examples Tab -->
            <div id="examples" class="tab-content">
                <h2>πŸ’‘ Usage Examples</h2>
                
                <h3>Python Integration Example</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('python-example')">Copy</button>
                    <div id="python-example">
import requests

class AIIntegrator:
    def __init__(self, base_url="https://sheikhcoders-ai-model-runner.hf.space"):
        self.base_url = base_url
    
    def health_check(self):
        response = requests.get(f"{self.base_url}/health")
        return response.json()
    
    def analyze_code(self, code, task="explain", language="python"):
        data = {
            "code": code,
            "task": task,
            "language": language
        }
        response = requests.post(f"{self.base_url}/code", json=data)
        return response.json()
    
    def chat(self, messages, model="microsoft/DialoGPT-medium"):
        data = {
            "messages": messages,
            "model": model
        }
        response = requests.post(f"{self.base_url}/chat", json=data)
        return response.json()

# Usage
integrator = AIIntegrator()

# Check health
print("Health:", integrator.health_check())

# Analyze code
code_analysis = integrator.analyze_code(
    "def fibonacci(n): return [fib(i) for i in range(n)]",
    task="explain",
    language="python"
)
print("Analysis:", code_analysis)
                    </div>
                </div>
                
                <h3>JavaScript Integration Example</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('js-example')">Copy</button>
                    <div id="js-example">
class AIIntegrator {
    constructor(baseUrl = "https://sheikhcoders-ai-model-runner.hf.space") {
        this.baseUrl = baseUrl;
    }
    
    async healthCheck() {
        const response = await fetch(`${this.baseUrl}/health`);
        return response.json();
    }
    
    async analyzeCode(code, task = "explain", language = "python") {
        const data = { code, task, language };
        const response = await fetch(`${this.baseUrl}/code`, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify(data)
        });
        return response.json();
    }
    
    async chat(messages, model = "microsoft/DialoGPT-medium") {
        const data = { messages, model };
        const response = await fetch(`${this.baseUrl}/chat`, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify(data)
        });
        return response.json();
    }
}

// Usage
const integrator = new AIIntegrator();

integrator.healthCheck().then(result => {
    console.log("Health:", result);
});

integrator.analyzeCode("console.log('Hello World')", "explain", "javascript")
    .then(result => {
        console.log("Analysis:", result);
    });
                    </div>
                </div>
                
                <h3>Claude Code Integration Script</h3>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyToClipboard('claude-integration')">Copy</button>
                    <div id="claude-integration">
# Claude Code Integration Script
# Save as: ~/setup-claude-integration.py

import os
import json
import shutil

def setup_claude_integration():
    """Setup Claude Code with AI Model Runner"""
    
    # Create settings directory
    settings_dir = os.path.expanduser("~/.claude")
    if not os.path.exists(settings_dir):
        os.makedirs(settings_dir)
        print(f"πŸ“ Created directory: {settings_dir}")
    
    # Backup existing settings
    settings_file = os.path.join(settings_dir, "settings.json")
    if os.path.exists(settings_file):
        backup_file = settings_file + ".backup"
        shutil.copy2(settings_file, backup_file)
        print(f"πŸ’Ύ Backed up existing settings to: {backup_file}")
        
        # Load existing settings
        with open(settings_file, 'r') as f:
            settings = json.load(f)
    else:
        settings = {}
    
    # Add AI Model Runner configuration
    if "claude" not in settings:
        settings["claude"] = {}
    if "api" not in settings["claude"]:
        settings["claude"]["api"] = {}
    if "endpoints" not in settings["claude"]["api"]:
        settings["claude"]["api"]["endpoints"] = {}
    
    settings["claude"]["api"]["endpoints"]["ai_model_runner"] = {
        "url": "https://sheikhcoders-ai-model-runner.hf.space",
        "description": "AI Model Runner - Code analysis, dialogue, and reasoning",
        "capabilities": {
            "code_analysis": ["explain", "refactor", "debug", "optimize"],
            "dialogue": "microsoft/DialoGPT-medium",
            "reasoning": "step-by-step problem solving",
            "sentiment": "text sentiment analysis"
        }
    }
    
    # Save settings
    with open(settings_file, 'w') as f:
        json.dump(settings, f, indent=2)
    
    print(f"βœ… Configuration saved to: {settings_file}")
    print("πŸš€ AI Model Runner is now integrated with Claude Code!")
    print(f"πŸ“‘ API Endpoint: https://sheikhcoders-ai-model-runner.hf.space")

if __name__ == "__main__":
    setup_claude_integration()
                    </div>
                </div>
            </div>
            
            <!-- Troubleshooting Tab -->
            <div id="troubleshooting" class="tab-content">
                <h2>πŸ”§ Troubleshooting</h2>
                
                <h3>Common Issues</h3>
                
                <div class="grid">
                    <div class="card">
                        <h3>🚫 Space Not Loading</h3>
                        <p><strong>Issue:</strong> "Preparing Space" message persists</p>
                        <p><strong>Solution:</strong></p>
                        <ul>
                            <li>Wait 2-5 minutes for initial build</li>
                            <li>Check Hugging Face Space logs</li>
                            <li>Verify no syntax errors in code</li>
                        </ul>
                    </div>
                    
                    <div class="card">
                        <h3>πŸ”Œ Connection Timeout</h3>
                        <p><strong>Issue:</strong> Requests timeout</p>
                        <p><strong>Solution:</strong></p>
                        <ul>
                            <li>First load takes longer (model loading)</li>
                            <li>Check internet connection</li>
                            <li>Try again in a few minutes</li>
                        </ul>
                    </div>
                    
                    <div class="card">
                        <h3>πŸ“ Settings File Not Found</h3>
                        <p><strong>Issue:</strong> ~/.claude/settings.json doesn't exist</p>
                        <p><strong>Solution:</strong></p>
                        <ul>
                            <li>Create the directory: mkdir -p ~/.claude</li>
                            <li>Copy the configuration manually</li>
                            <li>Use the setup script</li>
                        </ul>
                    </div>
                    
                    <div class="card">
                        <h3>❌ API Returns 404</h3>
                        <p><strong>Issue:</strong> Endpoint not found</p>
                        <p><strong>Solution:</strong></p>
                        <ul>
                            <li>Verify space URL is correct</li>
                            <li>Check space is fully built</li>
                            <li>Use correct endpoint paths</li>
                        </ul>
                    </div>
                </div>
                
                <h3>Testing Your Setup</h3>
                
                <div class="step">
                    <h4>1. Check API Health</h4>
                    <div class="curl-example">
curl https://sheikhcoders-ai-model-runner.hf.space/health
                    </div>
                    <p>Expected response: <code>{"status": "healthy"}</code></p>
                </div>
                
                <div class="step">
                    <h4>2. Test Code Analysis</h4>
                    <div class="curl-example">
curl -X POST https://sheikhcoders-ai-model-runner.hf.space/code \
  -H "Content-Type: application/json" \
  -d '{"code": "print(\"Hello World\")", "task": "explain"}'
                    </div>
                </div>
                
                <div class="step">
                    <h4>3. Verify Settings File</h4>
                    <div class="code-block">
cat ~/.claude/settings.json
                    </div>
                    <p>Look for the "ai_model_runner" endpoint configuration</p>
                </div>
                
                <div class="warning">
                    <h4>⚠️ Performance Notes</h4>
                    <ul>
                        <li><strong>First Load:</strong> 30-60 seconds (model loading)</li>
                        <li><strong>Subsequent Requests:</strong> 2-5 seconds (cached models)</li>
                        <li><strong>Model Loading:</strong> Automatically handled on startup</li>
                        <li><strong>Graceful Fallbacks:</strong> Mock responses if models fail</li>
                    </ul>
                </div>
                
                <div class="success">
                    <h4>βœ… Success Indicators</h4>
                    <ul>
                        <li>Health check returns "healthy" status</li>
                        <li>Code analysis returns detailed explanations</li>
                        <li>Chat responses are coherent</li>
                        <li>All endpoints return proper JSON</li>
                    </ul>
                </div>
                
                <h3>Debugging Commands</h3>
                <div class="code-block">
# Check space status
curl -I https://sheikhcoders-ai-model-runner.hf.space/

# List available endpoints
curl https://sheikhcoders-ai-model-runner.hf.space/

# Test specific endpoint
curl -X GET https://sheikhcoders-ai-model-runner.hf.space/models

# Check settings file
ls -la ~/.claude/
cat ~/.claude/settings.json
                </div>
            </div>
            
            <div id="status"></div>
        </div>
    </div>
    
    <script>
        function showTab(tabName) {
            // Hide all tabs
            document.querySelectorAll('.tab-content').forEach(tab => {
                tab.classList.remove('active');
            });
            document.querySelectorAll('.tab').forEach(tab => {
                tab.classList.remove('active');
            });
            
            // Show selected tab
            document.getElementById(tabName).classList.add('active');
            event.target.classList.add('active');
        }
        
        function copyToClipboard(elementId) {
            const element = document.getElementById(elementId);
            const text = element.textContent;
            
            navigator.clipboard.writeText(text).then(() => {
                showStatus('Copied to clipboard!', false);
            }).catch(err => {
                console.error('Failed to copy: ', err);
                showStatus('Failed to copy to clipboard', true);
            });
        }
        
        function downloadSetupScripts() {
            const pythonScript = `import os
import json

# Create settings directory
settings_dir = os.path.expanduser("~/.claude")
os.makedirs(settings_dir, exist_ok=True)

# Configuration
config = {
    "claude": {
        "api": {
            "endpoints": {
                "ai_model_runner": {
                    "url": "https://sheikhcoders-ai-model-runner.hf.space",
                    "description": "AI Model Runner - Code analysis, dialogue, and reasoning"
                }
            }
        }
    }
}

# Save settings
settings_file = os.path.join(settings_dir, "settings.json")
with open(settings_file, 'w') as f:
    json.dump(config, f, indent=2)

print(f"βœ… Configuration saved to: {settings_file}")
print("πŸš€ Claude Code integration complete!")`;

            const bashScript = `#!/bin/bash
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
  "claude": {
    "api": {
      "endpoints": {
        "ai_model_runner": {
          "url": "https://sheikhcoders-ai-model-runner.hf.space",
          "description": "AI Model Runner - Code analysis, dialogue, and reasoning"
        }
      }
    }
  }
}
EOF
echo "βœ… Configuration created at ~/.claude/settings.json"
echo "πŸš€ Claude Code integration complete!"`;

            // Create download links
            const pythonBlob = new Blob([pythonScript], {type: 'text/x-python'});
            const bashBlob = new Blob([bashScript], {type: 'text/x-shellscript'});
            
            const pythonUrl = URL.createObjectURL(pythonBlob);
            const bashUrl = URL.createObjectURL(bashBlob);
            
            const a1 = document.createElement('a');
            a1.href = pythonUrl;
            a1.download = 'setup-claude-integration.py';
            a1.click();
            
            const a2 = document.createElement('a');
            a2.href = bashUrl;
            a2.download = 'setup-claude-integration.sh';
            a2.click();
            
            showStatus('Setup scripts downloaded!', false);
        }
        
        function showStatus(message, isError = false) {
            const statusDiv = document.getElementById('status');
            statusDiv.innerHTML = `<div class="${isError ? 'warning' : 'success'}" style="position: fixed; top: 20px; right: 20px; z-index: 1000; max-width: 300px;">${message}</div>`;
            setTimeout(() => {
                statusDiv.innerHTML = '';
            }, 3000);
        }
        
        // Check API status on load
        setTimeout(() => {
            fetch('https://sheikhcoders-ai-model-runner.hf.space/health')
                .then(response => {
                    if (response.ok) {
                        showStatus('βœ… API is ready!', false);
                    } else {
                        showStatus('⚠️ API is still building. Please wait...', true);
                    }
                })
                .catch(() => {
                    showStatus('⚠️ API is still building. Please wait...', true);
                });
        }, 2000);
    </script>
</body>
</html>