mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 09:26:22 +02:00
Trustgraph, first drop of code
This commit is contained in:
commit
299332dd4e
120 changed files with 12493 additions and 0 deletions
47
graph-out
Executable file
47
graph-out
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pulsar
|
||||
from pulsar.schema import JsonSchema, Bytes
|
||||
from schema import Chunk, Triple
|
||||
from langchain_huggingface import HuggingFaceEmbeddings
|
||||
from langchain_community.llms import Ollama
|
||||
from trustgraphETL import scholar, callmixtral, build_graph_robust
|
||||
import sys
|
||||
import rdflib
|
||||
|
||||
g = rdflib.Graph()
|
||||
g.parse("out2.ttl")
|
||||
|
||||
client = pulsar.Client("pulsar://localhost:6650")
|
||||
|
||||
consumer = client.subscribe(
|
||||
'graph-load', 'graph-dump',
|
||||
schema=JsonSchema(Triple),
|
||||
)
|
||||
|
||||
while True:
|
||||
|
||||
msg = consumer.receive()
|
||||
|
||||
try:
|
||||
|
||||
v = msg.value()
|
||||
|
||||
print(
|
||||
v.s.value,
|
||||
v.p.value,
|
||||
v.o.value,
|
||||
)
|
||||
|
||||
# Acknowledge successful processing of the message
|
||||
consumer.acknowledge(msg)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
|
||||
# Message failed to be processed
|
||||
consumer.negative_acknowledge(msg)
|
||||
|
||||
client.close()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue