Spaces:
Runtime error
Runtime error
| from fast_graphrag import GraphRAG | |
| import os | |
| DOMAIN = "Analyze this story and identify the characters. Focus on how they interact with each other, the locations they explore, and their relationships." | |
| EXAMPLE_QUERIES = [ | |
| "What is the significance of Christmas Eve in A Christmas Carol?", | |
| "How does the setting of Victorian London contribute to the story's themes?", | |
| "Describe the chain of events that leads to Scrooge's transformation.", | |
| "How does Dickens use the different spirits (Past, Present, and Future) to guide Scrooge?", | |
| "Why does Dickens choose to divide the story into \"staves\" rather than chapters?" | |
| ] | |
| ENTITY_TYPES = ["Character", "Animal", "Place", "Object", "Activity", "Event"] | |
| print(os.environ) | |
| grag = GraphRAG( | |
| working_dir="./book_example", | |
| domain=DOMAIN, | |
| example_queries="\n".join(EXAMPLE_QUERIES), | |
| entity_types=ENTITY_TYPES | |
| ) | |
| with open("./book.txt") as f: | |
| grag.insert(f.read()) | |
| print(grag.query("Who is Scrooge?").response) |