Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,9 +15,7 @@ import os
|
|
| 15 |
|
| 16 |
|
| 17 |
# π Set your HF API key
|
| 18 |
-
|
| 19 |
-
os.environ["HF_TOKEN"] = token.strip()
|
| 20 |
-
return "β
Token saved successfully! You can now upload your CSV file."
|
| 21 |
|
| 22 |
|
| 23 |
# ββββββββββββββββββββββββββββββββ
|
|
@@ -383,19 +381,40 @@ def AutoML(data: dict, task_hint: str = None) -> dict:
|
|
| 383 |
# π§ Initialize the AI Agent
|
| 384 |
# ββββββββββββββββββββββββββββββββ
|
| 385 |
|
| 386 |
-
agent = CodeAgent(
|
| 387 |
-
tools=[LoadData, CleanData, EDA, AutoML],
|
| 388 |
-
model=InferenceClientModel(
|
| 389 |
-
model_id="Qwen/Qwen2.5-Coder-1.5B-Instruct",
|
| 390 |
-
token=os.environ["HF_TOKEN"],
|
| 391 |
-
provider="Featherless AI",
|
| 392 |
-
max_tokens=4048
|
| 393 |
-
),
|
| 394 |
-
additional_authorized_imports=[
|
| 395 |
-
"pandas", "matplotlib.pyplot", "seaborn", "PIL", "sklearn", "io", "os","joblib","tempfile"
|
| 396 |
-
],
|
| 397 |
-
max_steps=10,
|
| 398 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
|
| 400 |
|
| 401 |
# ββββββββββββββββββββββββββββββββ
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
# π Set your HF API key
|
| 18 |
+
agent = None
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
# ββββββββββββββββββββββββββββββββ
|
|
|
|
| 381 |
# π§ Initialize the AI Agent
|
| 382 |
# ββββββββββββββββββββββββββββββββ
|
| 383 |
|
| 384 |
+
#agent = CodeAgent(
|
| 385 |
+
#tools=[LoadData, CleanData, EDA, AutoML],
|
| 386 |
+
#model=InferenceClientModel(
|
| 387 |
+
#model_id="Qwen/Qwen2.5-Coder-1.5B-Instruct",
|
| 388 |
+
#token=os.environ["HF_TOKEN"],
|
| 389 |
+
#provider="Featherless AI",
|
| 390 |
+
#max_tokens=4048
|
| 391 |
+
#),
|
| 392 |
+
#additional_authorized_imports=[
|
| 393 |
+
#"pandas", "matplotlib.pyplot", "seaborn", "PIL", "sklearn", "io", "os","joblib","tempfile"
|
| 394 |
+
#],
|
| 395 |
+
#max_steps=10,
|
| 396 |
+
#)
|
| 397 |
+
|
| 398 |
+
def set_hf_token(token):
|
| 399 |
+
global agent
|
| 400 |
+
os.environ["HF_TOKEN"] = token.strip()
|
| 401 |
+
|
| 402 |
+
# β
Initialize the agent *only now* when token is available
|
| 403 |
+
agent = CodeAgent(
|
| 404 |
+
tools=[LoadData, CleanData, EDA, AutoML],
|
| 405 |
+
model=InferenceClientModel(
|
| 406 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 407 |
+
token=os.environ["HF_TOKEN"],
|
| 408 |
+
provider="together",
|
| 409 |
+
max_tokens=4048
|
| 410 |
+
),
|
| 411 |
+
additional_authorized_imports=[
|
| 412 |
+
"pandas", "matplotlib.pyplot", "seaborn", "PIL", "sklearn", "io", "os", "joblib", "tempfile"
|
| 413 |
+
],
|
| 414 |
+
max_steps=10,
|
| 415 |
+
)
|
| 416 |
+
|
| 417 |
+
return "β
Token saved and agent initialized successfully! You can now upload your CSV file."
|
| 418 |
|
| 419 |
|
| 420 |
# ββββββββββββββββββββββββββββββββ
|