marks commited on
Commit
0b6d459
·
1 Parent(s): 8b6570a

Fixed dropdowns

Browse files
Files changed (2) hide show
  1. api_clients.py +5 -7
  2. app.py +1 -1
api_clients.py CHANGED
@@ -55,10 +55,7 @@ class OpenRouterClient:
55
  Fetch available models from OpenRouter API using pydantic models
56
 
57
  Returns:
58
- List of tuples containing (model_id, model_description)
59
-
60
- Raises:
61
- ValueError: If API request fails
62
  """
63
  logger.info("Fetching available models from OpenRouter")
64
  async with self.get_session() as session:
@@ -67,7 +64,7 @@ class OpenRouterClient:
67
  data = await response.json()
68
  models = [OpenRouterModel(**model) for model in data["data"]]
69
  logger.info(f"Successfully fetched {len(models)} models")
70
- return [(model.id, model.name) for model in models]
71
 
72
  @log_async_execution_time(logger)
73
  async def generate_script(self, content: str, prompt: str, model_id: str) -> str:
@@ -142,9 +139,10 @@ class ElevenLabsClient:
142
  try:
143
  voices = elevenlabs.voices()
144
  return [(
145
- voice.voice_id, # Value (hidden from user)
146
  f"{voice.name} ({voice.labels.get('accent', 'No accent')})" +
147
- (f" - {voice.description[:50]}..." if voice.description else "")
 
148
  ) for voice in voices]
149
  except Exception as e:
150
  logger.error("Failed to fetch voices from ElevenLabs", exc_info=True)
 
55
  Fetch available models from OpenRouter API using pydantic models
56
 
57
  Returns:
58
+ List of tuples containing (model_id, model_id) where both values are the same
 
 
 
59
  """
60
  logger.info("Fetching available models from OpenRouter")
61
  async with self.get_session() as session:
 
64
  data = await response.json()
65
  models = [OpenRouterModel(**model) for model in data["data"]]
66
  logger.info(f"Successfully fetched {len(models)} models")
67
+ return [(model.name, model.id) for model in models]
68
 
69
  @log_async_execution_time(logger)
70
  async def generate_script(self, content: str, prompt: str, model_id: str) -> str:
 
139
  try:
140
  voices = elevenlabs.voices()
141
  return [(
142
+
143
  f"{voice.name} ({voice.labels.get('accent', 'No accent')})" +
144
+ (f" - {voice.description[:50]}..." if voice.description else ""),
145
+ voice.voice_id # Value (hidden from user)
146
  ) for voice in voices]
147
  except Exception as e:
148
  logger.error("Failed to fetch voices from ElevenLabs", exc_info=True)
app.py CHANGED
@@ -66,7 +66,7 @@ class PodcasterUI:
66
  with gr.Column():
67
  openrouter_model = gr.Dropdown(
68
  label='AI Model',
69
- choices=[(id, name) for id, name in self.models],
70
  value=self.models[0][0] if len(self.models) > 1 else None,
71
  )
72
 
 
66
  with gr.Column():
67
  openrouter_model = gr.Dropdown(
68
  label='AI Model',
69
+ choices=self.models, # Each choice now has same id/display value
70
  value=self.models[0][0] if len(self.models) > 1 else None,
71
  )
72