langchain_community.graphs.neptune_rdf_graph.NeptuneRdfGraph¶

class langchain_community.graphs.neptune_rdf_graph.NeptuneRdfGraph(host: str, port: int = 8182, use_iam_auth: bool = False, region_name: Optional[str] = None, hide_comments: bool = False)[source]¶

Neptune wrapper for RDF graph operations.

Parameters
  • host (str) – SPARQL endpoint host for Neptune

  • port (int) – SPARQL endpoint port for Neptune. Defaults 8182.

  • use_iam_auth (bool) – boolean indicating IAM auth is enabled in Neptune cluster

  • region_name (Optional[str]) – AWS region required if use_iam_auth is True, e.g., us-west-2

  • hide_comments (bool) – whether to include ontology comments in schema for prompt

Example


graph = NeptuneRdfGraph(

host=’<SPARQL host’>, port=<SPARQL port>, use_iam_auth=False

) schema = graph.get_schema()

OR graph = NeptuneRdfGraph(

host=’<SPARQL host’>, port=<SPARQL port>, use_iam_auth=False

) schema_elem = graph.get_schema_elements() … change schema_elements … graph.load_schema(schema_elem) schema = graph.get_schema()

Security note: Make sure that the database connection uses credentials

that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool.

See https://python.langchain.com/docs/security for more information.

Attributes

get_schema

Returns the schema of the graph database.

get_schema_elements

Methods

__init__(host[, port, use_iam_auth, ...])

load_schema(schema_elements)

Generates and sets schema from schema_elements.

query(query)

Run Neptune query.

__init__(host: str, port: int = 8182, use_iam_auth: bool = False, region_name: Optional[str] = None, hide_comments: bool = False) None[source]¶
Parameters
  • host (str) –

  • port (int) –

  • use_iam_auth (bool) –

  • region_name (Optional[str]) –

  • hide_comments (bool) –

Return type

None

load_schema(schema_elements: Dict[str, Any]) None[source]¶

Generates and sets schema from schema_elements. Helpful in cases where introspected schema needs pruning.

Parameters

schema_elements (Dict[str, Any]) –

Return type

None

query(query: str) Dict[str, Any][source]¶

Run Neptune query.

Parameters

query (str) –

Return type

Dict[str, Any]