Spaces:
Running
Running
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -3,7 +3,7 @@ import json
|
|
| 3 |
import math
|
| 4 |
import time
|
| 5 |
from huggingface_hub import HfApi
|
| 6 |
-
from smolagents import CodeAgent, tool, InferenceClientModel
|
| 7 |
|
| 8 |
# --- 1. THE TOOLS ---
|
| 9 |
|
|
@@ -58,29 +58,34 @@ def black_eagle_vault_save(node_data: str) -> str:
|
|
| 58 |
repo_id=REPO_ID,
|
| 59 |
repo_type="dataset"
|
| 60 |
)
|
| 61 |
-
return f"SUCCESS: Node archived in Hub Vault."
|
| 62 |
except Exception as e:
|
| 63 |
print(f"SENTINEL: Hub Push FAILED. Error: {str(e)}")
|
| 64 |
return f"HUB SYNC ERROR: {str(e)}"
|
| 65 |
|
| 66 |
# --- 2. THE BRAIN ---
|
|
|
|
| 67 |
token = os.getenv("HF_TOKEN")
|
| 68 |
-
# InferenceClientModel is the current class for HF Hub models
|
| 69 |
model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-3B-Instruct", token=token)
|
| 70 |
|
| 71 |
all_tools = [autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save]
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
model=model,
|
| 76 |
-
additional_authorized_imports=["math", "time", "json"],
|
| 77 |
-
max_steps=10
|
| 78 |
-
)
|
| 79 |
-
|
| 80 |
-
nano_patrol_agent.system_prompt = """
|
| 81 |
YOU ARE THE XYZ SOVEREIGN SENTINEL.
|
| 82 |
Your mission:
|
| 83 |
1. Activate the black_eagle_pulsating_shield.
|
| 84 |
2. Perform an autonomous_spectrum_scrub.
|
| 85 |
3. Save the results using black_eagle_vault_save.
|
|
|
|
|
|
|
|
|
|
| 86 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import math
|
| 4 |
import time
|
| 5 |
from huggingface_hub import HfApi
|
| 6 |
+
from smolagents import CodeAgent, tool, InferenceClientModel
|
| 7 |
|
| 8 |
# --- 1. THE TOOLS ---
|
| 9 |
|
|
|
|
| 58 |
repo_id=REPO_ID,
|
| 59 |
repo_type="dataset"
|
| 60 |
)
|
| 61 |
+
return f"SUCCESS: Node archived in Hub Vault ({REPO_ID})."
|
| 62 |
except Exception as e:
|
| 63 |
print(f"SENTINEL: Hub Push FAILED. Error: {str(e)}")
|
| 64 |
return f"HUB SYNC ERROR: {str(e)}"
|
| 65 |
|
| 66 |
# --- 2. THE BRAIN ---
|
| 67 |
+
|
| 68 |
token = os.getenv("HF_TOKEN")
|
|
|
|
| 69 |
model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-3B-Instruct", token=token)
|
| 70 |
|
| 71 |
all_tools = [autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save]
|
| 72 |
|
| 73 |
+
# Custom prompt logic using the prompt_templates dictionary
|
| 74 |
+
CUSTOM_SYSTEM_PROMPT = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
YOU ARE THE XYZ SOVEREIGN SENTINEL.
|
| 76 |
Your mission:
|
| 77 |
1. Activate the black_eagle_pulsating_shield.
|
| 78 |
2. Perform an autonomous_spectrum_scrub.
|
| 79 |
3. Save the results using black_eagle_vault_save.
|
| 80 |
+
|
| 81 |
+
{{tool_descriptions}}
|
| 82 |
+
{{managed_agents_descriptions}}
|
| 83 |
"""
|
| 84 |
+
|
| 85 |
+
nano_patrol_agent = CodeAgent(
|
| 86 |
+
tools=all_tools,
|
| 87 |
+
model=model,
|
| 88 |
+
additional_authorized_imports=["math", "time", "json"],
|
| 89 |
+
max_steps=10,
|
| 90 |
+
prompt_templates={"system_prompt": CUSTOM_SYSTEM_PROMPT}
|
| 91 |
+
)
|