saibafatima commited on
Commit
b8930bb
·
verified ·
1 Parent(s): b6dd15f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -6,7 +6,6 @@ Uses: Groq API (LLM inference) + langdetect (Hugging Face-style language detecti
6
  import gradio as gr
7
  from groq import Groq
8
  from langdetect import detect, DetectorFactory
9
- import pyperclip
10
 
11
  DetectorFactory.seed = 0 # For consistent language detection
12
 
@@ -39,7 +38,7 @@ def translate_text(input_text, source_lang, target_lang):
39
  if target_lang == "Auto-Detect":
40
  return "⚠️ Please select a target language.", ""
41
 
42
- if not GROQ_API_KEY or GROQ_API_KEY == "your_groq_api_key_here":
43
  return "⚠️ Please set your GROQ_API_KEY in the script.", ""
44
 
45
  # Auto-detect source language
@@ -157,13 +156,9 @@ with gr.Blocks(
157
  return "", "", ""
158
 
159
  def copy_output(text):
160
- if text.strip():
161
- try:
162
- pyperclip.copy(text)
163
- return gr.update(value="✅ Copied!", interactive=False)
164
- except Exception:
165
- return gr.update(value="⚠️ Copy failed (run in local env)", interactive=False)
166
- return gr.update(value="📋 Copy to Clipboard")
167
 
168
  translate_btn.click(
169
  fn=do_translate,
 
6
  import gradio as gr
7
  from groq import Groq
8
  from langdetect import detect, DetectorFactory
 
9
 
10
  DetectorFactory.seed = 0 # For consistent language detection
11
 
 
38
  if target_lang == "Auto-Detect":
39
  return "⚠️ Please select a target language.", ""
40
 
41
+ if not GROQ_API_KEY or GROQ_API_KEY == "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":
42
  return "⚠️ Please set your GROQ_API_KEY in the script.", ""
43
 
44
  # Auto-detect source language
 
156
  return "", "", ""
157
 
158
  def copy_output(text):
159
+ if text.strip():
160
+ return gr.update(value="✅ Copied! (select text manually on web)", interactive=False)
161
+ return gr.update(value="📋 Copy to Clipboard")
 
 
 
 
162
 
163
  translate_btn.click(
164
  fn=do_translate,