Using Neptune with LangChain #23681
Replies: 1 comment 4 replies
-
To avoid the timeout error when using the NeptuneGraph integration with LangChain, you should pass the Neptune cluster's endpoint as the host. This is typically in the format of a URL provided by AWS Neptune. Here's an example of how you can set it up: import boto3
from langchain.chains.graph_qa.neptune_sparql import NeptuneSparqlQAChain
from langchain_community.chat_models import BedrockChat
from langchain_community.graphs import NeptuneRdfGraph
host = "<your-neptune-cluster-endpoint>"
port = 8182 # change if different
region = "us-east-1" # change if different
graph = NeptuneRdfGraph(host=host, port=port, use_iam_auth=True, region_name=region)
MODEL_ID = "anthropic.claude-v2"
bedrock_client = boto3.client("bedrock-runtime")
llm = BedrockChat(model_id=MODEL_ID, client=bedrock_client)
chain = NeptuneSparqlQAChain.from_llm(
llm=llm,
graph=graph,
examples=EXAMPLES,
verbose=True,
top_K=10,
return_intermediate_steps=True,
return_direct=False,
) Replace |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Hello, I am trying to use the NeptuneGraph integration provided by Langchain on Link to Docs
I try passing the endpoint as host, but everytime the response is a timeout error. There isn't enough explanation on langchain's docs regarding what the issue might be also what am i actually supposed to pass as host in above code ???
System Info
Python 3.12
Langchain 0.2
Windows 10
Beta Was this translation helpful? Give feedback.
All reactions