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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -46
app.py CHANGED
@@ -21,6 +21,7 @@ DEFAULT_VISION_MODEL = "Qwen/Qwen2.5-VL-72B-Instruct"
21
  VISION_MODELS = [
22
  DEFAULT_VISION_MODEL,
23
  "Qwen/Qwen2.5-VL-7B-Instruct",
 
24
  ]
25
 
26
  # Code generation models confirmed to work on Nebius
@@ -34,13 +35,35 @@ CODE_MODELS = [
34
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
35
  "meta-llama/Meta-Llama-3.1-70B-Instruct",
36
  "meta-llama/Meta-Llama-3.1-8B-Instruct",
 
 
 
 
 
 
37
  ]
38
 
39
- # Performance recommendations based on working models
40
  MODEL_RECOMMENDATIONS = {
41
- "fast": ["Qwen/Qwen2.5-7B-Instruct", "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", "meta-llama/Meta-Llama-3.1-8B-Instruct"],
42
- "balanced": ["Qwen/Qwen2.5-Coder-32B-Instruct", "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"],
43
- "quality": ["Qwen/Qwen2.5-72B-Instruct", "deepseek-ai/DeepSeek-V3", "meta-llama/Meta-Llama-3.1-70B-Instruct"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
 
46
  # Timeouts and retries
@@ -104,7 +127,7 @@ def call_chat_completions(
104
  # Try a fallback model
105
  fallback_models = {
106
  "vision": ["Qwen/Qwen2.5-VL-7B-Instruct"],
107
- "code": ["Qwen/Qwen2.5-7B-Instruct"],
108
  }
109
 
110
  # Detect model type and use appropriate fallback
@@ -570,19 +593,6 @@ def export_html_to_file(html_code: str) -> Optional[str]:
570
  return None
571
 
572
 
573
- def get_model_recommendations(performance_tier: str) -> Tuple[str, str]:
574
- """
575
- Get recommended models based on performance tier.
576
- Returns (vision_model, code_model)
577
- """
578
- tier_map = {
579
- "Fast (7B-8B models)": ("Qwen/Qwen2.5-VL-7B-Instruct", "Qwen/Qwen2.5-7B-Instruct"),
580
- "Balanced (32B models)": ("Qwen/Qwen2.5-VL-7B-Instruct", "Qwen/Qwen2.5-Coder-32B-Instruct"),
581
- "Quality (70B+ models)": ("Qwen/Qwen2.5-VL-72B-Instruct", "Qwen/Qwen2.5-72B-Instruct"),
582
- }
583
- return tier_map.get(performance_tier, (DEFAULT_VISION_MODEL, DEFAULT_CODE_MODEL))
584
-
585
-
586
  # =========================
587
  # Gradio UI
588
  # =========================
@@ -670,6 +680,14 @@ custom_css = f"""
670
  border-color: {THEME_PRIMARY} !important;
671
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15) !important;
672
  }}
 
 
 
 
 
 
 
 
673
  """
674
 
675
  with gr.Blocks(
@@ -683,8 +701,8 @@ with gr.Blocks(
683
  Transform website screenshots into functional HTML code using Nebius AI models.
684
 
685
  ### Key Features:
686
- - Vision Analysis with Qwen VL models
687
- - Code Generation with Qwen, DeepSeek, and Llama models
688
  - Single-file HTML output with inline CSS
689
  - Direct CodeSandbox deployment
690
  - Automatic fallback for unavailable models
@@ -696,23 +714,17 @@ Transform website screenshots into functional HTML code using Nebius AI models.
696
  gr.Markdown(
697
  """
698
  Configure your API settings and model preferences. A default API key is provided for testing.
 
699
  """,
700
  elem_classes=["muted"]
701
  )
702
 
703
- with gr.Row():
704
- nebius_key = gr.Textbox(
705
- label="Nebius API Key",
706
- type="password",
707
- placeholder="Enter your Nebius API key or use default",
708
- value=DEFAULT_NEBIUS_API_KEY,
709
- )
710
- performance_tier = gr.Radio(
711
- label="Performance Tier",
712
- choices=["Fast (7B-8B models)", "Balanced (32B models)", "Quality (70B+ models)"],
713
- value="Balanced (32B models)",
714
- info="Select based on speed vs quality preference"
715
- )
716
 
717
  with gr.Row():
718
  vision_model_dd = gr.Dropdown(
@@ -720,7 +732,7 @@ Transform website screenshots into functional HTML code using Nebius AI models.
720
  choices=VISION_MODELS,
721
  value=DEFAULT_VISION_MODEL,
722
  allow_custom_value=True,
723
- info="Model for image analysis",
724
  )
725
  code_model_dd = gr.Dropdown(
726
  label="Code Model",
@@ -747,12 +759,6 @@ Transform website screenshots into functional HTML code using Nebius AI models.
747
  value=0.7,
748
  info="Creativity level",
749
  )
750
-
751
- performance_tier.change(
752
- fn=get_model_recommendations,
753
- inputs=[performance_tier],
754
- outputs=[vision_model_dd, code_model_dd]
755
- )
756
 
757
  with gr.Tab("Generate"):
758
  with gr.Row():
@@ -827,26 +833,43 @@ Transform website screenshots into functional HTML code using Nebius AI models.
827
  with gr.Tab("Models"):
828
  gr.Markdown(
829
  """
830
- ## Working Models on Nebius
831
 
832
  ### Vision Models
833
  - **Qwen/Qwen2.5-VL-72B-Instruct** - High quality vision analysis
834
  - **Qwen/Qwen2.5-VL-7B-Instruct** - Fast vision processing
 
 
 
835
 
836
- ### Code Generation Models
837
  - **Qwen/Qwen2.5-72B-Instruct** - Best overall quality
838
  - **Qwen/Qwen2.5-Coder-32B-Instruct** - Optimized for code
839
  - **Qwen/Qwen2.5-7B-Instruct** - Fast generation
 
 
840
  - **deepseek-ai/DeepSeek-V3** - Advanced code generation
841
  - **deepseek-ai/DeepSeek-R1-Distill-Qwen-32B** - Balanced performance
842
  - **deepseek-ai/DeepSeek-R1-Distill-Qwen-7B** - Fast alternative
 
 
 
 
 
 
 
 
 
 
843
  - **meta-llama/Meta-Llama-3.1-70B-Instruct** - High quality
844
  - **meta-llama/Meta-Llama-3.1-8B-Instruct** - Fast Llama option
845
 
846
- ### Tips
847
- - Start with Balanced tier for best results
848
- - Use Fast tier for quick prototypes
849
- - Quality tier for production-ready code
 
 
850
  """,
851
  elem_classes=["section"]
852
  )
 
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
 
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
  # 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
 
593
  return None
594
 
595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  # =========================
597
  # Gradio UI
598
  # =========================
 
680
  border-color: {THEME_PRIMARY} !important;
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
  """
692
 
693
  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
 
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
  )
721
 
722
+ nebius_key = gr.Textbox(
723
+ label="Nebius API Key",
724
+ type="password",
725
+ placeholder="Enter your Nebius API key or use default",
726
+ value=DEFAULT_NEBIUS_API_KEY,
727
+ )
 
 
 
 
 
 
 
728
 
729
  with gr.Row():
730
  vision_model_dd = gr.Dropdown(
 
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",
 
759
  value=0.7,
760
  info="Creativity level",
761
  )
 
 
 
 
 
 
762
 
763
  with gr.Tab("Generate"):
764
  with gr.Row():
 
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
  )