Hmd6919 commited on
Commit
9fd9ed7
·
verified ·
1 Parent(s): 4717d11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,16 +1,21 @@
1
 
 
2
  import subprocess
3
  import sys
 
4
 
5
- # 1. Force-install the latest library if the import fails
6
  try:
7
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
8
  except ImportError:
9
  print("⚠️ Installing smolagents from source...")
10
  subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/huggingface/smolagents.git"])
 
 
 
 
 
11
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
12
- import os
13
-
14
  import gradio as gr
15
  import requests
16
  import pandas as pd
 
1
 
2
+ import os
3
  import subprocess
4
  import sys
5
+ import importlib
6
 
7
+ # 1. Force-install and RELOAD the library if the import fails
8
  try:
9
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
10
  except ImportError:
11
  print("⚠️ Installing smolagents from source...")
12
  subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/huggingface/smolagents.git"])
13
+
14
+ # 💡 CRITICAL STEP: Force Python to reload the module we just installed
15
+ import smolagents
16
+ importlib.reload(smolagents)
17
+
18
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
 
 
19
  import gradio as gr
20
  import requests
21
  import pandas as pd