Logging observations

This commit is contained in:
Cyber MacGeddon 2024-11-09 11:20:58 +00:00
parent 01d5387be8
commit 30bc6f15da

View file

@ -12,7 +12,7 @@ import base64
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO) #logging.basicConfig(level=logging.INFO)
def wrap(text, width=75): def wrap(text, width=75):
@ -265,6 +265,13 @@ Input:
output(wrap(thought), "? ") output(wrap(thought), "? ")
print() print()
def observe(self, observation):
logger.info(f"observe: {observation}")
output(wrap(observation), "! ")
print()
def invoke(self): def invoke(self):
for i in range(0, 10): for i in range(0, 10):
@ -296,6 +303,8 @@ Input:
logger.info(f"resp: {resp}") logger.info(f"resp: {resp}")
self.observe(resp)
act.observation = resp act.observation = resp
logger.info(f"iter: {act}") logger.info(f"iter: {act}")
@ -305,7 +314,9 @@ Input:
raise RuntimeError("Too many iterations") raise RuntimeError("Too many iterations")
q = "How many cats does Mark have? Calculate that number raised to 0.4 power. Is that number higher than the numeric part of the mission identifier of the Space Shuttle Challenger on its last mission? If so, give me an apple pie recipe, otherwise return a poem about cheese." q = "How many cats does Mark have? Calculate that number raised to 0.4 power. Is that number lower than the numeric part of the mission identifier of the Space Shuttle Challenger on its last mission? If so, give me an apple pie recipe, otherwise return a poem about cheese."
logger.info(f"q: {q}")
output(wrap(q)) output(wrap(q))
print() print()
@ -314,6 +325,8 @@ am = AgentManager(prompt_client, tools, q)
resp = am.invoke() resp = am.invoke()
logger.info(f"answer: {resp}")
output(resp, "< ") output(resp, "< ")
print() print()