Rustamshry commited on
Commit
6268ee9
Β·
verified Β·
1 Parent(s): 51fd562

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -16
app.py CHANGED
@@ -15,9 +15,7 @@ import os
15
 
16
 
17
  # πŸ”‘ Set your HF API key
18
- def set_hf_token(token):
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
  # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”