mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-05 13:22:37 +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()
|
||||
|
||||
13
tests/test-run-extract-row
Normal file
13
tests/test-run-extract-row
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
scripts/object-extract-row \
|
||||
-p pulsar://localhost:6650 \
|
||||
--field 'name:string:100:pri:Name of the person in the story' \
|
||||
--field 'job:string:100::Job title or role' \
|
||||
--field 'date:string:20::Date entered into role if known' \
|
||||
--field 'supervisor:string:100::Supervisor or manager of this person, if known' \
|
||||
--field 'location:string:100::Main base or location of work, if known' \
|
||||
--field 'notes:string:1000::Additional notes or observations about this animal or person' \
|
||||
--no-metrics \
|
||||
--name actors \
|
||||
--description 'Relevant people'
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue