Skip to content

Commit 587f0d6

Browse files
update documentation
1 parent aab1603 commit 587f0d6

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ Here's a simple example of how to get up and running with `langchain-graphiti`.
4848

4949
```python
5050
import asyncio
51+
import os
52+
# Note: This must be set due to Graphiti's limitations. Will be fixed when Graphiti fixes it.
53+
# Of course, you can set it in ".env" as well, but you must load it before importing langchain_graphiti.
54+
os.environ["DEFAULT_DATABASE"] = "default_db"
55+
5156
from langchain_openai import ChatOpenAI
5257
from langgraph.prebuilt import create_react_agent
5358

@@ -56,8 +61,18 @@ from langchain_graphiti.tools import create_basic_agent_tools
5661
from langchain_graphiti.config import LLMProvider, DriverProvider, OpenAIConfig, Neo4jConfig
5762

5863
# 1. Configure your providers
59-
llm_config = OpenAIConfig() # Assumes OPENAI_API_KEY is in your environment
60-
driver_config = Neo4jConfig() # Assumes NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD are set
64+
llm_config = OpenAIConfig(
65+
api_key=os.getenv("OPENAI_API_KEY"),
66+
model="gpt-4o", # Use the model you prefer
67+
small_model="gpt-3.5-turbo", # Optional: for smaller tasks
68+
embedding_model="text-embedding-3-small",
69+
embedding_dim=1536, # Optional: dimension of the embeddings
70+
)
71+
driver_config = Neo4jConfig(
72+
uri=os.getenv("NEO4J_URI", "bolt://localhost:7687"),
73+
user=os.getenv("NEO4J_USER", "neo4j"),
74+
password=os.getenv("NEO4J_PASSWORD", "password")
75+
)
6176

6277
# 2. Create the GraphitiClient
6378
# This client manages the connection to your knowledge graph
@@ -74,6 +89,10 @@ tools = create_basic_agent_tools(client)
7489

7590
# 4. Set up your LangChain agent
7691
llm = ChatOpenAI(model="gpt-4o")
92+
93+
# I recommend using more advanced agents than `ReAct` for production use, but this is a simple example.
94+
# This is because agents may (rarely) make mistakes during tool calls, but they will get it right in
95+
# usually the second try.
7796
agent_executor = create_react_agent(llm, tools)
7897

7998
async def main():

src/langchain_graphiti/_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ class GraphitiClient(BaseModel):
9696
async with GraphitiClient.from_connections(...) as client:
9797
# Use client
9898
pass
99+
100+
# Option 4: Using factory method
101+
client = GraphitiClient.from_factory(
102+
llm_provider=LLMProvider.OPENAI,
103+
driver_provider=DriverProvider.NEO4J,
104+
llm_config=OpenAIConfig(...),
105+
driver_config=Neo4jConfig(...),
106+
)
99107
```
100108
"""
101109

0 commit comments

Comments
 (0)