cstr commited on
Commit
c2a46b3
Β·
verified Β·
1 Parent(s): a0e7edc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -25
app.py CHANGED
@@ -9,6 +9,7 @@ import webbrowser
9
  from huggingface_hub import InferenceClient
10
  from typing import Dict, List, Optional, Tuple
11
  import time
 
12
 
13
  # Set up logging
14
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -527,15 +528,16 @@ with gr.Blocks(css="""
527
  )
528
 
529
  with gr.Column(visible=False) as groq_options:
530
- groq_model = gr.Dropdown(
531
- choices=list(MODEL_CONTEXT_SIZES["Groq API"].keys()),
532
- value="mixtral-8x7b-32768",
533
- label="Groq Model"
534
- )
535
- groq_api_key = gr.Textbox(
536
- label="πŸ”‘ Groq API Key",
537
- type="password"
538
- )
 
539
 
540
  send_to_model_btn = gr.Button("πŸš€ Send to Model", variant="primary")
541
  open_chatgpt_button = gr.Button("🌐 Open ChatGPT")
@@ -808,22 +810,16 @@ with gr.Blocks(css="""
808
  )
809
 
810
  # Download handlers
811
- for btn, elem_id in [
812
- (copy_prompt_button, "generated_prompt"),
813
- (copy_summary_button, "summary_output")
814
- ]:
815
- btn.click(
816
- fn=None,
817
- _js=f"""
818
- () => {{
819
- const el = document.getElementById('{elem_id}');
820
- if (!el) return 'Element not found';
821
- navigator.clipboard.writeText(el.value);
822
- return 'Copied to clipboard!';
823
- }}
824
- """,
825
- outputs=progress_status
826
- )
827
 
828
  def download_file(content: str, prefix: str) -> List[str]:
829
  if not content:
 
9
  from huggingface_hub import InferenceClient
10
  from typing import Dict, List, Optional, Tuple
11
  import time
12
+ from groq import Groq # Import the Groq client
13
 
14
  # Set up logging
15
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
528
  )
529
 
530
  with gr.Column(visible=False) as groq_options:
531
+ groq_model = gr.Dropdown(
532
+ choices=list(model_registry.groq_models.keys()), # Use model_registry.groq_models
533
+ value=list(model_registry.groq_models.keys())[0] if model_registry.groq_models else None, # Set a default value if available
534
+ label="Groq Model"
535
+ )
536
+ groq_api_key = gr.Textbox(
537
+ label="πŸ”‘ Groq API Key",
538
+ type="password"
539
+ )
540
+ groq_refresh_btn = gr.Button("πŸ”„ Refresh Groq Models") # Add refresh button
541
 
542
  send_to_model_btn = gr.Button("πŸš€ Send to Model", variant="primary")
543
  open_chatgpt_button = gr.Button("🌐 Open ChatGPT")
 
810
  )
811
 
812
  # Download handlers
813
+ copy_prompt_button.click(
814
+ fn=None,
815
+ _js=copy_text_js("generated_prompt"), # Use the helper function
816
+ outputs=progress_status
817
+ )
818
+ copy_summary_button.click(
819
+ fn=None,
820
+ _js=copy_text_js("summary_output"), # Use the helper function
821
+ outputs=progress_status
822
+ )
 
 
 
 
 
 
823
 
824
  def download_file(content: str, prefix: str) -> List[str]:
825
  if not content: