Spaces:
Running on CPU Upgrade

app.py CHANGED
@@ -1,58 +1,71 @@
1
- from app_huggingface import demo as demo_huggingface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from utils import get_app
3
- import gradio as gr
4
-
5
- # Create mapping of providers to their code snippets
6
- PROVIDER_SNIPPETS = {
7
- "Hugging Face": """
8
- import gradio as gr
9
- import ai_gradio
10
- gr.load(
11
- name='huggingface:deepseek-ai/DeepSeek-R1',
12
- src=ai_gradio.registry,
13
- coder=True,
14
- provider="together"
15
- ).launch()""",
16
- # Add similar snippets for other providers
17
- }
18
 
19
  # Create mapping of providers to their demos
20
  PROVIDERS = {
21
- "Hugging Face": demo_huggingface,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
- # Modified get_app implementation
25
- demo = gr.Blocks()
26
- with demo:
27
- gr.Markdown("# Anychat")
28
-
29
- provider_dropdown = gr.Dropdown(
30
- choices=list(PROVIDERS.keys()),
31
- value="Hugging Face",
32
- label="Select code snippet"
33
- )
34
- code_display = gr.Code(
35
- label="Provider Code Snippet",
36
- language="python",
37
- value=PROVIDER_SNIPPETS["Hugging Face"]
38
- )
39
-
40
- def update_code(provider):
41
- return PROVIDER_SNIPPETS.get(provider, "Code snippet not available")
42
-
43
-
44
- provider_dropdown.change(
45
- fn=update_code,
46
- inputs=[provider_dropdown],
47
- outputs=[code_display]
48
- )
49
-
50
- selected_demo = get_app(
51
- models=list(PROVIDERS.keys()),
52
- default_model="Hugging Face",
53
- src=PROVIDERS,
54
- dropdown_label="Select Provider",
55
- )
56
 
57
  if __name__ == "__main__":
58
- demo.queue(api_open=False).launch(show_api=False)
 
1
+ from app_lumaai import demo as demo_lumaai
2
+ from app_claude import demo as demo_claude
3
+ from app_cohere import demo as demo_cohere
4
+ from app_fal import demo as demo_fal
5
+ from app_fireworks import demo as demo_fireworks
6
+ from app_meta import demo as demo_meta
7
+ from app_perplexity import demo as demo_perplexity
8
+ from app_playai import demo as demo_playai
9
+ from app_replicate import demo as demo_replicate
10
+ from app_sambanova import demo as demo_sambanova
11
+ from app_together import demo as demo_together
12
+ from app_xai import demo as demo_grok
13
+ from app_qwen import demo as demo_qwen
14
+ from app_crew import demo as demo_crew
15
+ from app_hyperbolic import demo as demo_hyperbolic
16
+ from app_gemini_coder import demo as demo_gemini_coder
17
+ from app_gemini import demo as demo_gemini
18
+ from app_hyperbolic_coder import demo as demo_hyperbolic_coder
19
+ from app_smolagents import demo as demo_smolagents
20
+ from app_groq import demo as demo_groq
21
+ from app_groq_coder import demo as demo_groq_coder
22
+ from app_openai_coder import demo as demo_openai_coder
23
+ from app_langchain import demo as demo_langchain
24
+ from app_mistral import demo as demo_mistral
25
+ from app_minimax import demo as demo_minimax
26
+ from app_minimax_coder import demo as demo_minimax_coder
27
+ from app_nvidia import demo as demo_nvidia
28
+ from app_deepseek import demo as demo_deepseek
29
  from utils import get_app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  # Create mapping of providers to their demos
32
  PROVIDERS = {
33
+ "Gemini Coder": demo_gemini_coder,
34
+ "Groq Coder": demo_groq_coder,
35
+ "DeepSeek Coder": demo_deepseek,
36
+ "Minimax Coder": demo_minimax_coder,
37
+ "NVIDIA": demo_nvidia,
38
+ "Minimax": demo_minimax,
39
+ "Mistral": demo_mistral,
40
+ "Langchain Agent": demo_langchain,
41
+ "OpenAI Coder": demo_openai_coder,
42
+ "Gemini": demo_gemini,
43
+ "Hyperbolic Coder": demo_hyperbolic_coder,
44
+ "SmolAgents": demo_smolagents,
45
+ "Qwen": demo_qwen,
46
+ "Hyperbolic": demo_hyperbolic,
47
+ "CrewAI": demo_crew,
48
+ "LumaAI": demo_lumaai,
49
+ "Grok": demo_grok,
50
+ "Cohere": demo_cohere,
51
+ "SambaNova": demo_sambanova,
52
+ "Fireworks": demo_fireworks,
53
+ "Together": demo_together,
54
+ "Groq": demo_groq,
55
+ "Meta Llama": demo_meta,
56
+ "Replicate": demo_replicate,
57
+ "Fal": demo_fal,
58
+ "PlayAI": demo_playai,
59
+ "Claude": demo_claude,
60
+ "Perplexity": demo_perplexity,
61
  }
62
 
63
+ demo = get_app(
64
+ models=list(PROVIDERS.keys()),
65
+ default_model="Gemini Coder",
66
+ src=PROVIDERS,
67
+ dropdown_label="Select Provider",
68
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  if __name__ == "__main__":
71
+ demo.queue(api_open=False).launch(show_api=False)
app_gemini_coder.py CHANGED
@@ -11,7 +11,7 @@ GEMINI_MODELS_DISPLAY = [k.replace("gemini:", "") for k in GEMINI_MODELS_FULL]
11
  # Create and launch the interface using get_app utility
12
  demo = get_app(
13
  models=GEMINI_MODELS_FULL, # Use the full names with prefix
14
- default_model=GEMINI_MODELS_FULL[-2],
15
  dropdown_label="Select Gemini Model",
16
  choices=GEMINI_MODELS_DISPLAY, # Display names without prefix
17
  src=ai_gradio.registry,
 
11
  # Create and launch the interface using get_app utility
12
  demo = get_app(
13
  models=GEMINI_MODELS_FULL, # Use the full names with prefix
14
+ default_model=GEMINI_MODELS_FULL[-1],
15
  dropdown_label="Select Gemini Model",
16
  choices=GEMINI_MODELS_DISPLAY, # Display names without prefix
17
  src=ai_gradio.registry,
app_huggingface.py CHANGED
@@ -1,21 +1,67 @@
1
- import ai_gradio
 
2
 
3
- from utils_ai_gradio import get_app
4
 
5
- # Get the hyperbolic models but keep their full names for loading
6
- HUGGINGFACE_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("huggingface:")]
7
 
8
- # Create display names without the prefix
9
- HUGGINGFACE_MODELS_DISPLAY = [k.replace("huggingface:", "") for k in HUGGINGFACE_MODELS_FULL]
 
 
 
10
 
 
 
11
 
12
- # Create and launch the interface using get_app utility
13
- demo = get_app(
14
- models=HUGGINGFACE_MODELS_FULL, # Use the full names with prefix
15
- default_model=HUGGINGFACE_MODELS_FULL[0],
16
- dropdown_label="Select Huggingface Model",
17
- choices=HUGGINGFACE_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
19
- coder=True,
20
- provider="fireworks-ai"
21
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_client import Client, handle_file
3
 
4
+ MODELS = {"SmolVLM-Instruct": "akhaliq/SmolVLM-Instruct"}
5
 
 
 
6
 
7
+ def create_chat_fn(client):
8
+ def chat(message, history):
9
+ # Extract text and files from the message
10
+ text = message.get("text", "")
11
+ files = message.get("files", [])
12
 
13
+ # Handle file uploads if present
14
+ processed_files = [handle_file(f) for f in files]
15
 
16
+ response = client.predict(
17
+ message={"text": text, "files": processed_files},
18
+ system_prompt="You are a helpful AI assistant.",
19
+ temperature=0.7,
20
+ max_new_tokens=1024,
21
+ top_k=40,
22
+ repetition_penalty=1.1,
23
+ top_p=0.95,
24
+ api_name="/chat",
25
+ )
26
+ return response
27
+
28
+ return chat
29
+
30
+
31
+ def set_client_for_session(model_name, request: gr.Request):
32
+ headers = {}
33
+ if request and hasattr(request, "headers"):
34
+ x_ip_token = request.headers.get("x-ip-token")
35
+ if x_ip_token:
36
+ headers["X-IP-Token"] = x_ip_token
37
+
38
+ return Client(MODELS[model_name], headers=headers)
39
+
40
+
41
+ def safe_chat_fn(message, history, client):
42
+ if client is None:
43
+ return "Error: Client not initialized. Please refresh the page."
44
+ try:
45
+ return create_chat_fn(client)(message, history)
46
+ except Exception as e:
47
+ print(f"Error during chat: {e!s}")
48
+ return f"Error during chat: {e!s}"
49
+
50
+
51
+ with gr.Blocks() as demo:
52
+ client = gr.State()
53
+
54
+ model_dropdown = gr.Dropdown(
55
+ choices=list(MODELS.keys()), value="SmolVLM-Instruct", label="Select Model", interactive=True
56
+ )
57
+
58
+ chat_interface = gr.ChatInterface(fn=safe_chat_fn, additional_inputs=[client], multimodal=True)
59
+
60
+ # Update client when model changes
61
+ model_dropdown.change(fn=set_client_for_session, inputs=[model_dropdown], outputs=[client])
62
+
63
+ # Initialize client on page load
64
+ demo.load(fn=set_client_for_session, inputs=[gr.State("SmolVLM-Instruct")], outputs=[client])
65
+
66
+ if __name__ == "__main__":
67
+ demo.launch()
app_hyperbolic.py CHANGED
@@ -12,7 +12,7 @@ HYPERBOLIC_MODELS_DISPLAY = [k.replace("hyperbolic:", "") for k in HYPERBOLIC_MO
12
  # Create and launch the interface using get_app utility
13
  demo = get_app(
14
  models=HYPERBOLIC_MODELS_FULL, # Use the full names with prefix
15
- default_model=HYPERBOLIC_MODELS_FULL[-2],
16
  dropdown_label="Select Hyperbolic Model",
17
  choices=HYPERBOLIC_MODELS_DISPLAY, # Display names without prefix
18
  fill_height=True,
 
12
  # Create and launch the interface using get_app utility
13
  demo = get_app(
14
  models=HYPERBOLIC_MODELS_FULL, # Use the full names with prefix
15
+ default_model=HYPERBOLIC_MODELS_FULL[-1],
16
  dropdown_label="Select Hyperbolic Model",
17
  choices=HYPERBOLIC_MODELS_DISPLAY, # Display names without prefix
18
  fill_height=True,
app_hyperbolic_coder.py CHANGED
@@ -12,7 +12,7 @@ HYPERBOLIC_MODELS_DISPLAY = [k.replace("hyperbolic:", "") for k in HYPERBOLIC_MO
12
  # Create and launch the interface using get_app utility
13
  demo = get_app(
14
  models=HYPERBOLIC_MODELS_FULL, # Use the full names with prefix
15
- default_model=HYPERBOLIC_MODELS_FULL[-2],
16
  dropdown_label="Select Hyperbolic Model",
17
  choices=HYPERBOLIC_MODELS_DISPLAY, # Display names without prefix
18
  fill_height=True,
 
12
  # Create and launch the interface using get_app utility
13
  demo = get_app(
14
  models=HYPERBOLIC_MODELS_FULL, # Use the full names with prefix
15
+ default_model=HYPERBOLIC_MODELS_FULL[-1],
16
  dropdown_label="Select Hyperbolic Model",
17
  choices=HYPERBOLIC_MODELS_DISPLAY, # Display names without prefix
18
  fill_height=True,
app_nvidia_coder.py DELETED
@@ -1,23 +0,0 @@
1
- import ai_gradio
2
-
3
- from utils_ai_gradio import get_app
4
-
5
- # Get the nvidia models but keep their full names for loading
6
- NVIDIA_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("nvidia:")]
7
-
8
- # Create display names without the prefix
9
- NVIDIA_MODELS_DISPLAY = [k.replace("nvidia:", "") for k in NVIDIA_MODELS_FULL]
10
-
11
-
12
- # Create and launch the interface using get_app utility
13
- demo = get_app(
14
- models=NVIDIA_MODELS_FULL, # Use the full names with prefix
15
- default_model=NVIDIA_MODELS_FULL[-1],
16
- dropdown_label="Select Nvidia Model",
17
- choices=NVIDIA_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
19
- coder=True
20
- )
21
-
22
- if __name__ == "__main__":
23
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_openai_coder.py CHANGED
@@ -11,7 +11,7 @@ OPENAI_MODELS_DISPLAY = [k.replace("openai:", "") for k in OPENAI_MODELS_FULL]
11
  # Create and launch the interface using get_app utility
12
  demo = get_app(
13
  models=OPENAI_MODELS_FULL, # Use the full names with prefix
14
- default_model=OPENAI_MODELS_FULL[-1],
15
  dropdown_label="Select OpenAI Model",
16
  choices=OPENAI_MODELS_DISPLAY, # Display names without prefix
17
  fill_height=True,
 
11
  # Create and launch the interface using get_app utility
12
  demo = get_app(
13
  models=OPENAI_MODELS_FULL, # Use the full names with prefix
14
+ default_model=OPENAI_MODELS_FULL[5],
15
  dropdown_label="Select OpenAI Model",
16
  choices=OPENAI_MODELS_DISPLAY, # Display names without prefix
17
  fill_height=True,
app_openrouter.py DELETED
@@ -1,22 +0,0 @@
1
- import ai_gradio
2
-
3
- from utils_ai_gradio import get_app
4
-
5
- # Get the OpenAI models but keep their full names for loading
6
- OPENROUTER_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("openrouter:")]
7
-
8
- # Create display names without the prefix
9
- OPENROUTER_MODELS_DISPLAY = [k.replace("openrouter:", "") for k in OPENROUTER_MODELS_FULL]
10
-
11
- # Create and launch the interface using get_app utility
12
- demo = get_app(
13
- models=OPENROUTER_MODELS_FULL, # Use the full names with prefix
14
- default_model=OPENROUTER_MODELS_FULL[-1],
15
- dropdown_label="Select OpenRouter Model",
16
- choices=OPENROUTER_MODELS_DISPLAY, # Display names without prefix
17
- fill_height=True,
18
- coder=True,
19
- )
20
-
21
- if __name__ == "__main__":
22
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_qwen.py CHANGED
@@ -1,19 +1,27 @@
1
- import ai_gradio
2
 
3
- from utils_ai_gradio import get_app
4
 
5
- # Get the qwen models but keep their full names for loading
6
- QWEN_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("qwen:")]
7
 
8
- # Create display names without the prefix
9
- QWEN_MODELS_DISPLAY = [k.replace("qwen:", "") for k in QWEN_MODELS_FULL]
10
-
11
-
12
- # Create and launch the interface using get_app utility
13
  demo = get_app(
14
- models=QWEN_MODELS_FULL, # Use the full names with prefix
15
- default_model=QWEN_MODELS_FULL[-1],
16
- dropdown_label="Select Qwen Model",
17
- choices=QWEN_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
 
 
 
 
 
 
 
 
 
 
 
19
  )
 
 
 
 
1
+ import os
2
 
3
+ import dashscope_gradio
4
 
5
+ from utils import get_app
 
6
 
 
 
 
 
 
7
  demo = get_app(
8
+ models=[
9
+ "qwen-turbo-latest",
10
+ "qwen-turbo",
11
+ "qwen-plus",
12
+ "qwen-max",
13
+ "qwen1.5-110b-chat",
14
+ "qwen1.5-72b-chat",
15
+ "qwen1.5-32b-chat",
16
+ "qwen1.5-14b-chat",
17
+ "qwen1.5-7b-chat",
18
+ "qwq-32b-preview",
19
+ "qvq-72b-preview",
20
+ ],
21
+ default_model="qvq-72b-preview",
22
+ src=dashscope_gradio.registry,
23
+ accept_token=not os.getenv("DASHSCOPE_API_KEY"),
24
  )
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()
app_qwen_coder.py DELETED
@@ -1,20 +0,0 @@
1
- import ai_gradio
2
-
3
- from utils_ai_gradio import get_app
4
-
5
- # Get the qwen models but keep their full names for loading
6
- QWEN_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("qwen:")]
7
-
8
- # Create display names without the prefix
9
- QWEN_MODELS_DISPLAY = [k.replace("qwen:", "") for k in QWEN_MODELS_FULL]
10
-
11
-
12
- # Create and launch the interface using get_app utility
13
- demo = get_app(
14
- models=QWEN_MODELS_FULL, # Use the full names with prefix
15
- default_model=QWEN_MODELS_FULL[-1],
16
- dropdown_label="Select Qwen Model",
17
- choices=QWEN_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
19
- coder=True,
20
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_sambanova.py CHANGED
@@ -1,19 +1,28 @@
1
- import ai_gradio
2
 
3
- from utils_ai_gradio import get_app
4
 
5
- # Get the hyperbolic models but keep their full names for loading
6
- SAMBANOVA_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("sambanova:")]
7
 
8
- # Create display names without the prefix
9
- SAMBANOVA_MODELS_DISPLAY = [k.replace("sambanova:", "") for k in SAMBANOVA_MODELS_FULL]
10
-
11
-
12
- # Create and launch the interface using get_app utility
13
  demo = get_app(
14
- models=SAMBANOVA_MODELS_FULL, # Use the full names with prefix
15
- default_model=SAMBANOVA_MODELS_FULL[-1],
16
- dropdown_label="Select Sambanova Model",
17
- choices=SAMBANOVA_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
19
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
 
3
+ import sambanova_gradio
4
 
5
+ from utils import get_app
 
6
 
 
 
 
 
 
7
  demo = get_app(
8
+ models=[
9
+ "Meta-Llama-3.2-1B-Instruct",
10
+ "Meta-Llama-3.2-3B-Instruct",
11
+ "Llama-3.2-11B-Vision-Instruct",
12
+ "Llama-3.2-90B-Vision-Instruct",
13
+ "Meta-Llama-3.1-8B-Instruct",
14
+ "Meta-Llama-3.1-70B-Instruct",
15
+ "Meta-Llama-3.1-405B-Instruct",
16
+ "Qwen2.5-72B-Instruct",
17
+ "Qwen2.5-Coder-32B-Instruct",
18
+ "Meta-Llama-3.3-70B-Instruct",
19
+ "QwQ-32B-Preview",
20
+ ],
21
+ default_model="QwQ-32B-Preview",
22
+ src=sambanova_gradio.registry,
23
+ accept_token=not os.getenv("SAMBANOVA_API_KEY"),
24
+ multimodal=True,
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()
app_sambanova_coder.py DELETED
@@ -1,20 +0,0 @@
1
- import ai_gradio
2
-
3
- from utils_ai_gradio import get_app
4
-
5
- # Get the hyperbolic models but keep their full names for loading
6
- SAMBANOVA_MODELS_FULL = [k for k in ai_gradio.registry.keys() if k.startswith("sambanova:")]
7
-
8
- # Create display names without the prefix
9
- SAMBANOVA_MODELS_DISPLAY = [k.replace("sambanova:", "") for k in SAMBANOVA_MODELS_FULL]
10
-
11
-
12
- # Create and launch the interface using get_app utility
13
- demo = get_app(
14
- models=SAMBANOVA_MODELS_FULL, # Use the full names with prefix
15
- default_model=SAMBANOVA_MODELS_FULL[-1],
16
- dropdown_label="Select Sambanova Model",
17
- choices=SAMBANOVA_MODELS_DISPLAY, # Display names without prefix
18
- fill_height=True,
19
- coder=True,
20
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pyproject.toml CHANGED
@@ -38,7 +38,7 @@ dependencies = [
38
  "langchain>=0.3.14",
39
  "chromadb>=0.5.23",
40
  "openai>=1.55.0",
41
- "ai-gradio[crewai,deepseek,gemini,groq,hyperbolic,openai,smolagents,transformers, langchain, mistral,minimax,nvidia, qwen, openrouter, huggingface]>=0.2.53",
42
  ]
43
 
44
  [tool.uv.sources]
 
38
  "langchain>=0.3.14",
39
  "chromadb>=0.5.23",
40
  "openai>=1.55.0",
41
+ "ai-gradio[crewai,deepseek,gemini,groq,hyperbolic,openai,smolagents,transformers, langchain, mistral,minimax,nvidia]>=0.2.28",
42
  ]
43
 
44
  [tool.uv.sources]
requirements.txt CHANGED
@@ -2,7 +2,7 @@
2
  # uv pip compile pyproject.toml -o requirements.txt
3
  accelerate==1.2.1
4
  # via ai-gradio
5
- ai-gradio==0.2.53
6
  # via anychat (pyproject.toml)
7
  aiofiles==23.2.1
8
  # via gradio
@@ -428,10 +428,9 @@ httpx-sse==0.4.0
428
  # langchain-community
429
  httpx-ws==0.7.1
430
  # via fireworks-ai
431
- huggingface-hub==0.29.1
432
  # via
433
  # accelerate
434
- # ai-gradio
435
  # gradio
436
  # gradio-client
437
  # tokenizers
 
2
  # uv pip compile pyproject.toml -o requirements.txt
3
  accelerate==1.2.1
4
  # via ai-gradio
5
+ ai-gradio==0.2.28
6
  # via anychat (pyproject.toml)
7
  aiofiles==23.2.1
8
  # via gradio
 
428
  # langchain-community
429
  httpx-ws==0.7.1
430
  # via fireworks-ai
431
+ huggingface-hub==0.27.1
432
  # via
433
  # accelerate
 
434
  # gradio
435
  # gradio-client
436
  # tokenizers