SHIKARICHACHA commited on
Commit
d22ab04
·
verified ·
1 Parent(s): 1d84416

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -6,10 +6,10 @@ Generates custom musical exercises with LLM, perfectly fit to user-specified num
6
  AND time signature, guaranteeing exact durations in MIDI and in the UI!
7
 
8
  Major updates:
9
- - Added Gemma and Kimi Dev 72b AI model options
10
- - Added DeepSeek R1 model option
11
  - Added duration sum display in Exercise Data tab
12
  - Shows total duration units (16th notes) for verification
 
13
  - Fixed difficulty level implementation
14
  - Maintained all original functionality
15
  """
@@ -64,10 +64,11 @@ from openai import OpenAI # For API models
64
  MISTRAL_API_URL = "https://api.mistral.ai/v1/chat/completions"
65
  MISTRAL_API_KEY = "yQdfM8MLbX9uhInQ7id4iUTwN4h4pDLX" # Replace with your key
66
  OPENROUTER_API_KEYS = {
 
 
67
  "Gemma": "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",
68
  "Kimi": "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",
69
- "Claude": "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",
70
- "DeepSeek-R1": "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"
71
  }
72
 
73
  SOUNDFONT_URLS = {
@@ -327,7 +328,7 @@ def query_llm(model_name: str, prompt: str, instrument: str, level: str, key: st
327
  print(f"Error querying Mistral API: {e}")
328
  return get_fallback_exercise(instrument, level, key, time_sig, measures)
329
 
330
- elif model_name in ["Gemma", "Kimi", "Claude", "DeepSeek-R1"]:
331
  try:
332
  client = OpenAI(
333
  base_url="https://openrouter.ai/api/v1",
@@ -335,10 +336,11 @@ def query_llm(model_name: str, prompt: str, instrument: str, level: str, key: st
335
  )
336
 
337
  model_map = {
 
 
338
  "Gemma": "google/gemma-3n-e2b-it:free",
339
  "Kimi": "moonshotai/kimi-dev-72b:free",
340
- "Claude": "anthropic/claude-3.5-sonnet:beta",
341
- "DeepSeek-R1": "deepseek/deepseek-r1-0528:free"
342
  }
343
 
344
  completion = client.chat.completions.create(
@@ -436,7 +438,7 @@ def handle_chat(message: str, history: List, instrument: str, level: str, ai_mod
436
  history.append((message, f"Error: {str(e)}"))
437
  return "", history
438
 
439
- elif ai_model in ["Gemma", "Kimi", "Claude", "DeepSeek-R1"]:
440
  try:
441
  client = OpenAI(
442
  base_url="https://openrouter.ai/api/v1",
@@ -444,10 +446,11 @@ def handle_chat(message: str, history: List, instrument: str, level: str, ai_mod
444
  )
445
 
446
  model_map = {
 
 
447
  "Gemma": "google/gemma-3n-e2b-it:free",
448
  "Kimi": "moonshotai/kimi-dev-72b:free",
449
- "Claude": "anthropic/claude-3.5-sonnet:beta",
450
- "DeepSeek-R1": "deepseek/deepseek-r1-0528:free"
451
  }
452
 
453
  completion = client.chat.completions.create(
@@ -486,7 +489,7 @@ def create_ui() -> gr.Blocks:
486
  with gr.Group(visible=True) as params_group:
487
  gr.Markdown("### Exercise Parameters")
488
  ai_model = gr.Radio(
489
- ["Mistral", "Gemma", "Kimi", "Claude", "DeepSeek-R1"],
490
  value="Mistral",
491
  label="AI Model"
492
  )
 
6
  AND time signature, guaranteeing exact durations in MIDI and in the UI!
7
 
8
  Major updates:
9
+ - Added Gemma, Kimi Dev 72b, and Llama 3.1 AI model options
 
10
  - Added duration sum display in Exercise Data tab
11
  - Shows total duration units (16th notes) for verification
12
+ - Added DeepSeek AI model option
13
  - Fixed difficulty level implementation
14
  - Maintained all original functionality
15
  """
 
64
  MISTRAL_API_URL = "https://api.mistral.ai/v1/chat/completions"
65
  MISTRAL_API_KEY = "yQdfM8MLbX9uhInQ7id4iUTwN4h4pDLX" # Replace with your key
66
  OPENROUTER_API_KEYS = {
67
+ "DeepSeek": "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",
68
+ "Claude": "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",
69
  "Gemma": "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",
70
  "Kimi": "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",
71
+ "Llama 3.1": "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"
 
72
  }
73
 
74
  SOUNDFONT_URLS = {
 
328
  print(f"Error querying Mistral API: {e}")
329
  return get_fallback_exercise(instrument, level, key, time_sig, measures)
330
 
331
+ elif model_name in ["DeepSeek", "Claude", "Gemma", "Kimi", "Llama 3.1"]:
332
  try:
333
  client = OpenAI(
334
  base_url="https://openrouter.ai/api/v1",
 
336
  )
337
 
338
  model_map = {
339
+ "DeepSeek": "deepseek/deepseek-chat-v3-0324:free",
340
+ "Claude": "anthropic/claude-3.5-sonnet:beta",
341
  "Gemma": "google/gemma-3n-e2b-it:free",
342
  "Kimi": "moonshotai/kimi-dev-72b:free",
343
+ "Llama 3.1": "meta-llama/llama-3.1-405b-instruct:free"
 
344
  }
345
 
346
  completion = client.chat.completions.create(
 
438
  history.append((message, f"Error: {str(e)}"))
439
  return "", history
440
 
441
+ elif ai_model in ["DeepSeek", "Claude", "Gemma", "Kimi", "Llama 3.1"]:
442
  try:
443
  client = OpenAI(
444
  base_url="https://openrouter.ai/api/v1",
 
446
  )
447
 
448
  model_map = {
449
+ "DeepSeek": "deepseek/deepseek-chat-v3-0324:free",
450
+ "Claude": "anthropic/claude-3.5-sonnet:beta",
451
  "Gemma": "google/gemma-3n-e2b-it:free",
452
  "Kimi": "moonshotai/kimi-dev-72b:free",
453
+ "Llama 3.1": "meta-llama/llama-3.1-405b-instruct:free"
 
454
  }
455
 
456
  completion = client.chat.completions.create(
 
489
  with gr.Group(visible=True) as params_group:
490
  gr.Markdown("### Exercise Parameters")
491
  ai_model = gr.Radio(
492
+ ["Mistral", "DeepSeek", "Claude", "Gemma", "Kimi", "Llama 3.1"],
493
  value="Mistral",
494
  label="AI Model"
495
  )