akhaliq HF staff commited on
Commit
890265a
1 Parent(s): 5602524
Files changed (2) hide show
  1. app.py +37 -99
  2. utils.py +6 -4
app.py CHANGED
@@ -1,5 +1,6 @@
1
- import gradio as gr
2
 
 
3
  from app_cohere import demo as demo_cohere
4
  from app_meta import demo as demo_meta
5
  from app_lumaai import demo as demo_lumaai
@@ -28,105 +29,42 @@ from app_xai import demo as demo_grok
28
  from app_showui import demo as demo_showui
29
  from app_omini import demo as demo_omini
30
 
31
- with gr.Blocks(fill_height=True) as demo:
32
- with gr.Tab("Gemini"):
33
- demo_gemini.render()
34
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>")
35
- with gr.Tab("Grok"):
36
- demo_grok.render()
37
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>")
38
- with gr.Tab("Cohere"):
39
- demo_cohere.render()
40
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>")
41
- with gr.Tab("SambaNova (New QwQ-32B-Preview)"):
42
- demo_sambanova.render()
43
- gr.Markdown(
44
- """
45
- **Note:** You need to use a SambaNova API key from [SambaNova Cloud](https://cloud.sambanova.ai/).
46
-
47
- This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.
48
- """
49
- )
50
- with gr.Tab("Hyperbolic (New Meta Llama 3.3 70B)"):
51
- demo_hyperbolic.render()
52
- gr.Markdown(
53
- """
54
- <div>
55
- <img src="https://storage.googleapis.com/public-arena-asset/hyperbolic_logo.png" alt="Hyperbolic Logo" style="height: 50px; margin-right: 10px;">
56
- </div>
 
 
 
 
57
 
58
- **Note:** This model is supported by Hyperbolic. Build your AI apps at [Hyperbolic](https://app.hyperbolic.xyz/).
59
-
60
- This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.
61
- """
62
- )
63
- with gr.Tab("OminiControl"):
64
- demo_omini.render()
65
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
66
- with gr.Tab("Fireworks (New Meta Llama 3.3 70B)"):
67
- demo_fireworks.render()
68
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
69
- with gr.Tab("Together (New Meta Llama 3.3 70B)"):
70
- demo_together.render()
71
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
72
- with gr.Tab("Groq (New Meta Llama 3.3 70B)"):
73
- demo_groq.render()
74
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
75
- with gr.Tab("Hugging Face (New Meta Llama 3.3 70B)"):
76
- demo_meta.render()
77
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
78
- with gr.Tab("LumaAI"):
79
- demo_lumaai.render()
80
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio.<img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>")
81
- with gr.Tab("Paligemma 2"):
82
- gr.Markdown("paligemma2-10b-ft-docci-448 is a fine-tuned version of Paligemma 2 on the DOCCI dataset, which can accomplish a wide range of captioning tasks, including text rendering, capturing spatial relations, and including world knowledge in captions.")
83
- demo_paligemma.render()
84
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
85
- with gr.Tab("Qwen"):
86
- demo_qwen.render()
87
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
88
- with gr.Tab("Replicate"):
89
- demo_replicate.render()
90
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
91
- with gr.Tab("Sailor"):
92
- demo_sailor.render()
93
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
94
- with gr.Tab("Huggingface"):
95
- demo_huggingface.render()
96
- with gr.Tab("Fal"):
97
- demo_fal.render()
98
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
99
- with gr.Tab("ShowUI"):
100
- demo_showui.render()
101
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
102
- with gr.Tab("PlayAI"):
103
- demo_playai.render()
104
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
105
- with gr.Tab("ChatGPT"):
106
- demo_openai.render()
107
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
108
- with gr.Tab("Claude"):
109
- demo_claude.render()
110
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
111
- with gr.Tab("Allen AI"):
112
- demo_allenai.render()
113
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
114
- with gr.Tab("Perplexity"):
115
- demo_perplexity.render()
116
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
117
- with gr.Tab("Experimental"):
118
- demo_experimental.render()
119
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
120
- with gr.Tab("Marco-o1"):
121
- demo_marco_o1.render()
122
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
123
- with gr.Tab("Mistral"):
124
- demo_mistral.render()
125
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
126
- with gr.Tab("NVIDIA"):
127
- demo_nvidia.render()
128
- gr.Markdown("This app is built with gradio, check out gradio github and star: <a href='https://github.com/gradio-app/gradio'>Gradio <img src='https://img.shields.io/github/stars/gradio-app/gradio'></a>.")
129
-
130
 
131
  if __name__ == "__main__":
132
  demo.queue(api_open=False).launch(show_api=False)
 
1
+ from utils import get_app
2
 
3
+ # Import all demos
4
  from app_cohere import demo as demo_cohere
5
  from app_meta import demo as demo_meta
6
  from app_lumaai import demo as demo_lumaai
 
29
  from app_showui import demo as demo_showui
30
  from app_omini import demo as demo_omini
31
 
32
+ # Create mapping of models to their demos
33
+ DEMOS = {
34
+ "Gemini": demo_gemini,
35
+ "Grok": demo_grok,
36
+ "Cohere": demo_cohere,
37
+ "SambaNova": demo_sambanova,
38
+ "Hyperbolic": demo_hyperbolic,
39
+ "OminiControl": demo_omini,
40
+ "Fireworks": demo_fireworks,
41
+ "Together": demo_together,
42
+ "Groq": demo_groq,
43
+ "Meta Llama": demo_meta,
44
+ "LumaAI": demo_lumaai,
45
+ "Paligemma": demo_paligemma,
46
+ "Qwen": demo_qwen,
47
+ "Replicate": demo_replicate,
48
+ "Huggingface": demo_huggingface,
49
+ "Fal": demo_fal,
50
+ "ShowUI": demo_showui,
51
+ "PlayAI": demo_playai,
52
+ "ChatGPT": demo_openai,
53
+ "Claude": demo_claude,
54
+ "Allen AI": demo_allenai,
55
+ "Perplexity": demo_perplexity,
56
+ "Experimental": demo_experimental,
57
+ "Mistral": demo_mistral,
58
+ "NVIDIA": demo_nvidia,
59
+ "Marco-o1": demo_marco_o1,
60
+ "Sailor": demo_sailor,
61
+ }
62
 
63
+ demo = get_app(
64
+ models=list(DEMOS.keys()),
65
+ default_model="Gemini",
66
+ src=DEMOS,
67
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  if __name__ == "__main__":
70
  demo.queue(api_open=False).launch(show_api=False)
utils.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Callable, Literal
2
 
3
  import gradio as gr
4
 
@@ -6,7 +6,7 @@ import gradio as gr
6
  def get_app(
7
  models: list[str],
8
  default_model: str,
9
- src: Callable[[str, str | None], gr.Blocks] | Literal["models"],
10
  accept_token: bool = False,
11
  **kwargs,
12
  ) -> gr.Blocks:
@@ -19,8 +19,10 @@ def get_app(
19
  columns = []
20
  for model_name in models:
21
  with gr.Column(visible=model_name == default_model) as column:
22
- gr.load(name=model_name, src=src, accept_token=accept_token, **kwargs)
23
-
 
 
24
  columns.append(column)
25
 
26
  model.change(
 
1
+ from typing import Callable, Literal, Dict, Union
2
 
3
  import gradio as gr
4
 
 
6
  def get_app(
7
  models: list[str],
8
  default_model: str,
9
+ src: Union[Callable[[str, str | None], gr.Blocks], Literal["models"], Dict[str, gr.Blocks]],
10
  accept_token: bool = False,
11
  **kwargs,
12
  ) -> gr.Blocks:
 
19
  columns = []
20
  for model_name in models:
21
  with gr.Column(visible=model_name == default_model) as column:
22
+ if isinstance(src, dict):
23
+ src[model_name].render()
24
+ else:
25
+ gr.load(name=model_name, src=src, accept_token=accept_token, **kwargs)
26
  columns.append(column)
27
 
28
  model.change(