@@ -48,6 +48,11 @@ Here's a simple example of how to get up and running with `langchain-graphiti`.
4848
4949``` python
5050import 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+
5156from langchain_openai import ChatOpenAI
5257from langgraph.prebuilt import create_react_agent
5358
@@ -56,8 +61,18 @@ from langchain_graphiti.tools import create_basic_agent_tools
5661from 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
7691llm = 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.
7796agent_executor = create_react_agent(llm, tools)
7897
7998async def main ():
0 commit comments