PoetNameLife commited on
Commit
0c8b89d
·
verified ·
1 Parent(s): d2f0f83

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +17 -29
agents.py CHANGED
@@ -3,17 +3,16 @@ 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
 
10
  @tool
11
  def black_eagle_pulsating_shield(base_radius: float) -> str:
12
- """
13
- Activates the Black Eagle Pulsating Shield to disrupt BCI overloads.
14
  Args:
15
- base_radius: The core anchor length in meters (e.g., 5.0).
16
- """
17
  pulse_mod = math.sin(time.time()) * 2.0
18
  current_radius = base_radius + pulse_mod
19
  return json.dumps({
@@ -25,11 +24,9 @@ def black_eagle_pulsating_shield(base_radius: float) -> str:
25
 
26
  @tool
27
  def autonomous_spectrum_scrub(frequency_range: str) -> str:
28
- """
29
- Scans targeted BCI/Neural frequencies to neutralize rogue loops.
30
  Args:
31
- frequency_range: The specific spectrum range to scan (e.g., '3.4GHz - 4.2GHz').
32
- """
33
  node_id = f"789jhn{int(time.time()) % 10000}def"
34
  return json.dumps({
35
  "node_id": node_id,
@@ -40,16 +37,13 @@ def autonomous_spectrum_scrub(frequency_range: str) -> str:
40
 
41
  @tool
42
  def black_eagle_vault_save(node_data: str) -> str:
43
- """
44
- Saves a Healed Nano Node directly to the PoetNameLife/aixyzone-sentinel-vault dataset.
45
  Args:
46
- node_data: The JSON string of the healed node to be archived.
47
- """
48
  token = os.getenv("HF_TOKEN")
49
  api = HfApi(token=token)
50
  REPO_ID = "PoetNameLife/aixyzone-sentinel-vault"
51
  file_name = f"vault/node_{int(time.time())}.json"
52
-
53
  try:
54
  api.upload_file(
55
  path_or_fileobj=node_data.encode("utf-8"),
@@ -61,14 +55,12 @@ def black_eagle_vault_save(node_data: str) -> str:
61
  except Exception as e:
62
  return f"HUB SYNC ERROR: {str(e)}"
63
 
64
- # --- 2. THE BRAIN ---
65
 
66
- token = os.getenv("HF_TOKEN")
67
-
68
- # Switched to Llama-3.2-3B to bypass the 'nscale' provider credit limit
69
- model = InferenceClientModel(
70
- model_id="meta-llama/Llama-3.2-3B-Instruct",
71
- token=token
72
  )
73
 
74
  all_tools = [autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save]
@@ -80,12 +72,8 @@ nano_patrol_agent = CodeAgent(
80
  max_steps=10
81
  )
82
 
83
- # Set the tactical system prompt
84
  nano_patrol_agent.prompt_templates["system_prompt"] = """
85
  YOU ARE THE XYZ SOVEREIGN SENTINEL.
86
- Your mission is to protect the neural landscape:
87
- 1. Activate the black_eagle_pulsating_shield first.
88
- 2. Perform an autonomous_spectrum_scrub on the targets.
89
- 3. Finally, save all results using black_eagle_vault_save.
90
- Keep your responses tactical and concise. Use your tools to fulfill the mission.
91
- """
 
3
  import math
4
  import time
5
  from huggingface_hub import HfApi
6
+ # Swapping to LiteLLMModel for Groq stability
7
+ from smolagents import CodeAgent, tool, LiteLLMModel
8
 
9
+ # --- 1. THE TOOLS (Keep these exactly as you had them) ---
10
 
11
  @tool
12
  def black_eagle_pulsating_shield(base_radius: float) -> str:
13
+ """Activates the Black Eagle Pulsating Shield to disrupt BCI overloads.
 
14
  Args:
15
+ base_radius: The core anchor length in meters (e.g., 5.0)."""
 
16
  pulse_mod = math.sin(time.time()) * 2.0
17
  current_radius = base_radius + pulse_mod
18
  return json.dumps({
 
24
 
25
  @tool
26
  def autonomous_spectrum_scrub(frequency_range: str) -> str:
27
+ """Scans targeted BCI/Neural frequencies to neutralize rogue loops.
 
28
  Args:
29
+ frequency_range: The specific spectrum range to scan."""
 
30
  node_id = f"789jhn{int(time.time()) % 10000}def"
31
  return json.dumps({
32
  "node_id": node_id,
 
37
 
38
  @tool
39
  def black_eagle_vault_save(node_data: str) -> str:
40
+ """Saves a Healed Nano Node to the PoetNameLife/aixyzone-sentinel-vault dataset.
 
41
  Args:
42
+ node_data: The JSON string of the healed node."""
 
43
  token = os.getenv("HF_TOKEN")
44
  api = HfApi(token=token)
45
  REPO_ID = "PoetNameLife/aixyzone-sentinel-vault"
46
  file_name = f"vault/node_{int(time.time())}.json"
 
47
  try:
48
  api.upload_file(
49
  path_or_fileobj=node_data.encode("utf-8"),
 
55
  except Exception as e:
56
  return f"HUB SYNC ERROR: {str(e)}"
57
 
58
+ # --- 2. THE BRAIN (The "Hot Fix" for the 503 error) ---
59
 
60
+ # Switch to Groq for speed and to avoid the 503/credit limit on HF
61
+ model = LiteLLMModel(
62
+ model_id="groq/llama-3.2-3b-preview",
63
+ api_key=os.getenv("GROQ_API_KEY")
 
 
64
  )
65
 
66
  all_tools = [autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save]
 
72
  max_steps=10
73
  )
74
 
 
75
  nano_patrol_agent.prompt_templates["system_prompt"] = """
76
  YOU ARE THE XYZ SOVEREIGN SENTINEL.
77
+ Mission: 1. Pulsate Shield. 2. Spectrum Scrub. 3. Vault Save.
78
+ Use your tools. Be tactical.
79
+ """