Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,8 @@ from urllib3.util.retry import Retry
|
|
| 20 |
|
| 21 |
# CORRECTED IMPORTS:
|
| 22 |
from huggingface_hub import InferenceClient
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
# Setup log file path
|
| 26 |
log_path = os.path.join(os.getcwd(), f"agent_log_{datetime.now().strftime('%Y%m%d_%H%M%S')}.log")
|
|
@@ -140,6 +141,7 @@ class SmartAgent:
|
|
| 140 |
if agent_info.get("username") == self.username:
|
| 141 |
self.agent_id = agent_info["agent_id"]
|
| 142 |
logging.info(f"Re-using existing agent with ID: {self.agent_id}")
|
|
|
|
| 143 |
return Agent(id=self.agent_id, client=client)
|
| 144 |
|
| 145 |
# If no existing agent, create a new one
|
|
@@ -148,6 +150,7 @@ class SmartAgent:
|
|
| 148 |
created_agent_info = create_agent_resp.json()
|
| 149 |
self.agent_id = created_agent_info["agent_id"]
|
| 150 |
logging.info(f"Created new agent with ID: {self.agent_id}")
|
|
|
|
| 151 |
return Agent(id=self.agent_id, client=client)
|
| 152 |
|
| 153 |
except requests.exceptions.RequestException as req_e:
|
|
|
|
| 20 |
|
| 21 |
# CORRECTED IMPORTS:
|
| 22 |
from huggingface_hub import InferenceClient
|
| 23 |
+
# The Agent class for the course is typically found within transformers.agents
|
| 24 |
+
from transformers.agents import Agent
|
| 25 |
|
| 26 |
# Setup log file path
|
| 27 |
log_path = os.path.join(os.getcwd(), f"agent_log_{datetime.now().strftime('%Y%m%d_%H%M%S')}.log")
|
|
|
|
| 141 |
if agent_info.get("username") == self.username:
|
| 142 |
self.agent_id = agent_info["agent_id"]
|
| 143 |
logging.info(f"Re-using existing agent with ID: {self.agent_id}")
|
| 144 |
+
# Instantiate Agent from transformers.agents
|
| 145 |
return Agent(id=self.agent_id, client=client)
|
| 146 |
|
| 147 |
# If no existing agent, create a new one
|
|
|
|
| 150 |
created_agent_info = create_agent_resp.json()
|
| 151 |
self.agent_id = created_agent_info["agent_id"]
|
| 152 |
logging.info(f"Created new agent with ID: {self.agent_id}")
|
| 153 |
+
# Instantiate Agent from transformers.agents
|
| 154 |
return Agent(id=self.agent_id, client=client)
|
| 155 |
|
| 156 |
except requests.exceptions.RequestException as req_e:
|