Tony20100/langchain_full huggingface dataset:
Is this class serializable?
Return type
bool
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod lc_id() → List[str]¶
A unique identifier for this class for serialization purposes.
The unique identifier is a list of strings that describes the path
to the object.
Return type
List[str]
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) –
value (Any) – 
Return type
Model
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
Examples using GraphDocument¶
Azure Cosmos DB for Apache Gremlin
Microsoft
langchain_community.graphs.neo4j_graph.Neo4jGraph¶
class langchain_community.graphs.neo4j_graph.Neo4jGraph(url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, database: Optional[str] = None, timeout: Optional[float] = None, sanitize: bool = False, refresh_schema: bool = True, *, driver_config: Optional[Dict] = None, enhanced_schema: bool = False)[source]¶
Neo4j database wrapper for various graph operations.
Parameters:
url (Optional[str]): The URL of the Neo4j database server.
username (Optional[str]): The username for database authentication.
password (Optional[str]): The password for database authentication.
database (str): The name of the database to connect to. Default is ‘neo4j’.
timeout (Optional[float]): The timeout for transactions in seconds.
Useful for terminating long-running queries.
By default, there is no timeout set.
sanitize (bool): A flag to indicate whether to remove lists withmore than 128 elements from results. Useful for removing
embedding-like properties from database responses. Default is False.
refresh_schema (bool): A flag whether to refresh schema informationat initialization. Default is True.
enhanced_schema (bool): A flag whether to scan the database forexample values and use them in the graph schema. Default is False.
driver_config (Dict): Configuration passed to Neo4j Driver.
Security note: Make sure that the database connection uses credentialsthat 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)
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.
Create a new Neo4j graph wrapper instance.
Attributes
get_schema
Returns the schema of the Graph
get_structured_schema
Returns the structured schema of the Graph
Methods
__init__([url, username, password, ...])
Create a new Neo4j graph wrapper instance.
add_graph_documents(graph_documents[, ...])
This method constructs nodes and relationships in the graph based on the provided GraphDocument objects.
query(query[, params])
Query Neo4j database.
refresh_schema()
Refreshes the Neo4j graph schema information.
Parameters
url (Optional[str]) – 
username (Optional[str]) – 
password (Optional[str]) – 
database (Optional[str]) – 
timeout (Optional[float]) – 
sanitize (bool) – 
refresh_schema (bool) – 
driver_config (Optional[Dict]) – 
enhanced_schema (bool) – 
__init__(url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, database: Optional[str] = None, timeout: Optional[float] = None, sanitize: bool = False, refresh_schema: bool = True, *, driver_config: Optional[Dict] = None, enhanced_schema: bool = False) → None[source]¶
Create a new Neo4j graph wrapper instance.
Parameters
url (Optional[str]) – 
username (Optional[str]) – 
password (Optional[str]) – 
database (Optional[str]) – 
timeout (Optional[float]) – 
sanitize (bool) – 
refresh_schema (bool) – 
driver_config (Optional[Dict]) –
refresh_schema (bool) – 
driver_config (Optional[Dict]) – 
enhanced_schema (bool) – 
Return type
None
add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False, baseEntityLabel: bool = False) → None[source]¶
This method constructs nodes and relationships in the graph based on the
provided GraphDocument objects.
Parameters:
- graph_documents (List[GraphDocument]): A list of GraphDocument objects
that contain the nodes and relationships to be added to the graph. Each
GraphDocument should encapsulate the structure of part of the graph,
including nodes, relationships, and the source document information.
- include_source (bool, optional): If True, stores the source document
and links it to nodes in the graph using the MENTIONS relationship.
This is useful for tracing back the origin of data. Merges source
documents based on the id property from the source document metadata
if available; otherwise it calculates the MD5 hash of page_content
for merging process. Defaults to False.
- baseEntityLabel (bool, optional): If True, each newly created node
gets a secondary __Entity__ label, which is indexed and improves import
speed and performance. Defaults to False.
Parameters
graph_documents (List[GraphDocument]) – 
include_source (bool) – 
baseEntityLabel (bool) – 
Return type
None
query(query: str, params: dict = {}) → List[Dict[str, Any]][source]¶
Query Neo4j database.
Parameters
query (str) – 
params (dict) – 
Return type
List[Dict[str, Any]]
refresh_schema() → None[source]¶
Refreshes the Neo4j graph schema information.
Return type
None
Examples using Neo4jGraph¶
langchain_community.graphs.arangodb_graph.ArangoGraph¶
class langchain_community.graphs.arangodb_graph.ArangoGraph(db: Any)[source]¶
ArangoDB wrapper for graph operations.
Security note: Make sure that the database connection uses credentialsthat 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.
Create a new ArangoDB graph wrapper instance.
Attributes
db
schema
Methods
__init__(db)
Create a new ArangoDB graph wrapper instance.
from_db_credentials([url, dbname, username, ...])
Convenience constructor that builds Arango DB from credentials.
generate_schema([sample_ratio])
Generates the schema of the ArangoDB Database and returns it User can specify a sample_ratio (0 to 1) to determine the ratio of documents/edges used (in relation to the Collection size) to render each Collection Schema.
query(query[, top_k])
Query the ArangoDB database.
set_db(db)
set_schema([schema])
Set the schema of the ArangoDB Database.
Parameters
db (Any) – 
__init__(db: Any) → None[source]¶
Create a new ArangoDB graph wrapper instance.
Parameters
db (Any) – 
Return type
None
Parameters
db (Any) – 
Return type
None
classmethod from_db_credentials(url: Optional[str] = None, dbname: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None) → Any[source]¶
Convenience constructor that builds Arango DB from credentials.
Parameters
url (Optional[str]) – Arango DB url. Can be passed in as named arg or set as environment
var ARANGODB_URL. Defaults to “http://localhost:8529”.
dbname (Optional[str]) – Arango DB name. Can be passed in as named arg or set as
environment var ARANGODB_DBNAME. Defaults to “_system”.
username (Optional[str]) – Can be passed in as named arg or set as environment var
ARANGODB_USERNAME. Defaults to “root”.
password (Optional[str]) – Can be passed ni as named arg or set as environment var
ARANGODB_PASSWORD. Defaults to “”.
Returns
An arango.database.StandardDatabase.
Return type
Any
generate_schema(sample_ratio: float = 0) → Dict[str, List[Dict[str, Any]]][source]¶
Generates the schema of the ArangoDB Database and returns it
User can specify a sample_ratio (0 to 1) to determine the
ratio of documents/edges used (in relation to the Collection size)
to render each Collection Schema.
Parameters
sample_ratio (float) – 
Return type
Dict[str, List[Dict[str, Any]]]
query(query: str, top_k: Optional[int] = None, **kwargs: Any) → List[Dict[str, Any]][source]¶
Query the ArangoDB database.
Parameters
query (str) – 
top_k (Optional[int]) – 
kwargs (Any) – 
Return type
List[Dict[str, Any]]
kwargs (Any) – 
Return type
List[Dict[str, Any]]
set_db(db: Any) → None[source]¶
Parameters
db (Any) – 
Return type
None
set_schema(schema: Optional[Dict[str, Any]] = None) → None[source]¶
Set the schema of the ArangoDB Database.
Auto-generates Schema if schema is None.
Parameters
schema (Optional[Dict[str, Any]]) – 
Return type
None
Examples using ArangoGraph¶
ArangoDB
langchain_aws.graphs.neptune_graph.NeptuneAnalyticsGraph¶
class langchain_aws.graphs.neptune_graph.NeptuneAnalyticsGraph(graph_identifier: str, client: Optional[Any] = None, credentials_profile_name: Optional[str] = None, region_name: Optional[str] = None)[source]¶
Neptune Analytics wrapper for graph operations.
Parameters
client (Any) – optional boto3 Neptune client
credentials_profile_name (Optional[str]) – optional AWS profile name
region_name (Optional[str]) – optional AWS region, e.g., us-west-2
graph_identifier (str) – the graph identifier for a Neptune Analytics graph
Example
graph = NeptuneAnalyticsGraph(graph_identifier=’<my-graph-id>’
)
Security note: Make sure that the database connection uses credentialsthat 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.
Create a new Neptune Analytics graph wrapper instance.
Attributes
get_schema
Returns the schema of the Neptune database
Methods
__init__(graph_identifier[, client, ...])
Create a new Neptune Analytics graph wrapper instance.
query(query[, params])
Query Neptune database.
__init__(graph_identifier: str, client: Optional[Any] = None, credentials_profile_name: Optional[str] = None, region_name: Optional[str] = None) → None[source]¶
Create a new Neptune Analytics graph wrapper instance.
Parameters
graph_identifier (str) – 
client (Optional[Any]) –
langchain_community.graphs.falkordb_graph.FalkorDBGraph¶
class langchain_community.graphs.falkordb_graph.FalkorDBGraph(database: str, host: str = 'localhost', port: int = 6379, username: Optional[str] = None, password: Optional[str] = None, ssl: bool = False)[source]¶
FalkorDB wrapper for graph operations.
Security note: Make sure that the database connection uses credentialsthat 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.
Create a new FalkorDB graph wrapper instance.
Attributes
get_schema
Returns the schema of the FalkorDB database
get_structured_schema
Returns the structured schema of the Graph
Methods
__init__(database[, host, port, username, ...])
Create a new FalkorDB graph wrapper instance.
add_graph_documents(graph_documents[, ...])
Take GraphDocument as input as uses it to construct a graph.
query(query[, params])
Query FalkorDB database.
refresh_schema()
Refreshes the schema of the FalkorDB database
Parameters
database (str) – 
host (str) – 
port (int) – 
username (Optional[str]) – 
password (Optional[str]) – 
ssl (bool) –
password (Optional[str]) – 
ssl (bool) – 
__init__(database: str, host: str = 'localhost', port: int = 6379, username: Optional[str] = None, password: Optional[str] = None, ssl: bool = False) → None[source]¶
Create a new FalkorDB graph wrapper instance.
Parameters
database (str) – 
host (str) – 
port (int) – 
username (Optional[str]) – 
password (Optional[str]) – 
ssl (bool) – 
Return type
None
add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) → None[source]¶
Take GraphDocument as input as uses it to construct a graph.
Parameters
graph_documents (List[GraphDocument]) – 
include_source (bool) – 
Return type
None
query(query: str, params: dict = {}) → List[Dict[str, Any]][source]¶
Query FalkorDB database.
Parameters
query (str) – 
params (dict) – 
Return type
List[Dict[str, Any]]
refresh_schema() → None[source]¶
Refreshes the schema of the FalkorDB database
Return type
None
Examples using FalkorDBGraph¶
FalkorDB
langchain_community.graphs.kuzu_graph.KuzuGraph¶
class langchain_community.graphs.kuzu_graph.KuzuGraph(db: Any, database: str = 'kuzu')[source]¶
Kùzu wrapper for graph operations.
Security note: Make sure that the database connection uses credentialsthat 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 Kùzu database
Methods
__init__(db[, database])
query(query[, params])
Query Kùzu database
refresh_schema()
Refreshes the Kùzu graph schema information
Parameters
db (Any) – 
database (str) – 
__init__(db: Any, database: str = 'kuzu') → None[source]¶
Parameters
db (Any) – 
database (str) – 
Return type
None
query(query: str, params: dict = {}) → List[Dict[str, Any]][source]¶
Query Kùzu database
Parameters
query (str) – 
params (dict) – 
Return type
List[Dict[str, Any]]
refresh_schema() → None[source]¶
Refreshes the Kùzu graph schema information
Return type
None
Examples using KuzuGraph¶
Kuzu
langchain_community.graphs.neo4j_graph.value_sanitize¶
langchain_community.graphs.neo4j_graph.value_sanitize(d: Any) → Any[source]¶
Sanitize the input dictionary or list.
Sanitizes the input by removing embedding-like values,
lists with more than 128 elements, that are mostly irrelevant for
generating answers in a LLM context. These properties, if left in
results, can occupy significant context space and detract from
the LLM’s performance by introducing unnecessary noise and cost.
Parameters
d (Any) – 
Return type
Any
langchain_community.graphs.tigergraph_graph.TigerGraph¶
class langchain_community.graphs.tigergraph_graph.TigerGraph(conn: Any)[source]¶
TigerGraph wrapper for graph operations.
Security note: Make sure that the database connection uses credentialsthat 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.
Create a new TigerGraph graph wrapper instance.
Attributes
conn
get_structured_schema
Return the schema of the Graph database
schema
Methods
__init__(conn)
Create a new TigerGraph graph wrapper instance.
add_graph_documents(graph_documents[, ...])
Take GraphDocument as input as uses it to construct a graph.
generate_schema()
Generates the schema of the TigerGraph Database and returns it User can specify a sample_ratio (0 to 1) to determine the ratio of documents/edges used (in relation to the Collection size) to render each Collection Schema.
get_schema()
Return the schema of the Graph database
query(query)
Query the TigerGraph database.
refresh_schema()
Refresh the graph schema information.
register_query(function_header, description, ...)
Wrapper function to register a custom GSQL query to the TigerGraph NLQS.
set_connection(conn)
set_schema([schema])
Set the schema of the TigerGraph Database.
Parameters
conn (Any) – 
__init__(conn: Any) → None[source]¶
Create a new TigerGraph graph wrapper instance.
Parameters
Create a new TigerGraph graph wrapper instance.
Parameters
conn (Any) – 
Return type
None
abstract add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) → None¶
Take GraphDocument as input as uses it to construct a graph.
Parameters
graph_documents (List[GraphDocument]) – 
include_source (bool) – 
Return type
None
generate_schema() → Dict[str, List[Dict[str, Any]]][source]¶
Generates the schema of the TigerGraph Database and returns it
User can specify a sample_ratio (0 to 1) to determine the
ratio of documents/edges used (in relation to the Collection size)
to render each Collection Schema.
Return type
Dict[str, List[Dict[str, Any]]]
get_schema() → str[source]¶
Return the schema of the Graph database
Return type
str
query(query: str) → Dict[str, Any][source]¶
Query the TigerGraph database.
Parameters
query (str) – 
Return type
Dict[str, Any]
refresh_schema()[source]¶
Refresh the graph schema information.
register_query(function_header: str, description: str, docstring: str, param_types: dict = {}) → List[str][source]¶
Wrapper function to register a custom GSQL query to the TigerGraph NLQS.
Parameters
function_header (str) – 
description (str) – 
docstring (str) – 
param_types (dict) – 
Return type
List[str]
set_connection(conn: Any) → None[source]¶
Parameters
conn (Any) – 
Return type
None
set_schema(schema: Optional[Dict[str, Any]] = None) → None[source]¶
Set the schema of the TigerGraph Database.
langchain_community.graphs.ontotext_graphdb_graph.OntotextGraphDBGraph¶
class langchain_community.graphs.ontotext_graphdb_graph.OntotextGraphDBGraph(query_endpoint: str, query_ontology: Optional[str] = None, local_file: Optional[str] = None, local_file_format: Optional[str] = None)[source]¶
Ontotext GraphDB https://graphdb.ontotext.com/ wrapper for graph operations.
Security note: Make sure that the database connection uses credentialsthat 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.
Set up the GraphDB wrapper
Parameters
query_endpoint (str) – SPARQL endpoint for queries, read access
query_ontology (Optional[str]) – 
local_file (Optional[str]) – 
local_file_format (Optional[str]) – 
If GraphDB is secured,
set the environment variables ‘GRAPHDB_USERNAME’ and ‘GRAPHDB_PASSWORD’.
Parameters
query_ontology (Optional[str]) – a CONSTRUCT query that is executed
query_endpoint (str) – 
local_file (Optional[str]) – 
local_file_format (Optional[str]) – 
on the SPARQL endpoint and returns the KG schema statements
Example:
‘CONSTRUCT {?s ?p ?o} FROM <https://example.com/ontology/> WHERE {?s ?p ?o}’
Currently, DESCRIBE queries like
Currently, DESCRIBE queries like
‘PREFIX onto: <https://example.com/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
DESCRIBE ?term WHERE {
?term rdfs:isDefinedBy onto:
}’
are not supported, because DESCRIBE returns
the Symmetric Concise Bounded Description (SCBD),
i.e. also the incoming class links.
In case of large graphs with a million of instances, this is not efficient.
Check https://github.com/eclipse-rdf4j/rdf4j/issues/4857
Parameters
local_file (Optional[str]) – a local RDF ontology file.
query_endpoint (str) – 
query_ontology (Optional[str]) – 
local_file_format (Optional[str]) – 
Supported RDF formats:
Turtle, RDF/XML, JSON-LD, N-Triples, Notation-3, Trig, Trix, N-Quads.
If the rdf format can’t be determined from the file extension,
pass explicitly the rdf format in local_file_format param.
Parameters
local_file_format (Optional[str]) – Used if the rdf format can’t be determined
query_endpoint (str) – 
query_ontology (Optional[str]) – 
local_file (Optional[str]) – 
from the local file extension.
One of “json-ld”, “xml”, “n3”, “turtle”, “nt”, “trig”, “nquads”, “trix”
Either query_ontology or local_file should be passed.
Attributes
get_schema
Returns the schema of the graph database in turtle format
Methods
__init__(query_endpoint[, query_ontology, ...])
Set up the GraphDB wrapper
query(query)
Query the graph.
Set up the GraphDB wrapper
query(query)
Query the graph.
__init__(query_endpoint: str, query_ontology: Optional[str] = None, local_file: Optional[str] = None, local_file_format: Optional[str] = None) → None[source]¶
Set up the GraphDB wrapper
Parameters
query_endpoint (str) – SPARQL endpoint for queries, read access
query_ontology (Optional[str]) – 
local_file (Optional[str]) – 
local_file_format (Optional[str]) – 
Return type
None
If GraphDB is secured,
set the environment variables ‘GRAPHDB_USERNAME’ and ‘GRAPHDB_PASSWORD’.
Parameters
query_ontology (Optional[str]) – a CONSTRUCT query that is executed
query_endpoint (str) – 
local_file (Optional[str]) – 
local_file_format (Optional[str]) – 
Return type
None
on the SPARQL endpoint and returns the KG schema statements
Example:
‘CONSTRUCT {?s ?p ?o} FROM <https://example.com/ontology/> WHERE {?s ?p ?o}’
Currently, DESCRIBE queries like
‘PREFIX onto: <https://example.com/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
DESCRIBE ?term WHERE {
?term rdfs:isDefinedBy onto:
}’
are not supported, because DESCRIBE returns
the Symmetric Concise Bounded Description (SCBD),
i.e. also the incoming class links.
In case of large graphs with a million of instances, this is not efficient.
Check https://github.com/eclipse-rdf4j/rdf4j/issues/4857
Parameters
local_file (Optional[str]) – a local RDF ontology file.
query_endpoint (str) –