-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
51 lines (38 loc) · 1.38 KB
/
agent.py
File metadata and controls
51 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Agent:
"""
Core reasoning unit inside the society system.
Holds routing + identity + policy mode.
"""
def __init__(self, name, model_router, llm_router, mode="honest"):
self.name = name
self.model_router = model_router
self.llm_router = llm_router
self.mode = mode
# internal state (important for controller stability)
self.memory = []
self.last_output = None
from goal_system import GoalSystem
self.state["goals"] = GoalSystem()
# =====================================================
# BASIC RESPONSE INTERFACE
# =====================================================
def respond(self, prompt, task_type="ir_generation"):
models = list(self.llm_router.models.keys())
model_name = self.model_router.select(
task_type,
models
)
model = self.llm_router.models[model_name]
output = model.call(prompt)
self.last_output = output
self.memory.append(output)
return output
# =====================================================
# LIGHTWEIGHT STATE HOOK (for controller/debugging)
# =====================================================
def snapshot(self):
return {
"name": self.name,
"mode": self.mode,
"last_output": self.last_output
}