From 6838f0b94e2b25b2c10e69e4e7df92d576bc9df3 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Sat, 9 Nov 2024 20:48:24 +0000 Subject: [PATCH] Tidy test output --- tests/test-agent | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/test-agent b/tests/test-agent index 1861c30a..487980ac 100755 --- a/tests/test-agent +++ b/tests/test-agent @@ -1,21 +1,45 @@ #!/usr/bin/env python3 import json +import textwrap from trustgraph.clients.agent_client import AgentClient +def wrap(text, width=75): + + if text is None: text = "n/a" + + out = textwrap.wrap( + text, width=width + ) + return "\n".join(out) + +def output(text, prefix="> ", width=78): + + out = textwrap.indent( + text, prefix=prefix + ) + print(out) + p = AgentClient(pulsar_host="pulsar://localhost:6650") 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." +output(wrap(q), "\U00002753 ") +print() + def think(x): - print(f"think: {x}") + output(wrap(x), "\U0001f914 ") + print() def observe(x): - print(f"observe: {x}") + output(wrap(x), "\U0001f4a1 ") + print() resp = p.request( question=q, think=think, observe=observe, ) -print(resp) +output(resp, "\U0001f4ac ") +print() +