natabrizy commited on
Commit
f588c19
·
verified ·
1 Parent(s): c7487ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +131 -57
app.py CHANGED
@@ -21,49 +21,73 @@ DEFAULT_VISION_MODEL = "Qwen/Qwen2.5-VL-72B-Instruct"
21
  VISION_MODELS = [
22
  DEFAULT_VISION_MODEL,
23
  "Qwen/Qwen2.5-VL-7B-Instruct",
24
- "mistralai/Pixtral-12B-2409", # Mistral's vision model
 
25
  ]
26
 
27
- # Code generation models confirmed to work on Nebius
28
  DEFAULT_CODE_MODEL = "Qwen/Qwen2.5-72B-Instruct"
29
  CODE_MODELS = [
 
30
  DEFAULT_CODE_MODEL,
31
  "Qwen/Qwen2.5-Coder-32B-Instruct",
32
  "Qwen/Qwen2.5-7B-Instruct",
 
 
 
 
 
33
  "deepseek-ai/DeepSeek-V3",
34
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
 
35
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
 
 
 
 
 
 
36
  "meta-llama/Meta-Llama-3.1-70B-Instruct",
37
  "meta-llama/Meta-Llama-3.1-8B-Instruct",
38
- "mistralai/Mixtral-8x22B-Instruct-v0.1",
39
- "mistralai/Mixtral-8x7B-Instruct-v0.1",
40
- "mistralai/Mistral-7B-Instruct-v0.3",
41
- "mistralai/Mistral-Nemo-Instruct-2407",
42
- "mistralai/Codestral-22B-v0.1",
43
- "mistralai/Mistral-Large-Instruct-2407",
 
 
44
  ]
45
 
46
  # Model recommendations for different use cases
47
  MODEL_RECOMMENDATIONS = {
48
  "fast": [
49
- "Qwen/Qwen2.5-7B-Instruct",
50
- "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
51
- "meta-llama/Meta-Llama-3.1-8B-Instruct",
52
- "mistralai/Mistral-7B-Instruct-v0.3"
 
53
  ],
54
  "balanced": [
55
- "Qwen/Qwen2.5-Coder-32B-Instruct",
56
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
57
- "mistralai/Mixtral-8x7B-Instruct-v0.1",
58
- "mistralai/Codestral-22B-v0.1"
 
59
  ],
60
  "quality": [
61
- "Qwen/Qwen2.5-72B-Instruct",
62
- "deepseek-ai/DeepSeek-V3",
63
  "meta-llama/Meta-Llama-3.1-70B-Instruct",
64
- "mistralai/Mixtral-8x22B-Instruct-v0.1",
65
- "mistralai/Mistral-Large-Instruct-2407"
66
  ],
 
 
 
 
 
 
67
  }
68
 
69
  # Timeouts and retries
@@ -127,7 +151,7 @@ def call_chat_completions(
127
  # Try a fallback model
128
  fallback_models = {
129
  "vision": ["Qwen/Qwen2.5-VL-7B-Instruct"],
130
- "code": ["Qwen/Qwen2.5-7B-Instruct", "mistralai/Mistral-7B-Instruct-v0.3"],
131
  }
132
 
133
  # Detect model type and use appropriate fallback
@@ -603,6 +627,7 @@ THEME_SURFACE = "#FFFFFF"
603
  THEME_TEXT = "#1F2937"
604
  THEME_MUTED = "#6B7280"
605
  THEME_BORDER = "#E5E7EB"
 
606
  THEME_GRADIENT = f"linear-gradient(135deg, {THEME_PRIMARY} 0%, {THEME_SECONDARY} 100%)"
607
 
608
  custom_css = f"""
@@ -614,6 +639,7 @@ custom_css = f"""
614
  --text: {THEME_TEXT};
615
  --muted: {THEME_MUTED};
616
  --border: {THEME_BORDER};
 
617
  }}
618
 
619
  body {{
@@ -681,11 +707,24 @@ custom_css = f"""
681
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15) !important;
682
  }}
683
 
684
- .model-info {{
685
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
686
  color: white;
687
- padding: 12px;
688
- border-radius: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
689
  margin: 8px 0;
690
  }}
691
  """
@@ -701,8 +740,8 @@ with gr.Blocks(
701
  Transform website screenshots into functional HTML code using Nebius AI models.
702
 
703
  ### Key Features:
704
- - Vision Analysis with Qwen VL and Mistral Pixtral models
705
- - Code Generation with Qwen, DeepSeek, Llama, and Mistral models
706
  - Single-file HTML output with inline CSS
707
  - Direct CodeSandbox deployment
708
  - Automatic fallback for unavailable models
@@ -712,9 +751,10 @@ Transform website screenshots into functional HTML code using Nebius AI models.
712
 
713
  with gr.Accordion("Configuration", open=True):
714
  gr.Markdown(
715
- """
716
- Configure your API settings and model preferences. A default API key is provided for testing.
717
- Select from a wide range of Mistral, Qwen, DeepSeek, and Llama models.
 
718
  """,
719
  elem_classes=["muted"]
720
  )
@@ -732,14 +772,14 @@ Transform website screenshots into functional HTML code using Nebius AI models.
732
  choices=VISION_MODELS,
733
  value=DEFAULT_VISION_MODEL,
734
  allow_custom_value=True,
735
- info="Model for image analysis (Qwen VL or Mistral Pixtral)",
736
  )
737
  code_model_dd = gr.Dropdown(
738
  label="Code Model",
739
  choices=CODE_MODELS,
740
  value=DEFAULT_CODE_MODEL,
741
  allow_custom_value=True,
742
- info="Model for HTML generation",
743
  )
744
 
745
  with gr.Row():
@@ -759,6 +799,31 @@ Transform website screenshots into functional HTML code using Nebius AI models.
759
  value=0.7,
760
  info="Creativity level",
761
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
 
763
  with gr.Tab("Generate"):
764
  with gr.Row():
@@ -832,44 +897,53 @@ Transform website screenshots into functional HTML code using Nebius AI models.
832
 
833
  with gr.Tab("Models"):
834
  gr.Markdown(
835
- """
836
- ## Available Models on Nebius
837
 
838
- ### Vision Models
839
- - **Qwen/Qwen2.5-VL-72B-Instruct** - High quality vision analysis
 
 
840
  - **Qwen/Qwen2.5-VL-7B-Instruct** - Fast vision processing
841
- - **mistralai/Pixtral-12B-2409** - Mistral's multimodal vision model
 
842
 
843
- ### Code Generation Models
844
 
845
- #### Qwen Models
846
  - **Qwen/Qwen2.5-72B-Instruct** - Best overall quality
847
- - **Qwen/Qwen2.5-Coder-32B-Instruct** - Optimized for code
 
 
848
  - **Qwen/Qwen2.5-7B-Instruct** - Fast generation
 
 
 
 
849
 
850
- #### DeepSeek Models
851
- - **deepseek-ai/DeepSeek-V3** - Advanced code generation
852
- - **deepseek-ai/DeepSeek-R1-Distill-Qwen-32B** - Balanced performance
853
- - **deepseek-ai/DeepSeek-R1-Distill-Qwen-7B** - Fast alternative
854
-
855
- #### Mistral Models
856
- - **mistralai/Mistral-Large-Instruct-2407** - Mistral's flagship model
857
- - **mistralai/Mixtral-8x22B-Instruct-v0.1** - Large MOE model
858
- - **mistralai/Mixtral-8x7B-Instruct-v0.1** - Efficient MOE architecture
859
- - **mistralai/Codestral-22B-v0.1** - Specialized for code generation
860
- - **mistralai/Mistral-Nemo-Instruct-2407** - Balanced performance
861
- - **mistralai/Mistral-7B-Instruct-v0.3** - Fast and efficient
862
 
863
- #### Meta Llama Models
 
864
  - **meta-llama/Meta-Llama-3.1-70B-Instruct** - High quality
865
- - **meta-llama/Meta-Llama-3.1-8B-Instruct** - Fast Llama option
 
 
866
 
867
  ### Recommendations by Use Case
868
 
869
- **For Speed:** Qwen 7B, Mistral 7B, DeepSeek 7B
870
- **For Quality:** Qwen 72B, Mistral Large, DeepSeek V3
871
- **For Code:** Qwen Coder, Codestral, DeepSeek models
872
- **For Balance:** Mixtral models, Qwen 32B models
873
  """,
874
  elem_classes=["section"]
875
  )
 
21
  VISION_MODELS = [
22
  DEFAULT_VISION_MODEL,
23
  "Qwen/Qwen2.5-VL-7B-Instruct",
24
+ "Qwen/Qwen2-VL-72B-Instruct",
25
+ "Qwen/Qwen2-VL-7B-Instruct",
26
  ]
27
 
28
+ # Code generation models confirmed to work on Nebius (tested and verified)
29
  DEFAULT_CODE_MODEL = "Qwen/Qwen2.5-72B-Instruct"
30
  CODE_MODELS = [
31
+ # Qwen Models (All working)
32
  DEFAULT_CODE_MODEL,
33
  "Qwen/Qwen2.5-Coder-32B-Instruct",
34
  "Qwen/Qwen2.5-7B-Instruct",
35
+ "Qwen/Qwen2.5-14B-Instruct",
36
+ "Qwen/Qwen2.5-32B-Instruct",
37
+ "Qwen/QwQ-32B-Preview",
38
+
39
+ # DeepSeek Models (All working)
40
  "deepseek-ai/DeepSeek-V3",
41
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
42
+ "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",
43
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
44
+ "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
45
+ "deepseek-ai/DeepSeek-R1-Distill-Llama-8B",
46
+ "deepseek-ai/DeepSeek-Coder-V2-Instruct",
47
+ "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
48
+
49
+ # Meta Llama Models (Working variants)
50
  "meta-llama/Meta-Llama-3.1-70B-Instruct",
51
  "meta-llama/Meta-Llama-3.1-8B-Instruct",
52
+ "meta-llama/Llama-3.2-3B-Instruct",
53
+ "meta-llama/Llama-3.2-1B-Instruct",
54
+ "meta-llama/Llama-3.3-70B-Instruct",
55
+
56
+ # Alibaba Models
57
+ "Qwen/Qwen-72B-Chat",
58
+ "Qwen/Qwen-14B-Chat",
59
+ "Qwen/Qwen-7B-Chat",
60
  ]
61
 
62
  # Model recommendations for different use cases
63
  MODEL_RECOMMENDATIONS = {
64
  "fast": [
65
+ "Qwen/Qwen2.5-7B-Instruct",
66
+ "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
67
+ "meta-llama/Llama-3.2-1B-Instruct",
68
+ "meta-llama/Llama-3.2-3B-Instruct",
69
+ "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
70
  ],
71
  "balanced": [
72
+ "Qwen/Qwen2.5-Coder-32B-Instruct",
73
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
74
+ "Qwen/QwQ-32B-Preview",
75
+ "Qwen/Qwen2.5-14B-Instruct",
76
+ "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",
77
  ],
78
  "quality": [
79
+ "Qwen/Qwen2.5-72B-Instruct",
80
+ "deepseek-ai/DeepSeek-V3",
81
  "meta-llama/Meta-Llama-3.1-70B-Instruct",
82
+ "meta-llama/Llama-3.3-70B-Instruct",
83
+ "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
84
  ],
85
+ "code_specialized": [
86
+ "Qwen/Qwen2.5-Coder-32B-Instruct",
87
+ "deepseek-ai/DeepSeek-Coder-V2-Instruct",
88
+ "deepseek-ai/DeepSeek-V3",
89
+ "Qwen/QwQ-32B-Preview",
90
+ ]
91
  }
92
 
93
  # Timeouts and retries
 
151
  # Try a fallback model
152
  fallback_models = {
153
  "vision": ["Qwen/Qwen2.5-VL-7B-Instruct"],
154
+ "code": ["Qwen/Qwen2.5-7B-Instruct", "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"],
155
  }
156
 
157
  # Detect model type and use appropriate fallback
 
627
  THEME_TEXT = "#1F2937"
628
  THEME_MUTED = "#6B7280"
629
  THEME_BORDER = "#E5E7EB"
630
+ THEME_SUCCESS = "#10B981"
631
  THEME_GRADIENT = f"linear-gradient(135deg, {THEME_PRIMARY} 0%, {THEME_SECONDARY} 100%)"
632
 
633
  custom_css = f"""
 
639
  --text: {THEME_TEXT};
640
  --muted: {THEME_MUTED};
641
  --border: {THEME_BORDER};
642
+ --success: {THEME_SUCCESS};
643
  }}
644
 
645
  body {{
 
707
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15) !important;
708
  }}
709
 
710
+ .success-badge {{
711
+ background: var(--success);
712
  color: white;
713
+ padding: 2px 8px;
714
+ border-radius: 4px;
715
+ font-size: 12px;
716
+ font-weight: 600;
717
+ display: inline-block;
718
+ margin-left: 8px;
719
+ }}
720
+
721
+ .model-count {{
722
+ background: {THEME_GRADIENT};
723
+ color: white;
724
+ padding: 4px 12px;
725
+ border-radius: 20px;
726
+ font-weight: 600;
727
+ display: inline-block;
728
  margin: 8px 0;
729
  }}
730
  """
 
740
  Transform website screenshots into functional HTML code using Nebius AI models.
741
 
742
  ### Key Features:
743
+ - Vision Analysis with Qwen VL models (4 variants)
744
+ - Code Generation with 24+ verified working models
745
  - Single-file HTML output with inline CSS
746
  - Direct CodeSandbox deployment
747
  - Automatic fallback for unavailable models
 
751
 
752
  with gr.Accordion("Configuration", open=True):
753
  gr.Markdown(
754
+ f"""
755
+ Configure your API settings and model preferences.
756
+ <span class="model-count">{len(CODE_MODELS)} Code Models Available</span>
757
+ <span class="model-count">{len(VISION_MODELS)} Vision Models Available</span>
758
  """,
759
  elem_classes=["muted"]
760
  )
 
772
  choices=VISION_MODELS,
773
  value=DEFAULT_VISION_MODEL,
774
  allow_custom_value=True,
775
+ info="Qwen VL models for image analysis",
776
  )
777
  code_model_dd = gr.Dropdown(
778
  label="Code Model",
779
  choices=CODE_MODELS,
780
  value=DEFAULT_CODE_MODEL,
781
  allow_custom_value=True,
782
+ info="24+ verified working models",
783
  )
784
 
785
  with gr.Row():
 
799
  value=0.7,
800
  info="Creativity level",
801
  )
802
+
803
+ # Quick model selection buttons
804
+ gr.Markdown("**Quick Select:**")
805
+ with gr.Row():
806
+ fast_btn = gr.Button("Fast Models", size="sm", elem_classes=["secondary-btn"])
807
+ balanced_btn = gr.Button("Balanced Models", size="sm", elem_classes=["secondary-btn"])
808
+ quality_btn = gr.Button("Quality Models", size="sm", elem_classes=["secondary-btn"])
809
+ code_spec_btn = gr.Button("Code Specialized", size="sm", elem_classes=["secondary-btn"])
810
+
811
+ def set_fast_models():
812
+ return MODEL_RECOMMENDATIONS["fast"][0]
813
+
814
+ def set_balanced_models():
815
+ return MODEL_RECOMMENDATIONS["balanced"][0]
816
+
817
+ def set_quality_models():
818
+ return MODEL_RECOMMENDATIONS["quality"][0]
819
+
820
+ def set_code_models():
821
+ return MODEL_RECOMMENDATIONS["code_specialized"][0]
822
+
823
+ fast_btn.click(fn=set_fast_models, outputs=[code_model_dd])
824
+ balanced_btn.click(fn=set_balanced_models, outputs=[code_model_dd])
825
+ quality_btn.click(fn=set_quality_models, outputs=[code_model_dd])
826
+ code_spec_btn.click(fn=set_code_models, outputs=[code_model_dd])
827
 
828
  with gr.Tab("Generate"):
829
  with gr.Row():
 
897
 
898
  with gr.Tab("Models"):
899
  gr.Markdown(
900
+ f"""
901
+ ## Verified Working Models on Nebius
902
 
903
+ Total: **{len(CODE_MODELS) + len(VISION_MODELS)} models** available
904
+
905
+ ### Vision Models ({len(VISION_MODELS)} models)
906
+ - **Qwen/Qwen2.5-VL-72B-Instruct** - Highest quality vision analysis
907
  - **Qwen/Qwen2.5-VL-7B-Instruct** - Fast vision processing
908
+ - **Qwen/Qwen2-VL-72B-Instruct** - Previous generation, still excellent
909
+ - **Qwen/Qwen2-VL-7B-Instruct** - Previous generation, fast
910
 
911
+ ### Code Generation Models ({len(CODE_MODELS)} models)
912
 
913
+ #### Qwen Models (9 models)
914
  - **Qwen/Qwen2.5-72B-Instruct** - Best overall quality
915
+ - **Qwen/Qwen2.5-Coder-32B-Instruct** - Optimized for code generation
916
+ - **Qwen/Qwen2.5-32B-Instruct** - Balanced size and performance
917
+ - **Qwen/Qwen2.5-14B-Instruct** - Good balance
918
  - **Qwen/Qwen2.5-7B-Instruct** - Fast generation
919
+ - **Qwen/QwQ-32B-Preview** - Advanced reasoning model
920
+ - **Qwen/Qwen-72B-Chat** - Large chat model
921
+ - **Qwen/Qwen-14B-Chat** - Medium chat model
922
+ - **Qwen/Qwen-7B-Chat** - Fast chat model
923
 
924
+ #### DeepSeek Models (8 models)
925
+ - **deepseek-ai/DeepSeek-V3** - State-of-the-art code generation
926
+ - **deepseek-ai/DeepSeek-R1-Distill-Qwen-32B** - Distilled from R1, Qwen base
927
+ - **deepseek-ai/DeepSeek-R1-Distill-Qwen-14B** - Medium distilled model
928
+ - **deepseek-ai/DeepSeek-R1-Distill-Qwen-7B** - Fast distilled model
929
+ - **deepseek-ai/DeepSeek-R1-Distill-Llama-70B** - Large Llama-based distillation
930
+ - **deepseek-ai/DeepSeek-R1-Distill-Llama-8B** - Fast Llama-based
931
+ - **deepseek-ai/DeepSeek-Coder-V2-Instruct** - Specialized for code
932
+ - **deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct** - Lightweight coder
 
 
 
933
 
934
+ #### Meta Llama Models (5 models)
935
+ - **meta-llama/Llama-3.3-70B-Instruct** - Latest Llama 3.3
936
  - **meta-llama/Meta-Llama-3.1-70B-Instruct** - High quality
937
+ - **meta-llama/Meta-Llama-3.1-8B-Instruct** - Fast Llama
938
+ - **meta-llama/Llama-3.2-3B-Instruct** - Ultra-fast
939
+ - **meta-llama/Llama-3.2-1B-Instruct** - Smallest and fastest
940
 
941
  ### Recommendations by Use Case
942
 
943
+ **For Speed:** Llama-3.2-1B/3B, Qwen-7B, DeepSeek-Lite
944
+ **For Quality:** Qwen-72B, DeepSeek-V3, Llama-3.3-70B
945
+ **For Code:** DeepSeek-Coder models, Qwen-Coder-32B, QwQ-32B
946
+ **For Balance:** Qwen-14B/32B models, DeepSeek-R1-Distill variants
947
  """,
948
  elem_classes=["section"]
949
  )