mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-28 09:56:22 +02:00
Trustgraph, first drop of code
This commit is contained in:
commit
299332dd4e
120 changed files with 12493 additions and 0 deletions
15
tests/test-embeddings
Executable file
15
tests/test-embeddings
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pulsar
|
||||
from trustgraph.embeddings_client import EmbeddingsClient
|
||||
|
||||
embed = EmbeddingsClient(pulsar_host="pulsar://localhost:6650")
|
||||
|
||||
prompt="Write a funny limerick about a llama"
|
||||
|
||||
resp = embed.request(prompt)
|
||||
|
||||
print(resp)
|
||||
|
||||
|
||||
|
||||
14
tests/test-graph-rag
Executable file
14
tests/test-graph-rag
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pulsar
|
||||
from trustgraph.graph_rag_client import GraphRagClient
|
||||
|
||||
rag = GraphRagClient(pulsar_host="pulsar://localhost:6650")
|
||||
|
||||
query="""This knowledge graph describes the Space Shuttle disaster.
|
||||
Present 20 facts which are present in the knowledge graph."""
|
||||
|
||||
resp = rag.request(query)
|
||||
|
||||
print(resp)
|
||||
|
||||
15
tests/test-llm
Executable file
15
tests/test-llm
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pulsar
|
||||
from trustgraph.llm_client import LlmClient
|
||||
|
||||
llm = LlmClient(pulsar_host="pulsar://localhost:6650")
|
||||
|
||||
prompt="Write a funny limerick about a llama"
|
||||
|
||||
resp = llm.request(prompt)
|
||||
|
||||
print(resp)
|
||||
|
||||
llm.close()
|
||||
|
||||
35
tests/test-milvus
Executable file
35
tests/test-milvus
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from langchain_huggingface import HuggingFaceEmbeddings
|
||||
|
||||
from edge_map import VectorStore
|
||||
|
||||
client = VectorStore()
|
||||
|
||||
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
|
||||
|
||||
text="""A cat is a small animal. A dog is a large animal.
|
||||
Cats say miaow. Dogs go woof.
|
||||
"""
|
||||
|
||||
embeds = embeddings.embed_documents([text])[0]
|
||||
|
||||
text2="""If you couldn't download the model due to network issues, as a walkaround, you can use random vectors to represent the text and still finish the example. Just note that the search result won't reflect semantic similarity as the vectors are fake ones.
|
||||
"""
|
||||
|
||||
embeds2 = embeddings.embed_documents([text2])[0]
|
||||
|
||||
client.insert(embeds, "animals")
|
||||
client.insert(embeds, "vectors")
|
||||
|
||||
query="""What noise does a cat make?"""
|
||||
|
||||
qembeds = embeddings.embed_documents([query])[0]
|
||||
|
||||
res = client.search(
|
||||
qembeds,
|
||||
limit=2
|
||||
)
|
||||
|
||||
print(res)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue