id stringlengths 14 15 | text stringlengths 13 2.7k | source stringlengths 60 181 |
|---|---|---|
7a05ae0dd133-0 | langchain_core.utils.input.get_color_mapping¶
langchain_core.utils.input.get_color_mapping(items: List[str], excluded_colors: Optional[List] = None) → Dict[str, str][source]¶
Get mapping for items to a support color. | https://api.python.langchain.com/en/latest/utils/langchain_core.utils.input.get_color_mapping.html |
a5c89290d18a-0 | langchain_core.utils.utils.guard_import¶
langchain_core.utils.utils.guard_import(module_name: str, *, pip_name: Optional[str] = None, package: Optional[str] = None) → Any[source]¶
Dynamically imports a module and raises a helpful exception if the module is not
installed. | https://api.python.langchain.com/en/latest/utils/langchain_core.utils.utils.guard_import.html |
922e0b9d2867-0 | langchain_core.utils.iter.NoLock¶
class langchain_core.utils.iter.NoLock[source]¶
Dummy lock that provides the proper interface but no protection
Methods
__init__()
__init__()¶ | https://api.python.langchain.com/en/latest/utils/langchain_core.utils.iter.NoLock.html |
c72dfcbbcfa3-0 | langchain.utils.ernie_functions.ToolDescription¶
class langchain.utils.ernie_functions.ToolDescription[source]¶
Representation of a callable function to the Ernie API.
type: Literal['function']¶
function: langchain.utils.ernie_functions.FunctionDescription¶ | https://api.python.langchain.com/en/latest/utils/langchain.utils.ernie_functions.ToolDescription.html |
fb213af3f177-0 | langchain_core.utils.utils.convert_to_secret_str¶
langchain_core.utils.utils.convert_to_secret_str(value: Union[SecretStr, str]) → SecretStr[source]¶
Convert a string to a SecretStr if needed. | https://api.python.langchain.com/en/latest/utils/langchain_core.utils.utils.convert_to_secret_str.html |
3fdcc833c30b-0 | langchain_community.utils.openai.is_openai_v1¶
langchain_community.utils.openai.is_openai_v1() → bool[source]¶ | https://api.python.langchain.com/en/latest/utils/langchain_community.utils.openai.is_openai_v1.html |
2bbcb44f2735-0 | langchain_experimental.smart_llm.base.SmartLLMChain¶
class langchain_experimental.smart_llm.base.SmartLLMChain[source]¶
Bases: Chain
Generalized implementation of SmartGPT (origin: https://youtu.be/wVzuvf9D9BU)
A SmartLLMChain is an LLMChain that instead of simply passing the prompt to the LLM
performs these 3 steps:
1... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-1 | Each custom chain can optionally call additional callback methods, see Callback docs
for full details.
param critique_llm: Optional[langchain_core.language_models.base.BaseLanguageModel] = None¶
LLM to use in critique step. If None given, ‘llm’ will be used.
param history: langchain_experimental.smart_llm.base.SmartLLM... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-2 | param prompt: langchain_core.prompts.base.BasePromptTemplate [Required]¶
Prompt object to use.
param resolver_llm: Optional[langchain_core.language_models.base.BaseLanguageModel] = None¶
LLM to use in resolve step. If None given, ‘llm’ will be used.
param return_intermediate_steps: bool = False¶
Whether to return ideas... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-3 | 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 gen... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-4 | e.g., if the underlying runnable uses an API which supports a batch mode.
async acall(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, ... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-5 | Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not implement a native async version of invoke.
Subclasses should override this method if they can run asynchronously.
apply(input_list: List[Dict[str, Any]], callbacks: Optional... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-6 | # -> "The temperature in Boise is..."
# Suppose we have a multi-input chain that takes a 'question' string
# and 'context' string:
question = "What's the temperature in Boise, Idaho?"
context = "Weather report for Boise, Idaho on 07/03/23..."
await chain.arun(question=question, context=context)
# -> "The temperature in... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-7 | diff – Whether to yield diffs between each step, or the current state.
with_streamed_output_list – Whether to yield the streamed_output list.
include_names – Only include logs with these names.
include_types – Only include logs with these types.
include_tags – Only include logs with these tags.
exclude_names – Exclude ... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-8 | Returns
A pydantic model that can be used to validate config.
configurable_alternatives(which: ConfigurableField, *, default_key: str = 'default', prefix_keys: bool = False, **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶
configurable_fields(**kwar... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-9 | Expects Chain._chain_type property to be implemented and for memory to benull.
Parameters
**kwargs – Keyword arguments passed to default pydantic.BaseModel.dict
method.
Returns
A dictionary representation of the chain.
Example
chain.dict(exclude_unset=True)
# -> {"_type": "foo", "verbose": False, ...}
classmethod from_... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-10 | Returns
A pydantic model that can be used to validate output.
get_prompt_strings(stage: str) → List[Tuple[Type[BaseMessagePromptTemplate], str]][source]¶
ideation_prompt() → ChatPromptTemplate[source]¶
invoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶
Transform a si... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-11 | to the object.
map() → Runnable[List[Input], List[Output]]¶
Return a new Runnable that maps a list of inputs to a list of outputs,
by calling invoke() with each input.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool =... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-12 | Prepare prompts from inputs.
resolve_prompt() → ChatPromptTemplate[source]¶
run(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶
Convenience method for executing chain.
The ma... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-13 | chain.run(question=question, context=context)
# -> "The temperature in Boise is..."
save(file_path: Union[Path, str]) → None¶
Save the chain.
Expects Chain._chain_type property to be implemented and for memory to benull.
Parameters
file_path – Path to file to save the chain to.
Example
chain.save(file_path="path/chain.... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-14 | Bind config to a Runnable, returning a new Runnable.
with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,)) → RunnableWithFallbacksT[Input, Output]¶
Add fallbacks to a runnable, returning a new Runnable.
Parameters
fallbacks – A se... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
2bbcb44f2735-15 | between retries
stop_after_attempt – The maximum number of attempts to make before giving up
Returns
A new Runnable that retries the original runnable on exceptions.
with_types(*, input_type: Optional[Type[Input]] = None, output_type: Optional[Type[Output]] = None) → Runnable[Input, Output]¶
Bind input and output types... | https://api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html |
09190b085d69-0 | langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper¶
class langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper[source]¶
Bases: StringRunMapper
Extract items to evaluate from the run object.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationErr... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper.html |
09190b085d69-1 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper.html |
09190b085d69-2 | The unique identifier is a list of strings that describes the path
to the object.
map(run: Run) → Dict[str, str][source]¶
Maps the Run to a dictionary.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper.html |
09190b085d69-3 | property output_keys: List[str]¶
The keys to extract from the run. | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.LLMStringRunMapper.html |
b6013bc46ebd-0 | langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain¶
class langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain[source]¶
Bases: Chain, RunEvaluator
Evaluate Run and optional examples.
Create a new model by parsing and validating input data from keyword arguments.
Raises Validation... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-1 | The name of the evaluation metric.
param run_mapper: StringRunMapper [Required]¶
Maps the Run to a dictionary with ‘input’ and ‘prediction’ strings.
param string_evaluator: StringEvaluator [Required]¶
The evaluation chain.
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the chain. Defaults... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-2 | 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 c... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-3 | 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
... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-4 | Convenience method for executing chain.
The main difference between this method and Chain.__call__ is that this
method expects inputs to be passed directly in as positional arguments or
keyword arguments, whereas Chain.__call__ expects a single input dictionary
with all the inputs
Parameters
*args – If the chain expect... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-5 | Subclasses should override this method if they support streaming output.
async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-6 | Default implementation of atransform, which buffers input and calls astream.
Subclasses should override this method if they can start producing output while
input is still being generated.
batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-7 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-8 | Create a StringRunEvaluatorChain from an evaluator and the run and dataset types.
This method provides an easy way to instantiate a StringRunEvaluatorChain, by
taking an evaluator and information about the type of run and the data.
The method supports LLM and chain runs.
Parameters
evaluator (StringEvaluator) – The str... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-9 | For example, if the class is langchain.llms.openai.OpenAI, then the
namespace is [“langchain”, “llms”, “openai”]
get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model that can be used to validate output to the runnable.
Runnables that leverage the configurable_fields and con... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-10 | classmethod is_lc_serializable() → bool¶
Is this class serializable?
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_defa... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-11 | Parameters
inputs – Dictionary of raw 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.
Returns
A dictionary of all inputs, including those added by the chain’s memory.
prep_outputs(inputs: Dict[str,... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-12 | these runtime tags will propagate to calls to other objects.
**kwargs – If the chain expects multiple inputs, they can be passed in
directly as keyword arguments.
Returns
The chain output.
Example
# Suppose we have a single-input chain that takes a 'question' string:
chain.run("What's the temperature in Boise, Idaho?")... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-13 | Default implementation of transform, which buffers input and then calls stream.
Subclasses should override this method if they can start producing output while
input is still being generated.
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and lo... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-14 | added to the run.
with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[Input, Output]¶
Create a new Runnable that retries the original runnable on exceptions.
Parameters
retry_if_exc... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
b6013bc46ebd-15 | A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
property output_keys: List[str]¶
Keys expected to be in the chain output.
property output_schema: Type[pydantic.main.BaseModel]¶
The type of output this runnable produces specified as a pydantic model. | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunEvaluatorChain.html |
94fb9e0efdd8-0 | langchain.smith.evaluation.name_generation.random_name¶
langchain.smith.evaluation.name_generation.random_name() → str[source]¶
Generate a random name. | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.name_generation.random_name.html |
43c796c61a04-0 | langchain.smith.evaluation.string_run_evaluator.StringRunMapper¶
class langchain.smith.evaluation.string_run_evaluator.StringRunMapper[source]¶
Bases: Serializable
Extract items to evaluate from the run object.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunMapper.html |
43c796c61a04-1 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunMapper.html |
43c796c61a04-2 | The unique identifier is a list of strings that describes the path
to the object.
abstract map(run: Run) → Dict[str, str][source]¶
Maps the Run to a dictionary.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False)... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringRunMapper.html |
982c80469aff-0 | langchain.smith.evaluation.config.EvalConfig¶
class langchain.smith.evaluation.config.EvalConfig[source]¶
Bases: BaseModel
Configuration for a given run evaluator.
Parameters
evaluator_type (EvaluatorType) – The type of evaluator to use.
get_kwargs()[source]¶
Get the keyword arguments for the evaluator configuration.
C... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.EvalConfig.html |
982c80469aff-1 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.EvalConfig.html |
982c80469aff-2 | 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¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmet... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.EvalConfig.html |
ccdf200499b8-0 | langchain.smith.evaluation.runner_utils.TestResult¶
class langchain.smith.evaluation.runner_utils.TestResult[source]¶
A dictionary of the results of a single test run.
Methods
__init__(*args, **kwargs)
clear()
copy()
fromkeys([value])
Create a new dictionary with keys from iterable and values set to value.
get(key[, de... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.TestResult.html |
ccdf200499b8-1 | get_aggregate_feedback() → pd.DataFrame[source]¶
Return quantiles for the feedback scores.
This method calculates and prints the quantiles for the feedback scores
across all feedback keys.
Returns
A DataFrame containing the quantiles for each feedback key.
items() → a set-like object providing a view on D's items¶
keys... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.TestResult.html |
03873e06990a-0 | langchain.smith.evaluation.runner_utils.arun_on_dataset¶
async langchain.smith.evaluation.runner_utils.arun_on_dataset(client: Optional[Client], dataset_name: str, llm_or_chain_factory: Union[Callable[[], Union[Chain, Runnable]], BaseLanguageModel, Callable[[dict], Any], Runnable, Chain], *, evaluation: Optional[RunEva... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.arun_on_dataset.html |
03873e06990a-1 | Examples
from langsmith import Client
from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain
from langchain.smith import smith_eval.RunEvalConfig, run_on_dataset
# Chains may have memory. Passing in a constructor function lets the
# evaluation framework avoid cross-contamination between runs... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.arun_on_dataset.html |
03873e06990a-2 | return {"score": prediction == reference}
evaluation_config = smith_eval.RunEvalConfig(
custom_evaluators = [MyStringEvaluator()],
)
await arun_on_dataset(
client,
"<my_dataset_name>",
construct_chain,
evaluation=evaluation_config,
)
Examples using arun_on_dataset¶
LangSmith Walkthrough | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.arun_on_dataset.html |
3a816d860b7a-0 | langchain.smith.evaluation.progress.ProgressBarCallback¶
class langchain.smith.evaluation.progress.ProgressBarCallback(total: int, ncols: int = 50, **kwargs: Any)[source]¶
A simple progress bar for the console.
Initialize the progress bar.
Parameters
total – int, the total number of items to be processed.
ncols – int, ... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.progress.ProgressBarCallback.html |
3a816d860b7a-1 | on_llm_error(error, *, run_id[, parent_run_id])
Run when LLM errors. :param error: The error that occurred. :type error: BaseException :param kwargs: Additional keyword arguments. - response (LLMResult): The response which was generated before the error occurred. :type kwargs: Any.
on_llm_new_token(t... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.progress.ProgressBarCallback.html |
3a816d860b7a-2 | increment() → None[source]¶
Increment the counter and update the progress bar.
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)... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.progress.ProgressBarCallback.html |
3a816d860b7a-3 | Run when LLM ends running.
on_llm_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any[source]¶
Run when LLM errors.
:param error: The error that occurred.
:type error: BaseException
:param kwargs: Additional keyword arguments.
response (LLMResult): The response which ... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.progress.ProgressBarCallback.html |
3a816d860b7a-4 | Run when Retriever errors.
on_retriever_start(serialized: Dict[str, Any], query: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶
Run when Retriever starts running.
on_retry(retry_state: RetryCallState, *, run_... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.progress.ProgressBarCallback.html |
56a37716af9c-0 | langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper¶
class langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper[source]¶
Bases: StringRunMapper
Extract items to evaluate from the run object from a chain.
Create a new model by parsing and validating input data from keyword arguments.
Rai... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper.html |
56a37716af9c-1 | 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(*, i... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper.html |
56a37716af9c-2 | 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 lc_id() → List[str]¶
A unique identifier for this class for serialization purposes.
The unique identifier is a ... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper.html |
56a37716af9c-3 | For example,{“openai_api_key”: “OPENAI_API_KEY”}
property output_keys: List[str]¶
The keys to extract from the run. | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ChainStringRunMapper.html |
63a773e82213-0 | langchain.smith.evaluation.runner_utils.InputFormatError¶
class langchain.smith.evaluation.runner_utils.InputFormatError[source]¶
Raised when the input format is invalid. | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.InputFormatError.html |
352889ab2a65-0 | langchain.smith.evaluation.string_run_evaluator.ToolStringRunMapper¶
class langchain.smith.evaluation.string_run_evaluator.ToolStringRunMapper[source]¶
Bases: StringRunMapper
Map an input to the tool.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input dat... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ToolStringRunMapper.html |
352889ab2a65-1 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ToolStringRunMapper.html |
352889ab2a65-2 | The unique identifier is a list of strings that describes the path
to the object.
map(run: Run) → Dict[str, str][source]¶
Maps the Run to a dictionary.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.ToolStringRunMapper.html |
f081474b877f-0 | langchain.smith.evaluation.config.SingleKeyEvalConfig¶
class langchain.smith.evaluation.config.SingleKeyEvalConfig[source]¶
Bases: EvalConfig
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 evaluator_t... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.SingleKeyEvalConfig.html |
f081474b877f-1 | 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(*, i... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.SingleKeyEvalConfig.html |
f081474b877f-2 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.SingleKeyEvalConfig.html |
b592b871cf85-0 | langchain.smith.evaluation.string_run_evaluator.StringExampleMapper¶
class langchain.smith.evaluation.string_run_evaluator.StringExampleMapper[source]¶
Bases: Serializable
Map an example, or row in the dataset, to the inputs of an evaluation.
Create a new model by parsing and validating input data from keyword argument... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringExampleMapper.html |
b592b871cf85-1 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringExampleMapper.html |
b592b871cf85-2 | The unique identifier is a list of strings that describes the path
to the object.
map(example: Example) → Dict[str, str][source]¶
Maps the Example, or dataset row to a dictionary.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pi... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.string_run_evaluator.StringExampleMapper.html |
95558ddeb8ad-0 | langchain.smith.evaluation.runner_utils.run_on_dataset¶
langchain.smith.evaluation.runner_utils.run_on_dataset(client: Optional[Client], dataset_name: str, llm_or_chain_factory: Union[Callable[[], Union[Chain, Runnable]], BaseLanguageModel, Callable[[dict], Any], Runnable, Chain], *, evaluation: Optional[RunEvalConfig]... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.run_on_dataset.html |
95558ddeb8ad-1 | Examples
from langsmith import Client
from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain
from langchain.smith import smith_eval.RunEvalConfig, run_on_dataset
# Chains may have memory. Passing in a constructor function lets the
# evaluation framework avoid cross-contamination between runs... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.run_on_dataset.html |
95558ddeb8ad-2 | return {"score": prediction == reference}
evaluation_config = smith_eval.RunEvalConfig(
custom_evaluators = [MyStringEvaluator()],
)
run_on_dataset(
client,
"<my_dataset_name>",
construct_chain,
evaluation=evaluation_config,
)
Examples using run_on_dataset¶
LangSmith Walkthrough | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.run_on_dataset.html |
9786ad6bbd78-0 | langchain.smith.evaluation.runner_utils.EvalError¶
class langchain.smith.evaluation.runner_utils.EvalError(Error: BaseException, **kwargs: Any)[source]¶
Your architecture raised an error.
Methods
__init__(Error, **kwargs)
clear()
copy()
fromkeys([value])
Create a new dictionary with keys from iterable and values set to... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.EvalError.html |
9786ad6bbd78-1 | items() → a set-like object providing a view on D's items¶
keys() → a set-like object providing a view on D's keys¶
pop(k[, d]) → v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise,
raise a KeyError.
popitem()¶
Remove and return a (key, value) pa... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.runner_utils.EvalError.html |
fb03d5d36a87-0 | langchain.smith.evaluation.config.RunEvalConfig¶
class langchain.smith.evaluation.config.RunEvalConfig[source]¶
Bases: BaseModel
Configuration for a run evaluation.
Parameters
evaluators (List[Union[EvaluatorType, EvalConfig]]) – Configurations for which evaluators to apply to the dataset run.
Each can be the string of... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-1 | The language model to pass to any evaluators that require one.
param evaluators: List[Union[langchain.evaluation.schema.EvaluatorType, str, langchain.smith.evaluation.config.EvalConfig]] [Optional]¶
Configurations for which evaluators to apply to the dataset run.
Each can be the string of an
EvaluatorType, such
as Eval... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-2 | input. If not provided, it will be inferred automatically.
param llm: Optional[langchain_core.language_models.base.BaseLanguageModel] = None¶
param prediction_key: Optional[str] = None¶
The key from the traced run’s outputs dictionary to use to
represent the prediction. If not provided, it will be inferred
automaticall... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-3 | 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, ex... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-4 | 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¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmet... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-5 | param prompt: Optional[langchain_core.prompts.base.BasePromptTemplate] = None¶
param reference_key: Optional[str] = None¶
The key in the dataset run to use as the reference string.
If not provided, we will attempt to infer automatically.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-6 | Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
classmethod from_orm(obj: Any) → Model¶
get_kwargs() → Dict[str, Any]¶
Get the keyword arguments for the load_evaluator call.
Returns
The keyword arguments for the load_evaluator call.
Return type
Dict[str, Any]... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-7 | 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¶
class Criteria[source]¶
Bases: SingleKeyEvalConfig
Configuration for a reference-free criteria evaluator.
Parameters
criteria (Optional[CRITERI... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-8 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-9 | The keyword arguments for the load_evaluator call.
Return type
Dict[str, Any]
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, exc... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-10 | Bases: SingleKeyEvalConfig
Configuration for an embedding distance evaluator.
Parameters
embeddings (Optional[Embeddings]) – The embeddings to use for computing the distance.
distance_metric (Optional[EmbeddingDistanceEnum]) – The distance metric to use for computing the distance.
Create a new model by parsing and vali... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-11 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-12 | The keyword arguments for the load_evaluator call.
Return type
Dict[str, Any]
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, exc... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-13 | Bases: SingleKeyEvalConfig
Configuration for an exact match string evaluator.
Parameters
ignore_case (bool) – Whether to ignore case when comparing strings.
ignore_punctuation (bool) – Whether to ignore punctuation when comparing strings.
ignore_numbers (bool) – Whether to ignore numbers when comparing strings.
Create ... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-14 | 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 creat... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-15 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-16 | 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... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-17 | The keyword arguments for the load_evaluator call.
Return type
Dict[str, Any]
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, exc... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-18 | Bases: SingleKeyEvalConfig
Configuration for a json validity evaluator.
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 evaluator_type: langchain.evaluation.schema.EvaluatorType = EvaluatorType.JSON_VA... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-19 | 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[boo... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-20 | 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¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmet... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
fb03d5d36a87-21 | param prediction_key: Optional[str] = None¶
The key from the traced run’s outputs dictionary to use to
represent the prediction. If not provided, it will be inferred
automatically.
param reference_key: Optional[str] = None¶
The key in the dataset run to use as the reference string.
If not provided, we will attempt to i... | https://api.python.langchain.com/en/latest/smith/langchain.smith.evaluation.config.RunEvalConfig.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.