mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Extract rows and apply object embeddings (#42)
* - Restructured the extract directories - Added an extractor for 'rows' == a row of a table - Added a row extractor prompt to prompter. * Add row support to template prompter * Row extraction working * Bump version * Emit extracted info * Object embeddings store * Invocation script * Add script to package, remove cruft output * Write rows to Cassandra * Remove output cruft
This commit is contained in:
parent
b574ba26a8
commit
e4c4774b5d
70 changed files with 1624 additions and 520 deletions
51
tests/test-rows-prompt
Executable file
51
tests/test-rows-prompt
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue