mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 16:36:21 +02:00
- Keeps processing in different flows separate so that data can go to different stores / collections etc. - Potentially supports different processing flows - Tidies the processing API with common base-classes for e.g. LLMs, and automatic configuration of 'clients' to use the right queue names in a flow
48 lines
1.1 KiB
Python
Executable file
48 lines
1.1 KiB
Python
Executable file
#!/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://pulsar:6650",
|
|
input_queue = "non-persistent://tg/request/agent:0000",
|
|
output_queue = "non-persistent://tg/response/agent:0000",
|
|
)
|
|
|
|
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):
|
|
output(wrap(x), "\U0001f914 ")
|
|
print()
|
|
|
|
def observe(x):
|
|
output(wrap(x), "\U0001f4a1 ")
|
|
print()
|
|
|
|
resp = p.request(
|
|
question=q, think=think, observe=observe,
|
|
)
|
|
|
|
output(resp, "\U0001f4ac ")
|
|
print()
|
|
|