viruPVS/langchain-docs huggingface dataset:
langchain_core.tracers.schemas.Run¶
class langchain_core.tracers.schemas.Run[source]¶
Bases: RunBase
Run schema for the V2 API in the Tracer.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param child_execution_order: int [Required]¶
param child_runs: List[langchain_core.tracers.schemas.Run] [Optional]¶
param end_time: Optional[<module 'datetime' from '/home/docs/.asdf/installs/python/3.11.6/lib/python3.11/datetime.py'>] = None¶
End time of the run, if applicable.
param error: Optional[str] = None¶
Error message, if the run encountered any issues.
param events: List[Dict[str, Any]] [Optional]¶
List of events associated with the run, like
start and end events.
param execution_order: int [Required]¶
param extra: Optional[dict] = None¶
Additional metadata or settings related to the run.
param id: uuid.UUID [Required]¶
Unique identifier for the run.
param inputs: dict [Required]¶
Inputs used for the run.
param name: str [Required]¶
Human-readable name for the run.
param outputs: Optional[dict] = None¶
Outputs generated by the run, if any.
param parent_run_id: Optional[uuid.UUID] = None¶
Identifier for a parent run, if this run is a sub-run.
param reference_example_id: Optional[uuid.UUID] = None¶
Reference to an example that this run may be based on.
param run_type: str [Required]¶
The type of run, such as tool, chain, llm, retriever,
embedding, prompt, parser.
embedding, prompt, parser.
param serialized: Optional[dict] = None¶
Serialized object that executed the run for potential reuse.
param start_time: <module 'datetime' from '/home/docs/.asdf/installs/python/3.11.6/lib/python3.11/datetime.py'> [Required]¶
Start time of the run.
param tags: Optional[List[str]] [Optional]¶
Tags for categorizing or annotating the run.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep – set to True to make a deep copy of the model
Returns
new model instance
langchain_core.tracers.evaluation.EvaluatorCallbackHandler¶
class langchain_core.tracers.evaluation.EvaluatorCallbackHandler(evaluators: Sequence[RunEvaluator], client: Optional[Client] = None, example_id: Optional[Union[str, UUID]] = None, skip_unfinished: bool = True, project_name: Optional[str] = 'evaluators', max_concurrency: Optional[int] = None, **kwargs: Any)[source]¶
A tracer that runs a run evaluator whenever a run is persisted.
Parameters
evaluators (Sequence[RunEvaluator]) – The run evaluators to apply to all top level runs.
client (LangSmith Client, optional) – The LangSmith client instance to use for evaluating the runs.
If not specified, a new instance will be created.
example_id (Union[UUID, str], optional) – The example ID to be associated with the runs.
project_name (str, optional) – The LangSmith project name to be organize eval chain runs under.
example_id¶
The example ID associated with the runs.
Type
Union[UUID, None]
client¶
The LangSmith client instance used for evaluating the runs.
Type
Client
evaluators¶
The sequence of run evaluators to be executed.
Type
Sequence[RunEvaluator]
executor¶
The thread pool executor used for running the evaluators.
Type
ThreadPoolExecutor
futures¶
The set of futures representing the running evaluators.
Type
Set[Future]
skip_unfinished¶
Whether to skip runs that are not finished or raised
an error.
Type
bool
project_name¶
The LangSmith project name to be organize eval chain runs under.
Type
Optional[str]
Attributes
ignore_agent
Whether to ignore agent callbacks.
ignore_chain
Whether to ignore chain callbacks.
ignore_chat_model
ignore_chain
Whether to ignore chain callbacks.
ignore_chat_model
Whether to ignore chat model callbacks.
ignore_llm
Whether to ignore LLM callbacks.
ignore_retriever
Whether to ignore retriever callbacks.
ignore_retry
Whether to ignore retry callbacks.
name
raise_error
run_inline
Methods
__init__(evaluators[, client, example_id, ...])
on_agent_action(action, *, run_id[, ...])
Run on agent action.
on_agent_finish(finish, *, run_id[, ...])
Run on agent end.
on_chain_end(outputs, *, run_id[, inputs])
End a trace for a chain run.
on_chain_error(error, *[, inputs])
Handle an error for a chain run.
on_chain_start(serialized, inputs, *, run_id)
Start a trace for a chain run.
on_chat_model_start(serialized, messages, *, ...)
Run when a chat model starts running.
on_llm_end(response, *, run_id, **kwargs)
End a trace for an LLM run.
on_llm_error(error, *, run_id, **kwargs)
Handle an error for an LLM run.
on_llm_new_token(token, *[, chunk, ...])
Run on new LLM token.
on_llm_start(serialized, prompts, *, run_id)
Start a trace for an LLM run.
on_retriever_end(documents, *, run_id, **kwargs)
Run when Retriever ends running.
on_retriever_error(error, *, run_id, **kwargs)
Run when Retriever errors.
Run when Retriever errors.
on_retriever_start(serialized, query, *, run_id)
Run when Retriever starts running.
on_retry(retry_state, *, run_id, **kwargs)
Run on a retry event.
on_text(text, *, run_id[, parent_run_id])
Run on arbitrary text.
on_tool_end(output, *, run_id, **kwargs)
End a trace for a tool run.
on_tool_error(error, *, run_id, **kwargs)
Handle an error for a tool run.
on_tool_start(serialized, input_str, *, run_id)
Start a trace for a tool run.
wait_for_futures()
Wait for all futures to complete.
__init__(evaluators: Sequence[RunEvaluator], client: Optional[Client] = None, example_id: Optional[Union[str, UUID]] = None, skip_unfinished: bool = True, project_name: Optional[str] = 'evaluators', max_concurrency: Optional[int] = None, **kwargs: Any) → None[source]¶
on_agent_action(action: AgentAction, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶
Run on agent action.
on_agent_finish(finish: AgentFinish, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶
Run on agent end.
on_chain_end(outputs: Dict[str, Any], *, run_id: UUID, inputs: Optional[Dict[str, Any]] = None, **kwargs: Any) → Run¶
End a trace for a chain run.
Handle an error for a tool run.
on_tool_start(serialized: Dict[str, Any], input_str: str, *, run_id: UUID, tags: Optional[List[str]] = None, parent_run_id: Optional[UUID] = None, metadata: Optional[Dict[str, Any]] = None, name: Optional[str] = None, **kwargs: Any) → Run¶
Start a trace for a tool run.
wait_for_futures() → None[source]¶
Wait for all futures to complete.
langchain_core.tracers.stdout.ConsoleCallbackHandler¶
class langchain_core.tracers.stdout.ConsoleCallbackHandler(**kwargs: Any)[source]¶
Tracer that prints to the console.
Attributes
ignore_agent
Whether to ignore agent callbacks.
ignore_chain
Whether to ignore chain callbacks.
ignore_chat_model
Whether to ignore chat model callbacks.
ignore_llm
Whether to ignore LLM callbacks.
ignore_retriever
Whether to ignore retriever callbacks.
ignore_retry
Whether to ignore retry callbacks.
name
raise_error
run_inline
Methods
__init__(**kwargs)
get_breadcrumbs(run)
get_parents(run)
on_agent_action(action, *, run_id[, ...])
Run on agent action.
on_agent_finish(finish, *, run_id[, ...])
Run on agent end.
on_chain_end(outputs, *, run_id[, inputs])
End a trace for a chain run.
on_chain_error(error, *[, inputs])
Handle an error for a chain run.
on_chain_start(serialized, inputs, *, run_id)
Start a trace for a chain run.
on_chat_model_start(serialized, messages, *, ...)
Run when a chat model starts running.
on_llm_end(response, *, run_id, **kwargs)
End a trace for an LLM run.
on_llm_error(error, *, run_id, **kwargs)
Handle an error for an LLM run.
on_llm_new_token(token, *[, chunk, ...])
Run on new LLM token.
on_llm_start(serialized, prompts, *, run_id)
Start a trace for an LLM run.
on_retriever_end(documents, *, run_id, **kwargs)
on_retriever_end(documents, *, run_id, **kwargs)
Run when Retriever ends running.
on_retriever_error(error, *, run_id, **kwargs)
Run when Retriever errors.
on_retriever_start(serialized, query, *, run_id)
Run when Retriever starts running.
on_retry(retry_state, *, run_id, **kwargs)
Run on a retry event.
on_text(text, *, run_id[, parent_run_id])
Run on arbitrary text.
on_tool_end(output, *, run_id, **kwargs)
End a trace for a tool run.
on_tool_error(error, *, run_id, **kwargs)
Handle an error for a tool run.
on_tool_start(serialized, input_str, *, run_id)
Start a trace for a tool run.
__init__(**kwargs: Any) → None[source]¶
get_breadcrumbs(run: Run) → str¶
get_parents(run: Run) → List[Run]¶
on_agent_action(action: AgentAction, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶
Run on agent action.
on_agent_finish(finish: AgentFinish, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶
Run on agent end.
on_chain_end(outputs: Dict[str, Any], *, run_id: UUID, inputs: Optional[Dict[str, Any]] = None, **kwargs: Any) → Run¶
End a trace for a chain run.
langchain_core.tracers.stdout.try_json_stringify¶
langchain_core.tracers.stdout.try_json_stringify(obj: Any, fallback: str) → str[source]¶
Try to stringify an object to JSON.
:param obj: Object to stringify.
:param fallback: Fallback string to return if the object cannot be stringified.
Returns
A JSON string if the object can be stringified, otherwise the fallback string.
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
__init__(db: Any, database: str = 'kuzu') → None[source]¶
query(query: str, params: dict = {}) → List[Dict[str, Any]][source]¶
Query Kùzu database
refresh_schema() → None[source]¶
Refreshes the Kùzu graph schema information
Examples using KuzuGraph¶
KuzuQAChain
langchain_community.graphs.networkx_graph.KnowledgeTriple¶
class langchain_community.graphs.networkx_graph.KnowledgeTriple(subject: str, predicate: str, object_: str)[source]¶
A triple in the graph.
Create new instance of KnowledgeTriple(subject, predicate, object_)
Attributes
object_
Alias for field number 2
predicate
Alias for field number 1
subject
Alias for field number 0
Methods
__init__()
count(value, /)
Return number of occurrences of value.
from_string(triple_string)
Create a KnowledgeTriple from a string.
index(value[, start, stop])
Return first index of value.
__init__()¶
count(value, /)¶
Return number of occurrences of value.
classmethod from_string(triple_string: str) → KnowledgeTriple[source]¶
Create a KnowledgeTriple from a string.
index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
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
__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.
Create a new FalkorDB graph wrapper instance.
add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) → None[source]¶
Take GraphDocument as input as uses it to construct a graph.
query(query: str, params: dict = {}) → List[Dict[str, Any]][source]¶
Query FalkorDB database.
refresh_schema() → None[source]¶
Refreshes the schema of the FalkorDB database
Examples using FalkorDBGraph¶
FalkorDBQAChain
langchain_community.graphs.graph_document.GraphDocument¶
class langchain_community.graphs.graph_document.GraphDocument[source]¶
Bases: Serializable
Represents a graph document consisting of nodes and relationships.
nodes¶
A list of nodes in the graph.
Type
List[Node]
relationships¶
A list of relationships in the graph.
Type
List[Relationship]
source¶
The document from which the graph information is derived.
Type
Document
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param nodes: List[langchain_community.graphs.graph_document.Node] [Required]¶
param relationships: List[langchain_community.graphs.graph_document.Relationship] [Required]¶
param source: langchain_core.documents.base.Document [Required]¶
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
langchain_community.graphs.hugegraph.HugeGraph¶
class langchain_community.graphs.hugegraph.HugeGraph(username: str = 'default', password: str = 'default', address: str = '127.0.0.1', port: int = 8081, graph: str = 'hugegraph')[source]¶
HugeGraph 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 HugeGraph wrapper instance.
Attributes
get_schema
Returns the schema of the HugeGraph database
Methods
__init__([username, password, address, ...])
Create a new HugeGraph wrapper instance.
query(query)
refresh_schema()
Refreshes the HugeGraph schema information.
__init__(username: str = 'default', password: str = 'default', address: str = '127.0.0.1', port: int = 8081, graph: str = 'hugegraph') → None[source]¶
Create a new HugeGraph wrapper instance.
query(query: str) → List[Dict[str, Any]][source]¶
refresh_schema() → None[source]¶
Refreshes the HugeGraph schema information.
Examples using HugeGraph¶
HugeGraph QA Chain
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: str = 'neo4j')[source]¶
Neo4j 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 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, database])
Create a new Neo4j graph wrapper instance.
add_graph_documents(graph_documents[, ...])
Take GraphDocument as input as uses it to construct a graph.
query(query[, params])
Query Neo4j database.
refresh_schema()
Refreshes the Neo4j graph schema information.
__init__(url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, database: str = 'neo4j') → None[source]¶
Create a new Neo4j graph wrapper instance.
add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) → None[source]¶
Take GraphDocument as input as uses it to construct a graph.
langchain_community.graphs.memgraph_graph.MemgraphGraph¶
class langchain_community.graphs.memgraph_graph.MemgraphGraph(url: str, username: str, password: str, *, database: str = 'memgraph')[source]¶
Memgraph 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 Memgraph 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, *[, database])
Create a new Memgraph graph wrapper instance.
add_graph_documents(graph_documents[, ...])
Take GraphDocument as input as uses it to construct a graph.
query(query[, params])
Query Neo4j database.
refresh_schema()
Refreshes the Memgraph graph schema information.
__init__(url: str, username: str, password: str, *, database: str = 'memgraph') → None[source]¶
Create a new Memgraph graph wrapper instance.
add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) → None¶
Take GraphDocument as input as uses it to construct a graph.
query(query: str, params: dict = {}) → List[Dict[str, Any]]¶
Query Neo4j database.
langchain_community.graphs.graph_document.Node¶
class langchain_community.graphs.graph_document.Node[source]¶
Bases: Serializable
Represents a node in a graph with associated properties.
id¶
A unique identifier for the node.
Type
Union[str, int]
type¶
The type or label of the node, default is “Node”.
Type
str
properties¶
Additional properties and metadata associated with the node.
Type
dict
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param id: Union[str, int] [Required]¶
param properties: dict [Optional]¶
param type: str = 'Node'¶
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep – set to True to make a deep copy of the model
Returns
new model instance
langchain_community.graphs.neptune_graph.NeptuneGraph¶
class langchain_community.graphs.neptune_graph.NeptuneGraph(host: str, port: int = 8182, use_https: bool = True, client: Any = None, credentials_profile_name: Optional[str] = None, region_name: Optional[str] = None, service: str = 'neptunedata', sign: bool = True)[source]¶
Neptune wrapper for graph operations.
Parameters
host – endpoint for the database instance
port – port number for the database instance, default is 8182
use_https – whether to use secure connection, default is True
client – optional boto3 Neptune client
credentials_profile_name – optional AWS profile name
region_name – optional AWS region, e.g., us-west-2
service – optional service name, default is neptunedata
sign – optional, whether to sign the request payload, default is True
Example
graph = NeptuneGraph(host=’<my-cluster>’,
port=8182
)
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 graph wrapper instance.
Attributes
get_schema
Returns the schema of the Neptune database
Methods
__init__(host[, port, use_https, client, ...])
Create a new Neptune graph wrapper instance.
query(query[, params])
Query Neptune database.