| 1 | # Construct a knowledge graph from a GitHub repository |
| 2 | |
| 3 | The main entities and relations extracted: |
| 4 | |
| 5 | ## Entities |
| 6 | |
| 7 | - File |
| 8 | - Directory |
| 9 | - Commit |
| 10 | - Branch |
| 11 | - Repository |
| 12 | - Organization |
| 13 | - User |
| 14 | |
| 15 | ## Relations |
| 16 | |
| 17 | - (Repository)-[CONTAINS]->(File) |
| 18 | - (Repository)-[CONTAINS]->(Directory) |
| 19 | - (Repository)-[CONTAINS]->(Commit) |
| 20 | - (Repository)-[CONTAINS]->(branch) |
| 21 | - (Organization)-[OWNS]->(Repository) |
| 22 | - (User)-[STAR]->(Repository) |
| 23 | - (User)-[PART_OF]->(Organization) |
| 24 | |
| 25 | ## Run |
| 26 | |
| 27 | Run FalkorDB: |
| 28 | ```sh |
| 29 | docker run -p 6379:6379 -p 3000:3000 -it --rm -v ./data:/data falkordb/falkordb:edge |
| 30 | ``` |
| 31 | |
| 32 | Construct knowledge graph from github URL |
| 33 | ```sh |
| 34 | python examples/github/github.py -r https://github.com/falkorDB/falkordb |
| 35 | ``` |
| 36 | |
| 37 | ## Output |
| 38 | |
| 39 | ```sh |
| 40 | python examples/github/github.py |
| 41 | 2024-06-10 10:05:36,912 - graphrag_sdk.kg - DEBUG - Run in progress |
| 42 | ... |
| 43 | Question: List a few stargazers |
| 44 | |
| 45 | 2024-06-10 10:07:55,729 - graphrag_sdk.query_graph - DEBUG - Model suggested query: MATCH (u:User)-[:STAR]->(r:Repository) RETURN u.Name, r.Name LIMIT 5 |
| 46 | |
| 47 | Answer: Here are a few stargazers: |
| 48 | 1. User: dekelev - Repository: FalkorDB |
| 49 | 2. User: qdrddr - Repository: FalkorDB |
| 50 | 3. User: MikeLP - Repository: FalkorDB |
| 51 | 4. User: johnpccd - Repository: FalkorDB |
| 52 | 5. User: ohdearquant - Repository: FalkorDB |
| 53 | |
| 54 | Question: Does the FalkorDB repository has a 'main' branch? |
| 55 | |
| 56 | 2024-06-10 10:08:08,774 - graphrag_sdk.query_graph - DEBUG - Model suggested query: MATCH (:Repository {Name: 'FalkorDB'})-[:CONTAINS]->(b:Branch {Name: 'main'}) RETURN b |
| 57 | |
| 58 | Answer: No, the FalkorDB repository does not have a 'main' branch in the knowledge graph. |
| 59 | |
| 60 | How can I help you with? |
| 61 | Summerise stargazers locations |
| 62 | |
| 63 | 2024-06-10 10:27:51,036 - graphrag_sdk.query_graph - DEBUG - Model suggested query: MATCH (u:User)-[:STAR]->(r:Repository) RETURN u.Location, COUNT(u) as StargazersCount |
| 64 | |
| 65 | Answer: Here is a summary of stargazers locations along with the count of stargazers from each location: |
| 66 | - San Francisco, CA USA: 1 stargazer |
| 67 | - Sydney, Australia: 1 stargazer |
| 68 | - Houston, TX: 1 stargazer |
| 69 | - Mountain: 1 stargazer |
| 70 | - Bengaluru, India: 1 stargazer |
| 71 | - New York: 1 stargazer |
| 72 | - Bangkok, Thailand: 1 stargazer |
| 73 | - Russia: 1 stargazer |
| 74 | - Israel: 1 stargazer |
| 75 | - Unknown Location: 37 stargazers |
| 76 | - Mempool: 1 stargazer |
| 77 | ``` |