Elffuss BraidHub

kikocis/GraphRAG-SDK public

Update README
Changesetffd3815000e169cc14bf15a847ac49d8732df58e20317f9bff85a00655c36dca
AuthorRoi Lipman <swilly22@users.noreply.github.com> · 2024-05-27 14:23 +03:00
CommitterGitHub <noreply@github.com> · 2024-05-27 14:23 +03:00
Parentsc4d9d856add1

Browse the files at this changeset

1 file changed

modified README.md +31 −0
@@ -0,0 +1,31 @@
1+## Usage
2+
3+### Manual schema creation
4+
5+```python
6+s = Schema()
7+s.add_entity('Actor').add_attribute('name', str, unique=True)
8+s.add_entity('Movie').add_attribute('title', str, unique=True)
9+s.add_relation("ACTED", 'Actor', 'Movie')
10+
11+g = KG("IMDB", schema=s)
12+g.add_source("./data/madoff.txt")
13+
14+g.create()
15+
16+answer, messages = g.ask("List a few actors")
17+```
18+
19+### Automatic schema creation
20+
21+```python
22+sources = [Source("./data/madoff.txt")]
23+s = Schema.auto_detect(sources)
24+
25+g = KG("IMDB", schema=s)
26+g.add_source("./data/madoff.txt")
27+
28+g.create()
29+
30+answer, messages = g.ask("List a few actors")
31+```