mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
52 lines
1.5 KiB
Text
52 lines
1.5 KiB
Text
|
|
#!/usr/bin/env python3
|
||
|
|
|
||
|
|
import pulsar
|
||
|
|
from trustgraph.clients.prompt_client import PromptClient
|
||
|
|
from trustgraph.objects.object import Schema
|
||
|
|
from trustgraph.objects.field import Field, FieldType
|
||
|
|
|
||
|
|
schema = Schema(
|
||
|
|
name="actors",
|
||
|
|
description="actors in this story",
|
||
|
|
fields=[
|
||
|
|
Field(
|
||
|
|
name="name", type=FieldType.STRING,
|
||
|
|
description="Name of the animal or person in the story"
|
||
|
|
),
|
||
|
|
Field(
|
||
|
|
name="legs", type=FieldType.INT,
|
||
|
|
description="Number of legs of the animal or person"
|
||
|
|
),
|
||
|
|
Field(
|
||
|
|
name="notes", type=FieldType.STRING,
|
||
|
|
description="Additional notes or observations about this animal or person"
|
||
|
|
),
|
||
|
|
]
|
||
|
|
)
|
||
|
|
|
||
|
|
chunk = """I noticed a cat in my garden. It is a four-legged animal
|
||
|
|
which is a mammal and can be tame or wild. I wonder if it will be friends
|
||
|
|
with me? I think the cat's name is Fred and it has 4 legs.
|
||
|
|
There is also a dog barking outside. The dog has 4 legs also.
|
||
|
|
The dog comes to my call when I shout "Come here, Bernard".
|
||
|
|
|
||
|
|
I am also standing in the garden, my name is Steve and I have 2 legs.
|
||
|
|
|
||
|
|
My friend Clifford is coming to visit shortly, he has 3 legs due to
|
||
|
|
a freak accident at birth.
|
||
|
|
"""
|
||
|
|
|
||
|
|
p = PromptClient(pulsar_host="pulsar://localhost:6650")
|
||
|
|
|
||
|
|
resp = p.request_rows(
|
||
|
|
schema=schema,
|
||
|
|
chunk=chunk,
|
||
|
|
)
|
||
|
|
|
||
|
|
for d in resp:
|
||
|
|
print(f"Name: {d['name']}")
|
||
|
|
print(f" No. of legs: {d['legs']}")
|
||
|
|
print(f" Notes: {d['notes']}")
|
||
|
|
print()
|
||
|
|
|