mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 20:21:03 +02:00
Logging
This commit is contained in:
parent
82235a0758
commit
01d5387be8
1 changed files with 10 additions and 18 deletions
|
|
@ -8,8 +8,11 @@ import ibis
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import sys
|
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
def wrap(text, width=75):
|
def wrap(text, width=75):
|
||||||
|
|
||||||
|
|
@ -219,7 +222,7 @@ Input:
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
# print(prompt)
|
logger.info(f"prompt: {prompt}")
|
||||||
|
|
||||||
resp = prompt_client.request(
|
resp = prompt_client.request(
|
||||||
"question",
|
"question",
|
||||||
|
|
@ -231,11 +234,7 @@ Input:
|
||||||
resp = resp.replace("```json", "")
|
resp = resp.replace("```json", "")
|
||||||
resp = resp.replace("```", "")
|
resp = resp.replace("```", "")
|
||||||
|
|
||||||
# print("---")
|
logger.info(f"response: {resp}")
|
||||||
# print(resp)
|
|
||||||
# print("---")
|
|
||||||
|
|
||||||
# print(base64.b64encode(resp.encode("utf-8")).decode("utf-8"))
|
|
||||||
|
|
||||||
obj = json.loads(resp)
|
obj = json.loads(resp)
|
||||||
|
|
||||||
|
|
@ -261,7 +260,7 @@ Input:
|
||||||
|
|
||||||
def think(self, thought):
|
def think(self, thought):
|
||||||
|
|
||||||
# print(thought)
|
logger.info(f"thought: {thought}")
|
||||||
|
|
||||||
output(wrap(thought), "? ")
|
output(wrap(thought), "? ")
|
||||||
print()
|
print()
|
||||||
|
|
@ -270,11 +269,8 @@ Input:
|
||||||
|
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
|
|
||||||
# print("-----------------------")
|
|
||||||
# print("Iter", i)
|
|
||||||
|
|
||||||
act = self.iterate()
|
act = self.iterate()
|
||||||
# print(act)
|
logger.info(f"act: {act}")
|
||||||
|
|
||||||
if isinstance(act, Final):
|
if isinstance(act, Final):
|
||||||
|
|
||||||
|
|
@ -285,8 +281,6 @@ Input:
|
||||||
|
|
||||||
self.think(act.thought)
|
self.think(act.thought)
|
||||||
|
|
||||||
# print(act.name)
|
|
||||||
|
|
||||||
action = None
|
action = None
|
||||||
|
|
||||||
for tool in self.tools:
|
for tool in self.tools:
|
||||||
|
|
@ -300,16 +294,14 @@ Input:
|
||||||
|
|
||||||
resp = resp.strip()
|
resp = resp.strip()
|
||||||
|
|
||||||
# print(resp)
|
logger.info(f"resp: {resp}")
|
||||||
|
|
||||||
act.observation = resp
|
act.observation = resp
|
||||||
|
|
||||||
# print("act>", act)
|
logger.info(f"iter: {act}")
|
||||||
|
|
||||||
self.history.append(act)
|
self.history.append(act)
|
||||||
|
|
||||||
# print(self.history)
|
|
||||||
|
|
||||||
raise RuntimeError("Too many iterations")
|
raise RuntimeError("Too many iterations")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue