Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md fixes #74

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ Optional:
> The simplest way to install Neo4j is via [Neo4j Desktop](https://neo4j.com/download/). It provides a user-friendly interface to manage Neo4j instances and databases.

```bash
pip install Graphiti-core
pip install graphiti-core
```

or

```bash
poetry add Graphiti-core
poetry add graphiti-core
```


Expand All @@ -89,15 +89,15 @@ poetry add Graphiti-core
> Graphiti uses OpenAI for LLM inference and embedding. Ensure that an `OPENAI_API_KEY` is set in your environment. Support for Anthropic and Groq LLM inferences is available, too.

```python
from Graphiti_core import Graphiti
from Graphiti_core.nodes import EpisodeType
from graphiti_core import Graphiti
from graphiti_core.nodes import EpisodeType
from datetime import datetime

# Initialize Graphiti
Graphiti = Graphiti("bolt://localhost:7687", "neo4j", "password")
graphiti = Graphiti("bolt://localhost:7687", "neo4j", "password")

# Initialize the graph database with Graphiti's indices. This only needs to be done once.
Graphiti.build_indices_and_constraints()
graphiti.build_indices_and_constraints()

# Add episodes
episodes = [
Expand All @@ -106,7 +106,7 @@ episodes = [
"As AG, Harris was in office from January 3, 2011 – January 3, 2017",
]
for i, episode in enumerate(episodes):
await Graphiti.add_episode(
await graphiti.add_episode(
name=f"Freakonomics Radio {i}",
episode_body=episode,
source=EpisodeType.text,
Expand All @@ -117,7 +117,7 @@ for i, episode in enumerate(episodes):
# Search the graph
# Execute a hybrid search combining semantic similarity and BM25 retrieval
# Results are combined and reranked using Reciprocal Rank Fusion
results = await Graphiti.search('Who was the California Attorney General?')
results = await graphiti.search('Who was the California Attorney General?')
[
EntityEdge(
│ uuid='3133258f738e487383f07b04e15d4ac0',
Expand All @@ -144,10 +144,10 @@ results = await Graphiti.search('Who was the California Attorney General?')
# Rerank search results based on graph distance
# Provide a node UUID to prioritize results closer to that node in the graph.
# Results are weighted by their proximity, with distant edges receiving lower scores.
await client.search('Who was the California Attorney General?', center_node_uuid)
await graphiti.search('Who was the California Attorney General?', center_node_uuid)

# Close the connection
Graphiti.close()
graphiti.close()
```


Expand Down