This will help you get started with the Memgraph toolkit.
Tools within MemgraphToolkit
are designed for the interaction with the Memgraph
database.
To be able tot follow the steps below, make sure you have a running Memgraph instance on your local host. For more details on how to run Memgraph, take a look at Memgraph docs
If you want to get automated tracing from runs of individual tools, you can also set your LangSmith API key by uncommenting below:
InstallationThis toolkit lives in the langchain-memgraph
package:
%pip install -qU langchain-memgraph
Instantiation
Now we can instantiate our toolkit:
from langchain.chat_models import init_chat_model
from langchain_memgraph import MemgraphToolkit
from langchain_memgraph.graphs.memgraph import MemgraphLangChain
db = MemgraphLangChain(url=url, username=username, password=password)
llm = init_chat_model("gpt-4o-mini", model_provider="openai")
toolkit = MemgraphToolkit(
db=db,
llm=llm,
)
View available tools:
InvocationTools can be individually called by passing an arguments, for QueryMemgraphTool it would be:
from langchain_memgraph.tools import QueryMemgraphTool
tool.invoke({QueryMemgraphTool({"query": "MATCH (n) RETURN n LIMIT 5"})})
Use within an agent
from langgraph.prebuilt import create_react_agent
agent_executor = create_react_agent(llm, tools)
example_query = "MATCH (n) RETURN n LIMIT 1"
events = agent_executor.stream(
{"messages": [("user", example_query)]},
stream_mode="values",
)
for event in events:
event["messages"][-1].pretty_print()
API reference
For more details on API visit Memgraph integration docs
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4