Spaces:
Sleeping
Sleeping
Made the agent conversational with memory
Browse files
agent.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
-
from smolagents import CodeAgent, Model, ChatMessage
|
| 5 |
import tools.tools as tls # Your tool definitions
|
| 6 |
|
| 7 |
load_dotenv()
|
|
@@ -61,10 +61,12 @@ class BasicAgent:
|
|
| 61 |
def __init__(self):
|
| 62 |
print("✅ BasicAgent initialized with Hugging Face chat model.")
|
| 63 |
self.model = HuggingFaceChatModel()
|
|
|
|
| 64 |
|
| 65 |
self.agent = CodeAgent(
|
| 66 |
tools=[tls.search_tool, tls.calculate_cargo_travel_time],
|
| 67 |
model=self.model,
|
|
|
|
| 68 |
additional_authorized_imports=["pandas"],
|
| 69 |
max_steps=20,
|
| 70 |
)
|
|
|
|
| 1 |
import os
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
+
from smolagents import CodeAgent, Model, ChatMessage, SimpleMemory
|
| 5 |
import tools.tools as tls # Your tool definitions
|
| 6 |
|
| 7 |
load_dotenv()
|
|
|
|
| 61 |
def __init__(self):
|
| 62 |
print("✅ BasicAgent initialized with Hugging Face chat model.")
|
| 63 |
self.model = HuggingFaceChatModel()
|
| 64 |
+
self.memory = SimpleMemory(k=5) # k = how many turns to remember
|
| 65 |
|
| 66 |
self.agent = CodeAgent(
|
| 67 |
tools=[tls.search_tool, tls.calculate_cargo_travel_time],
|
| 68 |
model=self.model,
|
| 69 |
+
memory=self.memory,
|
| 70 |
additional_authorized_imports=["pandas"],
|
| 71 |
max_steps=20,
|
| 72 |
)
|