Tpayne101 commited on
Commit
30c0316
·
verified ·
1 Parent(s): 1277551

Update agentos_core.py

Browse files
Files changed (1) hide show
  1. agentos_core.py +47 -1
agentos_core.py CHANGED
@@ -19,8 +19,54 @@ class AgentCore:
19
  print(f"[INIT] Agent {self.agent_id} initialized with model {self.model}")
20
 
21
  def run(self, prompt):
22
- ==== Application Startup at 2025-10-20 07:10:44 =====
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
 
 
 
 
24
  [Identity] Created digital DNA for agent 4a65fb77-5b14-4caa-9883-806a67eff093
25
  [Telemetry] init - success | {'agent_id': '4a65fb77-5b14-4caa-9883-806a67eff093'}
26
  [INIT] Agent 4a65fb77-5b14-4caa-9883-806a67eff093 initialized with model gpt-4o-mini
 
19
  print(f"[INIT] Agent {self.agent_id} initialized with model {self.model}")
20
 
21
  def run(self, prompt):
22
+ import os
23
+ from telemetry import Telemetry
24
+ from memory_core import MemoryManager
25
+ from context_graph import ContextGraph
26
+ from identity_core import create_agent_identity
27
+
28
+
29
+ class AgentCore:
30
+ def __init__(self, model="gpt-4o-mini"):
31
+ self.agent_id = create_agent_identity()
32
+ self.telemetry = Telemetry(agent_id=self.agent_id)
33
+ self.model = model
34
+ self.memory = MemoryManager(self.agent_id)
35
+ self.context = ContextGraph()
36
+
37
+ self.telemetry.log("init", "success", {"agent_id": self.agent_id})
38
+ print(f"[INIT] Agent {self.agent_id} initialized with model {self.model}")
39
+
40
+ def run(self, prompt):
41
+ self.telemetry.log("run_start", "in_progress", {"prompt": prompt})
42
+ try:
43
+ recall_hits = self.context.query_context(self.agent_id, prompt)
44
+ response = None
45
+
46
+ if recall_hits and recall_hits != ["No matching context found."]:
47
+ for hit in recall_hits:
48
+ if " is " in hit:
49
+ parts = hit.split(" is ", 1)
50
+ subject = parts[0].replace("My ", "Your ").strip()
51
+ fact = parts[1].strip().rstrip(".")
52
+ if subject.lower() in prompt.lower():
53
+ response = f"{subject} is {fact}."
54
+ break
55
+
56
+ if not response:
57
+ response = f"Agent {self.agent_id} processed: {prompt}"
58
+
59
+ self.memory.save({"prompt": prompt, "response": response})
60
+ self.context.link_context(self.agent_id, prompt, response)
61
+
62
+ self.telemetry.log("run_complete", "success", {"response": response})
63
+ print(f"[RUN] {response}")
64
+ return response
65
 
66
+ except Exception as e:
67
+ self.telemetry.log("run_failed", "error", {"error": str(e)})
68
+ print(f"[ERROR] {e}")
69
+ return f"Error: {e}"
70
  [Identity] Created digital DNA for agent 4a65fb77-5b14-4caa-9883-806a67eff093
71
  [Telemetry] init - success | {'agent_id': '4a65fb77-5b14-4caa-9883-806a67eff093'}
72
  [INIT] Agent 4a65fb77-5b14-4caa-9883-806a67eff093 initialized with model gpt-4o-mini