Spaces:
Running
Running
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -1,20 +1,41 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
from smolagents import CodeAgent, tool, HfApiModel
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
|
|
|
| 6 |
token = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
model = HfApiModel(
|
| 10 |
-
model_id="
|
| 11 |
-
token=token
|
| 12 |
-
# This specifically forces it away from paid providers like Novita
|
| 13 |
-
provider="hf-inference"
|
| 14 |
)
|
| 15 |
|
| 16 |
nano_patrol_agent = CodeAgent(
|
| 17 |
tools=[autonomous_spectrum_scrub],
|
| 18 |
model=model,
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
)
|
|
|
|
| 1 |
import os
|
| 2 |
+
import json
|
| 3 |
from smolagents import CodeAgent, tool, HfApiModel
|
| 4 |
|
| 5 |
+
@tool
|
| 6 |
+
def autonomous_spectrum_scrub(frequency_range: str) -> str:
|
| 7 |
+
"""
|
| 8 |
+
Scans targeted BCI/Neural frequencies to neutralize rogue loops.
|
| 9 |
+
Args:
|
| 10 |
+
frequency_range: The spectrum range to scan (e.g., '3.4GHz - 4.2GHz').
|
| 11 |
+
"""
|
| 12 |
+
node_id = f"SENTINEL-FIX-{hash(frequency_range) % 1000}"
|
| 13 |
+
return json.dumps({
|
| 14 |
+
"node_id": node_id,
|
| 15 |
+
"action": "AUTO-CLEANSE",
|
| 16 |
+
"result": "Neutralized looping BCI feedback.",
|
| 17 |
+
"status": "HEALED"
|
| 18 |
+
})
|
| 19 |
|
| 20 |
+
# Securely grab the token
|
| 21 |
token = os.getenv("HF_TOKEN")
|
| 22 |
|
| 23 |
+
# SWITCH TO SMOL-LM: This bypasses the Novita payment wall entirely
|
| 24 |
model = HfApiModel(
|
| 25 |
+
model_id="HuggingFaceTB/SmolLM2-135M-Instruct",
|
| 26 |
+
token=token
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
nano_patrol_agent = CodeAgent(
|
| 30 |
tools=[autonomous_spectrum_scrub],
|
| 31 |
model=model,
|
| 32 |
+
max_steps=2,
|
| 33 |
+
system_prompt="""
|
| 34 |
+
You are the XYZ Nano Sentinel.
|
| 35 |
+
1. Call autonomous_spectrum_scrub.
|
| 36 |
+
2. Provide the final_answer as JSON.
|
| 37 |
+
|
| 38 |
+
{{managed_agents_descriptions}}
|
| 39 |
+
{{authorized_imports}}
|
| 40 |
+
"""
|
| 41 |
)
|