Update app.py
Browse files
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 |
-
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 171 |
-
2.
|
| 172 |
-
3.
|
| 173 |
-
4.
|
| 174 |
-
|
|
|
|
| 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 |
)
|