This commit is contained in:
Cyber MacGeddon 2024-11-09 11:17:37 +00:00
parent 82235a0758
commit 01d5387be8

View file

@ -8,8 +8,11 @@ import ibis
import textwrap
import time
import dataclasses
import sys
import base64
import logging
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def wrap(text, width=75):
@ -219,7 +222,7 @@ Input:
],
})
# print(prompt)
logger.info(f"prompt: {prompt}")
resp = prompt_client.request(
"question",
@ -231,11 +234,7 @@ Input:
resp = resp.replace("```json", "")
resp = resp.replace("```", "")
# print("---")
# print(resp)
# print("---")
# print(base64.b64encode(resp.encode("utf-8")).decode("utf-8"))
logger.info(f"response: {resp}")
obj = json.loads(resp)
@ -261,7 +260,7 @@ Input:
def think(self, thought):
# print(thought)
logger.info(f"thought: {thought}")
output(wrap(thought), "? ")
print()
@ -270,11 +269,8 @@ Input:
for i in range(0, 10):
# print("-----------------------")
# print("Iter", i)
act = self.iterate()
# print(act)
logger.info(f"act: {act}")
if isinstance(act, Final):
@ -285,8 +281,6 @@ Input:
self.think(act.thought)
# print(act.name)
action = None
for tool in self.tools:
@ -300,16 +294,14 @@ Input:
resp = resp.strip()
# print(resp)
logger.info(f"resp: {resp}")
act.observation = resp
# print("act>", act)
logger.info(f"iter: {act}")
self.history.append(act)
# print(self.history)
raise RuntimeError("Too many iterations")