piyushdev commited on
Commit
549a812
·
verified ·
1 Parent(s): 7e0815e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -60,7 +60,6 @@ def process_csv_files(
60
  max_tokens,
61
  temperature,
62
  top_p,
63
- hf_token: gr.OAuthToken,
64
  progress=gr.Progress()
65
  ):
66
  """
@@ -69,10 +68,14 @@ def process_csv_files(
69
  if not files or len(files) == 0:
70
  return "Please upload at least one CSV file.", None
71
 
72
- if not hf_token or not hf_token.token:
73
- return "Please login with your Hugging Face account.", None
 
74
 
75
- client = InferenceClient(token=hf_token.token, model="meta-llama/Llama-3.3-70B-Instruct")
 
 
 
76
 
77
  output_files = []
78
  status_messages = []
@@ -167,11 +170,12 @@ with gr.Blocks(title="Business Category Description Generator") as demo:
167
  CLIP-ready visual descriptions for each category using AI.
168
 
169
  **Instructions:**
170
- 1. Login with your Hugging Face account (required)
171
- 2. Upload one or more CSV files
172
- 3. Specify the column name that contains the category keywords
173
- 4. Click "Process Files" to generate descriptions
174
- 5. Download the output CSV files
 
175
  """)
176
 
177
  with gr.Sidebar():
@@ -231,8 +235,7 @@ with gr.Blocks(title="Business Category Description Generator") as demo:
231
  category_column,
232
  max_tokens,
233
  temperature,
234
- top_p,
235
- gr.OAuthToken()
236
  ],
237
  outputs=[status_output, files_output]
238
  )
 
60
  max_tokens,
61
  temperature,
62
  top_p,
 
63
  progress=gr.Progress()
64
  ):
65
  """
 
68
  if not files or len(files) == 0:
69
  return "Please upload at least one CSV file.", None
70
 
71
+ # Get HF token from environment (automatically available in HF Spaces with OAuth enabled)
72
+ import os
73
+ hf_token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")
74
 
75
+ if not hf_token:
76
+ return "❌ Error: Hugging Face token not found. Please make sure OAuth is enabled for this Space.", None
77
+
78
+ client = InferenceClient(token=hf_token, model="meta-llama/Llama-3.3-70B-Instruct")
79
 
80
  output_files = []
81
  status_messages = []
 
170
  CLIP-ready visual descriptions for each category using AI.
171
 
172
  **Instructions:**
173
+ 1. Upload one or more CSV files
174
+ 2. Specify the column name that contains the category keywords
175
+ 3. Click "Process Files" to generate descriptions
176
+ 4. Download the output CSV files
177
+
178
+ *Note: This Space requires OAuth to be enabled. Make sure to configure it in Space settings.*
179
  """)
180
 
181
  with gr.Sidebar():
 
235
  category_column,
236
  max_tokens,
237
  temperature,
238
+ top_p
 
239
  ],
240
  outputs=[status_output, files_output]
241
  )