victor HF staff commited on
Commit
bc6b1cc
·
1 Parent(s): 9b7d21e

refactor: Improve model configuration formatting and ensure consistent API key retrieval

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -16,18 +16,18 @@ import shutil
16
  MODELS = {
17
  "Qwen/Qwen2.5-Coder-32B-Instruct": {
18
  "base_url": "https://api-inference.huggingface.co/v1/",
19
- "env_key": "HF_TOKEN"
20
  },
21
  "deepseek-ai/DeepSeek-V3": {
22
  "base_url": "https://api.deepseek.com/v1",
23
- "env_key": "DEEPSEEK_API_KEY"
24
- }
25
  }
26
 
27
  # Initialize client with first available model
28
  client = OpenAI(
29
  base_url=next(iter(MODELS.values()))["base_url"],
30
- api_key=os.environ[next(iter(MODELS.values()))["env_key"]]
31
  )
32
 
33
  allowed_medias = [
@@ -169,7 +169,7 @@ YOUR FFMPEG COMMAND:
169
 
170
  if model_choice not in MODELS:
171
  raise ValueError(f"Model {model_choice} is not supported")
172
-
173
  model_config = MODELS[model_choice]
174
  client.base_url = model_config["base_url"]
175
  client.api_key = os.environ[model_config["env_key"]]
@@ -347,7 +347,11 @@ with gr.Blocks() as demo:
347
  "Use the image as the background with a waveform visualization for the audio positioned in center of the video. Make sure the waveform has a max height of 250 pixels.",
348
  0.7,
349
  0.1,
350
- list(MODELS.keys())[1] if len(MODELS) > 1 else list(MODELS.keys())[0],
 
 
 
 
351
  ],
352
  [
353
  [
 
16
  MODELS = {
17
  "Qwen/Qwen2.5-Coder-32B-Instruct": {
18
  "base_url": "https://api-inference.huggingface.co/v1/",
19
+ "env_key": "HF_TOKEN",
20
  },
21
  "deepseek-ai/DeepSeek-V3": {
22
  "base_url": "https://api.deepseek.com/v1",
23
+ "env_key": "DEEPSEEK_API_KEY",
24
+ },
25
  }
26
 
27
  # Initialize client with first available model
28
  client = OpenAI(
29
  base_url=next(iter(MODELS.values()))["base_url"],
30
+ api_key=os.environ[next(iter(MODELS.values()))["env_key"]],
31
  )
32
 
33
  allowed_medias = [
 
169
 
170
  if model_choice not in MODELS:
171
  raise ValueError(f"Model {model_choice} is not supported")
172
+
173
  model_config = MODELS[model_choice]
174
  client.base_url = model_config["base_url"]
175
  client.api_key = os.environ[model_config["env_key"]]
 
347
  "Use the image as the background with a waveform visualization for the audio positioned in center of the video. Make sure the waveform has a max height of 250 pixels.",
348
  0.7,
349
  0.1,
350
+ (
351
+ list(MODELS.keys())[1]
352
+ if len(MODELS) > 1
353
+ else list(MODELS.keys())[0]
354
+ ),
355
  ],
356
  [
357
  [