viruPVS/langchain-docs huggingface dataset:
what\'s the maximum of the pet counts for all the people?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the maximum of the pet counts for all the people?",\n        "llm_error_msg": "",\n        "expression": "SELECT MAX(value) FROM df"\n    }}\n\n\n\n\nnarrative_input: what\'s the minimum of the pet counts for all the people?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the minimum of the pet counts for all the people?",\n        "llm_error_msg": "",\n        "expression": "SELECT MIN(value) FROM df"\n    }}\n\n\n\n\nnarrative_input: what\'s the number of people with pet counts greater than 10?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the number of people with pet counts greater than 10?",\n        "llm_error_msg": "",\n        "expression": "SELECT COUNT(*) FROM df WHERE value > 10"\n    }}\n\n\n\n\nnarrative_input: what\'s the pet count for boris?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the pet count for boris?",\n        "llm_error_msg": "",\n        "expression": "SELECT name, value FROM df WHERE name = \'boris\'"\n    }}\n\n\n\n\nnarrative_input: what\'s the pet count for cindy and marcia?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the pet count for cindy and
"narrative_input": "what\'s the pet count for cindy and marcia?",\n        "llm_error_msg": "",\n        "expression": "SELECT name, value FROM df WHERE name IN (\'cindy\', \'marcia\')"\n    }}\n\n\n\n\nnarrative_input: what\'s the total pet count for cindy and marcia?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the total pet count for cindy and marcia?",\n        "llm_error_msg": "",\n        "expression": "SELECT SUM(value) FROM df WHERE name IN (\'cindy\', \'marcia\')"\n    }}\n\n\n\n\nnarrative_input: what\'s the total pet count for TED?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the total pet count for TED?",\n        "llm_error_msg": "",\n        "expression": "SELECT SUM(value) FROM df WHERE name = \'TED\'"\n    }}\n\n\n\n\n\nnarrative_input: what\'s the total dollar count for TED and cindy?\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the total dollar count for TED and cindy?",\n        "llm_error_msg": "",\n        "expression": "SELECT SUM(value) FROM df WHERE name IN (\'TED\', \'cindy\')"\n    }}\n\n\n\n\nnarrative_input: what\'s the total pet count for TED and cindy?\n\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the total pet count for TED and
"narrative_input": "what\'s the total pet count for TED and cindy?",\n        "llm_error_msg": "",\n        "expression": "SELECT SUM(value) FROM df WHERE name IN (\'TED\', \'cindy\')"\n    }}\n\n\n\n\nnarrative_input: what\'s the best for TED and cindy?\n\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the best for TED and cindy?",\n        "llm_error_msg": "ambiguous narrative_input, not sure what \'best\' means",\n        "expression": ""\n    }}\n\n\n\n\nnarrative_input: what\'s the value?\n\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "what\'s the value?",\n        "llm_error_msg": "ambiguous narrative_input, not sure what entity is being asked about",\n        "expression": ""\n    }}\n\n\n\n\n\n\nnarrative_input: how many total pets do the three have?\n\n\n\n\n\n# JSON:\n\n    {{\n        "narrative_input": "how many total pets do the three have?",\n        "llm_error_msg": "",\n        "expression": "SELECT SUM(value) FROM df"\n    }}\n\n\n\n\n\n\nnarrative_input: {narrative_input}\n\n\n\n\n# JSON:\n\n\n'¶
langchain_experimental.cpal.constants.Constant¶
class langchain_experimental.cpal.constants.Constant(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Enum for constants used in the CPAL.
narrative_input = 'narrative_input'¶
chain_answer = 'chain_answer'¶
chain_data = 'chain_data'¶
langchain_experimental.cpal.base.InterventionChain¶
class langchain_experimental.cpal.base.InterventionChain[source]¶
Bases: _BaseStoryElementChain
Set the hypothetical conditions for the causal model.
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 callback_manager: Optional[BaseCallbackManager] = None¶
Deprecated, use callbacks instead.
param callbacks: Callbacks = None¶
Optional list of callback handlers (or callback manager). Defaults to None.
Callback handlers are called throughout the lifecycle of a call to a chain,
starting with on_chain_start, ending with on_chain_end or on_chain_error.
Each custom chain can optionally call additional callback methods, see Callback docs
for full details.
param chain: LLMChain [Required]¶
param memory: Optional[BaseMemory] = None¶
Optional memory object. Defaults to None.
Memory is a class that gets called at the start
and at the end of every chain. At the start, memory loads variables and passes
them along in the chain. At the end, it saves any returned variables.
There are many different types of memory - please see memory docs
for the full catalog.
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the chain. Defaults to None.
This metadata will be associated with each call to this chain,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a chain with its use case.
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the chain. Defaults to None.
These tags will be associated with each call to this chain,
and passed as arguments to the handlers defined in callbacks.
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a chain with its use case.
param verbose: bool [Optional]¶
Whether or not run in verbose mode. In verbose mode, some intermediate logs
will be printed to the console. Defaults to the global verbose value,
accessible via langchain.globals.get_verbose().
pydantic_model¶
alias of InterventionModel
__call__(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, include_run_info: bool = False) → Dict[str, Any]¶
Execute the chain.
Parameters
inputs – Dictionary of inputs, or single input if chain expects
only one param. Should contain all inputs specified in
Chain.input_keys except for inputs that will be set by the chain’s
memory.
return_only_outputs – Whether to return only outputs in the
response. If True, only new keys generated by this chain will be
returned. If False, both input keys and new keys generated by this
chain will be returned. Defaults to False.
callbacks – Callbacks to use for this chain run. These will be called in
addition to callbacks passed to the chain during construction, but only
these runtime callbacks will propagate to calls to other objects.
tags – List of string tags to pass to all callbacks. These will be passed in
addition to tags passed to the chain during construction, but only
these runtime tags will propagate to calls to other objects.
metadata – Optional metadata associated with the chain. Defaults to None
include_run_info – Whether to include run info in the response. Defaults
to False.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
property output_schema: Type[pydantic.main.BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
template: ClassVar[str] = 'Transform the hypothetical whatif statement into JSON. Don\'t guess at any of the parts. Write NONE if you are unsure.\n\n{format_instructions}\n\n\n\nstatement: if cindy\'s pet count was 4\n\n\n\n\n# JSON:\n\n\n\n{{\n    "entity_settings" : [\n        {{ "name": "cindy", "attribute": "pet_count", "value": "4" }}\n    ]\n}}\n\n\n\n\n\nstatement: Let\'s say boris has ten dollars and Bill has 20 dollars.\n\n\n\n\n# JSON:\n\n\n{{\n    "entity_settings" : [\n        {{ "name": "boris", "attribute": "dollars", "value": "10" }},\n        {{ "name": "bill", "attribute": "dollars", "value": "20" }}\n    ]\n}}\n\n\n\n\n\nStatement: {narrative_input}\n\n\n\n\n# JSON:\n\n\n'¶
meta private:
langchain_experimental.cpal.models.ResultModel¶
class langchain_experimental.cpal.models.ResultModel[source]¶
Bases: BaseModel
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 question: str [Required] (alias 'narrative_input')¶
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
dict(*, 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) → DictStrAny¶
langchain_experimental.cpal.models.EntitySettingModel¶
class langchain_experimental.cpal.models.EntitySettingModel[source]¶
Bases: BaseModel
Initial conditions for an entity
{“name”: “bud”, “attribute”: “pet_count”, “value”: 12}
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 attribute: str [Required]¶
name of the attribute to be calculated
param name: str [Required]¶
name of the entity
param value: float [Required]¶
entity’s attribute value (calculated)
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_experimental.cpal.models.StoryModel¶
class langchain_experimental.cpal.models.StoryModel[source]¶
Bases: BaseModel
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 causal_operations: Any = None¶
param intervention: Any = None¶
param query: Any = None¶
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
deep – set to True to make a deep copy of the model
Returns
new model instance
dict(*, 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) → DictStrAny¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
classmethod from_orm(obj: Any) → Model¶
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().
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
print_debug_report() → None[source]¶
print_debug_report() → None[source]¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
classmethod validate(value: Any) → Model¶
langchain_experimental.cpal.models.InterventionModel¶
class langchain_experimental.cpal.models.InterventionModel[source]¶
Bases: BaseModel
aka initial conditions
>>> intervention.dict()
{
    entity_settings: [
        {"name": "bud", "attribute": "pet_count", "value": 12},
        {"name": "pat", "attribute": "pet_count", "value": 0},
    ],
    system_settings: None,
}
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 entity_settings: List[langchain_experimental.cpal.models.EntitySettingModel] [Required]¶
param system_settings: Optional[List[langchain_experimental.cpal.models.SystemSettingModel]] = None¶
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_experimental.cpal.models.SystemSettingModel¶
class langchain_experimental.cpal.models.SystemSettingModel[source]¶
Bases: BaseModel
Initial global conditions for the system.
{“parameter”: “interest_rate”, “value”: .05}
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 parameter: str [Required]¶
param value: float [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
deep – set to True to make a deep copy of the model
Returns
new model instance
langchain_experimental.cpal.models.NarrativeModel¶
class langchain_experimental.cpal.models.NarrativeModel[source]¶
Bases: BaseModel
Represent the narrative input as three story elements.
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 story_hypothetical: str [Required]¶
param story_outcome_question: str [Required]¶
param story_plot: str [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
deep – set to True to make a deep copy of the model
Returns
new model instance
langchain_experimental.cpal.models.EntityModel¶
class langchain_experimental.cpal.models.EntityModel[source]¶
Bases: BaseModel
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 code: str [Required]¶
entity actions
param depends_on: List[str] = []¶
ancestor entities
param name: str [Required]¶
entity name
param value: float [Required]¶
entity initial value
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_experimental.cpal.models.CausalModel¶
class langchain_experimental.cpal.models.CausalModel[source]¶
Bases: BaseModel
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 attribute: str [Required]¶
name of the attribute to be calculated
param entities: List[langchain_experimental.cpal.models.EntityModel] [Required]¶
entities in the story
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_experimental.cpal.base.NarrativeChain¶
class langchain_experimental.cpal.base.NarrativeChain[source]¶
Bases: _BaseStoryElementChain
Decompose the narrative into its story elements
causal model
query
intervention
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 callback_manager: Optional[BaseCallbackManager] = None¶
Deprecated, use callbacks instead.
param callbacks: Callbacks = None¶
Optional list of callback handlers (or callback manager). Defaults to None.
Callback handlers are called throughout the lifecycle of a call to a chain,
starting with on_chain_start, ending with on_chain_end or on_chain_error.
Each custom chain can optionally call additional callback methods, see Callback docs
for full details.
param chain: LLMChain [Required]¶
param memory: Optional[BaseMemory] = None¶
Optional memory object. Defaults to None.
Memory is a class that gets called at the start
and at the end of every chain. At the start, memory loads variables and passes
them along in the chain. At the end, it saves any returned variables.
There are many different types of memory - please see memory docs
for the full catalog.
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the chain. Defaults to None.
This metadata will be associated with each call to this chain,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a chain with its use case.
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the chain. Defaults to None.
These tags will be associated with each call to this chain,
and passed as arguments to the handlers defined in callbacks.