Elffuss BraidHub

kikocis/GraphRAG-SDK public

423ab603a5a9 · 783 BRawPermalink
1import unittest
2from rag_sdk import KnowledgeGraph, Source
3from rag_sdk.Schema import Schema
4
5class TestKG(unittest.TestCase):
6 def test_kg_creation(self):
7 # Create schema
8 s = Schema()
9 actor = s.add_entity('Actor')
10 actor.add_attribute('name', str, unique=True)
11
12 movie = s.add_entity('Movie')
13 movie.add_attribute('title', str, unique=True)
14
15 s.add_relation("ACTED", actor, movie)
16
17 g = KnowledgeGraph("IMDB", schema=s)
18 g.process_sources([Source("./data/madoff.txt")])
19
20 answer, messages = g.ask("List a few actors")
21 print(f"answer: {answer}")
22
23 answer, messages = g.ask("list additional actors", messages)
24 print(f"answer: {answer}")
25
26if __name__ == '__main__':
27 unittest.main()