id stringlengths 14 15 | text stringlengths 13 2.7k | source stringlengths 60 181 |
|---|---|---|
79d00a26b31a-15 | Parameters
input – The input to the runnable.
config – A config to use when invoking the runnable.
The config supports standard keys like ‘tags’, ‘metadata’ for tracing
purposes, ‘max_concurrency’ for controlling how much work to do
in parallel, and other keys. Please refer to the RunnableConfig
for more details.
Retur... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
79d00a26b31a-16 | 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¶
prep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶
Validate and prepare chain inputs, including ad... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
79d00a26b31a-17 | sole positional argument.
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
additi... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
79d00a26b31a-18 | Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶
to_json_not_implemented() → SerializedNotImplemented¶
transform(input: Iterator[Input], config: Optional[RunnableConfig] = No... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
79d00a26b31a-19 | on_start: Called before the runnable starts running, with the Run object.
on_end: Called after the runnable finishes running, with the Run object.
on_error: Called if the runnable throws an error, with the Run object.
The Run object contains information about the run, including its id,
type, input, output, error, start... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
79d00a26b31a-20 | Input keys.
property input_schema: Type[pydantic.main.BaseModel]¶
The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.base.FallacyChain.html |
8b6e545272a5-0 | langchain_experimental.fallacy_removal.models.LogicalFallacy¶
class langchain_experimental.fallacy_removal.models.LogicalFallacy[source]¶
Bases: BaseModel
Class for a logical fallacy.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parse... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.models.LogicalFallacy.html |
8b6e545272a5-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/fallacy_removal/langchain_experimental.fallacy_removal.models.LogicalFallacy.html |
8b6e545272a5-2 | 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... | https://api.python.langchain.com/en/latest/fallacy_removal/langchain_experimental.fallacy_removal.models.LogicalFallacy.html |
970a347e477a-0 | langchain_core.prompts.string.get_template_variables¶
langchain_core.prompts.string.get_template_variables(template: str, template_format: str) → List[str][source]¶
Get the variables from the template.
Parameters
template – The template string.
template_format – The template format. Should be one of “f-string” or “jinj... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.string.get_template_variables.html |
f5dde7861bde-0 | langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate¶
class langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate[source]¶
Bases: BaseChatPromptTemplate, _FewShotPromptTemplateMixin
Chat prompt template that supports few-shot examples.
The high level structure of produced by this prompt template ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-1 | ]
)
final_prompt.format(input="What is 4+4?")
Prompt template with dynamically selected examples:
from langchain_core.prompts import SemanticSimilarityExampleSelector
from langchain_core.embeddings import OpenAIEmbeddings
from langchain_core.vectorstores import Chroma
examples = [
{"input": "2+2", "output": "4"},
... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-2 | + few_shot_prompt
+ HumanMessagePromptTemplate.from_template("{input}")
)
# Show the prompt
print(final_prompt.format_messages(input="What's 3+3?"))
# Use within an LLM
from langchain_core.chat_models import ChatAnthropic
chain = final_prompt | ChatAnthropic()
chain.invoke({"input": "What's 3+3?"})
Create a new mod... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-3 | Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
async ainvoke(input: Input, co... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-4 | step, and the final state of the run.
The jsonpatch ops can be applied in order to construct state.
Parameters
input – The input to the runnable.
config – The config to use for the runnable.
diff – Whether to yield diffs between each step, or the current state.
with_streamed_output_list – Whether to yield the streamed_... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-5 | To mark a field as configurable, see the configurable_fields
and configurable_alternatives methods.
Parameters
include – A list of fields to include in the config schema.
Returns
A pydantic model that can be used to validate config.
configurable_alternatives(which: ConfigurableField, *, default_key: str = 'default', pr... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-6 | dict(**kwargs: Any) → Dict¶
Return dictionary representation of prompt.
format(**kwargs: Any) → str[source]¶
Format the prompt with inputs generating a string.
Use this method to generate a string representation of a prompt consisting
of chat messages.
Useful for feeding into a string based completion language model or... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-7 | Runnables that leverage the configurable_fields and configurable_alternatives
methods will have a dynamic output schema that depends on which
configuration the runnable is invoked with.
This method allows to get an output schema for a specific configuration.
Parameters
config – A config to use when generating the schem... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-8 | The unique identifier is a list of strings that describes the path
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, encod... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-9 | to_json_not_implemented() → SerializedNotImplemented¶
transform(input: Iterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶
Default implementation of transform, which buffers input and then calls stream.
Subclasses should override this method if they can start producing... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-10 | The Run object contains information about the run, including its id,
type, input, output, error, start_time, end_time, and any tags or metadata
added to the run.
with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_af... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
f5dde7861bde-11 | 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.
Examples using FewShotChatMessagePromptTemplate¶
Few-shot examples for chat models | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotChatMessagePromptTemplate.html |
2d5e0bec5f77-0 | langchain_core.prompts.chat.HumanMessagePromptTemplate¶
class langchain_core.prompts.chat.HumanMessagePromptTemplate[source]¶
Bases: BaseStringMessagePromptTemplate
Human message prompt template. This is a message sent from the user.
Create a new model by parsing and validating input data from keyword arguments.
Raises... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.HumanMessagePromptTemplate.html |
2d5e0bec5f77-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/prompts/langchain_core.prompts.chat.HumanMessagePromptTemplate.html |
2d5e0bec5f77-2 | Returns
A new instance of this class.
classmethod from_template_file(template_file: Union[str, Path], input_variables: List[str], **kwargs: Any) → MessagePromptTemplateT¶
Create a class from a template file.
Parameters
template_file – path to a template file. String or Path.
input_variables – list of input variables.
*... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.HumanMessagePromptTemplate.html |
2d5e0bec5f77-3 | 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/prompts/langchain_core.prompts.chat.HumanMessagePromptTemplate.html |
eaa73cf9643c-0 | langchain_core.prompts.few_shot.FewShotPromptTemplate¶
class langchain_core.prompts.few_shot.FewShotPromptTemplate[source]¶
Bases: _FewShotPromptTemplateMixin, StringPromptTemplate
Prompt template that contains few shot examples.
Create a new model by parsing and validating input data from keyword arguments.
Raises Val... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-1 | The format of the prompt template. Options are: ‘f-string’, ‘jinja2’.
param validate_template: bool = False¶
Whether or not to try validating the template.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any])... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-2 | 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/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-3 | 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/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-4 | 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/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-5 | Parameters
config – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate input.
classmethod get_lc_namespace() → List[str]¶
Get the namespace of the langchain object.
get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model that can ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-6 | Return whether or not the class is 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_defaults: bool = False, ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-7 | Save the prompt.
Parameters
file_path – Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=”path/prompt.yaml”)
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-8 | Add fallbacks to a runnable, returning a new Runnable.
Parameters
fallbacks – A sequence of runnables to try if the original runnable fails.
exceptions_to_handle – A tuple of exception types to handle.
Returns
A new Runnable that will try the original runnable, and then each
fallback in order, upon failures.
with_liste... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
eaa73cf9643c-9 | Bind input and output types to a Runnable, returning a new Runnable.
property InputType: Type[langchain_core.runnables.utils.Input]¶
The type of input this runnable accepts specified as a type annotation.
property OutputType: Any¶
The type of output this runnable produces specified as a type annotation.
property config... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot.FewShotPromptTemplate.html |
420f861772b3-0 | langchain_core.prompts.string.check_valid_template¶
langchain_core.prompts.string.check_valid_template(template: str, template_format: str, input_variables: List[str]) → None[source]¶
Check that template string is valid.
Parameters
template – The template string.
template_format – The template format. Should be one of ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.string.check_valid_template.html |
5b23a0583029-0 | langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector¶
class langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector[source]¶
Bases: BaseExampleSelector, BaseModel
Select and order examples based on ngram overlap score (sentence_bleu score).
https://www.nltk.org/_modules/nltk... | https://api.python.langchain.com/en/latest/prompts/langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector.html |
5b23a0583029-1 | 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/prompts/langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector.html |
5b23a0583029-2 | 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_n... | https://api.python.langchain.com/en/latest/prompts/langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector.html |
5b23a0583029-3 | 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¶
Examples using NGramOverlapExampleSelector¶
Select by n-gram overlap | https://api.python.langchain.com/en/latest/prompts/langchain.prompts.example_selector.ngram_overlap.NGramOverlapExampleSelector.html |
efef5fd5360a-0 | langchain.prompts.example_selector.ngram_overlap.ngram_overlap_score¶
langchain.prompts.example_selector.ngram_overlap.ngram_overlap_score(source: List[str], example: List[str]) → float[source]¶
Compute ngram overlap score of source and example as sentence_bleu score.
Use sentence_bleu with method1 smoothing function a... | https://api.python.langchain.com/en/latest/prompts/langchain.prompts.example_selector.ngram_overlap.ngram_overlap_score.html |
2ce459c1062d-0 | langchain_core.prompts.chat.MessagesPlaceholder¶
class langchain_core.prompts.chat.MessagesPlaceholder[source]¶
Bases: BaseMessagePromptTemplate
Prompt template that assumes variable is already list of messages.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if th... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.MessagesPlaceholder.html |
2ce459c1062d-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/prompts/langchain_core.prompts.chat.MessagesPlaceholder.html |
2ce459c1062d-2 | A unique identifier for this class for serialization purposes.
The unique identifier is a list of strings that describes the path
to the object.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classm... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.MessagesPlaceholder.html |
2ce459c1062d-3 | Agents
Memory in LLMChain
Add Memory to OpenAI Functions Agent
Types of `MessagePromptTemplate`
Adding memory | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.MessagesPlaceholder.html |
c83f1f566386-0 | langchain_core.prompts.chat.ChatPromptTemplate¶
class langchain_core.prompts.chat.ChatPromptTemplate[source]¶
Bases: BaseChatPromptTemplate
A prompt template for chat models.
Use to create flexible templated prompts for chat models.
Examples
from langchain_core.prompts import ChatPromptTemplate
template = ChatPromptTem... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-1 | Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
async ainvoke(input: Input, co... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-2 | Stream all output from a runnable, as reported to the callback system.
This includes all inner runs of LLMs, Retrievers, Tools, etc.
Output is streamed as Log objects, which include a list of
jsonpatch ops that describe how the state of the run has changed in each
step, and the final state of the run.
The jsonpatch ops... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-3 | bind(**kwargs: Any) → Runnable[Input, Output]¶
Bind arguments to a Runnable, returning a new Runnable.
config_schema(*, include: Optional[Sequence[str]] = None) → Type[BaseModel]¶
The type of config this runnable accepts specified as a pydantic model.
To mark a field as configurable, see the configurable_fields
and con... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-4 | 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(**kw... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-5 | ("ai", "I'm doing well, thanks!"),
("human", "That's good to hear."),
])
Instantiation from mixed message formats:
template = ChatPromptTemplate.from_messages([
SystemMessage(content="hello"),
("human", "Hello, how are you?"),
])
Parameters
messages – sequence of message representations.
A message can be re... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-6 | string_messages – list of (role class, template) tuples.
Returns
a chat prompt template[Deprecated] Create a chat prompt template from a list of (role class, template) tuples.
Returns
a chat prompt template
Notes
Deprecated since version 0.0.260: Use from_messages classmethod instead.
classmethod from_template(template... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-7 | Parameters
config – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate output.
invoke(input: Dict, config: Optional[RunnableConfig] = None) → PromptValue¶
Transform a single input into an output. Override to implement.
Parameters
input – The input to the runnable.
config –... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-8 | 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 = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = No... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-9 | stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶
to_json_not_implem... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-10 | Bind lifecycle listeners to a Runnable, returning a new Runnable.
on_start: Called before the runnable starts running, with the Run object.
on_end: Called after the runnable finishes running, with the Run object.
on_error: Called if the runnable throws an error, with the Run object.
The Run object contains information ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
c83f1f566386-11 | The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
Return a list of attribute names that should be included in the
serialized kwargs. These attributes must be accepted by the
constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.ChatPromptTemplate.html |
9f13bda2350d-0 | langchain_core.prompts.prompt.PromptTemplate¶
class langchain_core.prompts.prompt.PromptTemplate[source]¶
Bases: StringPromptTemplate
A prompt template for a language model.
A prompt template consists of a string template. It accepts a set of parameters
from the user that can be used to generate a prompt for a language... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-1 | A list of the names of the variables the prompt template expects.
param output_parser: Optional[BaseOutputParser] = None¶
How to parse the output of calling an LLM on this formatted prompt.
param partial_variables: Mapping[str, Union[str, Callable[[], str]]] [Optional]¶
param template: str [Required]¶
The prompt templa... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-2 | 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/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-3 | 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/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-4 | 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/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-5 | set up the user’s input.
input_variables – A list of variable names the final prompt template
will expect.
example_separator – The separator to use in between examples. Defaults
to two new line characters.
prefix – String that should go before any examples. Generally includes
examples. Default to an empty string.
Retur... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-6 | from untrusted sources.
Parameters
template – The template to load.
template_format – The format of the template. Use jinja2 for jinja2,
and f-string or None for f-strings.
partial_variables –
A dictionary of variables that can be used to partiallyfill in the template. For example, if the template is
”{variable1} {var... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-7 | invoke(input: Dict, config: Optional[RunnableConfig] = None) → PromptValue¶
Transform a single input into an output. Override to implement.
Parameters
input – The input to the runnable.
config – A config to use when invoking the runnable.
The config supports standard keys like ‘tags’, ‘metadata’ for tracing
purposes, ‘... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-8 | 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 = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = No... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-9 | input is still being generated.
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¶
with_config(config: Optional[RunnableConfig] = None, **kwargs: Any) → Runnable[Input, Output]¶
Bind config to a... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-10 | 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/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
9f13bda2350d-11 | property output_schema: Type[pydantic.main.BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
Examples using PromptTemplate¶
RePhraseQueryRetriever
Zapier Natural Language Actions
Dall-E Image Generator
Streamlit Chat Message History
Context
Argilla
Comet
Aim
Weights & Biases
SageMaker... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html |
ae97b4c3a013-0 | langchain_experimental.prompts.load.load_prompt¶
langchain_experimental.prompts.load.load_prompt(path: Union[str, Path]) → BasePromptTemplate[source]¶
Unified method for loading a prompt from LangChainHub or local fs.
Examples using load_prompt¶
Amazon Comprehend Moderation Chain
Serialization | https://api.python.langchain.com/en/latest/prompts/langchain_experimental.prompts.load.load_prompt.html |
8d7e1337ff72-0 | langchain_core.prompts.chat.AIMessagePromptTemplate¶
class langchain_core.prompts.chat.AIMessagePromptTemplate[source]¶
Bases: BaseStringMessagePromptTemplate
AI message prompt template. This is a message sent from the AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises Validation... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.AIMessagePromptTemplate.html |
8d7e1337ff72-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/prompts/langchain_core.prompts.chat.AIMessagePromptTemplate.html |
8d7e1337ff72-2 | Returns
A new instance of this class.
classmethod from_template_file(template_file: Union[str, Path], input_variables: List[str], **kwargs: Any) → MessagePromptTemplateT¶
Create a class from a template file.
Parameters
template_file – path to a template file. String or Path.
input_variables – list of input variables.
*... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.AIMessagePromptTemplate.html |
8d7e1337ff72-3 | 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/prompts/langchain_core.prompts.chat.AIMessagePromptTemplate.html |
03c729199881-0 | langchain_core.prompts.chat.BaseMessagePromptTemplate¶
class langchain_core.prompts.chat.BaseMessagePromptTemplate[source]¶
Bases: Serializable, ABC
Base class for message prompt templates.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.BaseMessagePromptTemplate.html |
03c729199881-1 | Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
abstract format_messages(**kwargs: Any) → List[BaseMessage][source]¶
Format messages from kwargs. Should return a list of BaseMessages.
Parameters
**kwargs – Keyword arguments to use for formatting.
Returns
List... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.BaseMessagePromptTemplate.html |
03c729199881-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/prompts/langchain_core.prompts.chat.BaseMessagePromptTemplate.html |
83404df6e448-0 | langchain_core.prompts.loading.load_prompt¶
langchain_core.prompts.loading.load_prompt(path: Union[str, Path]) → BasePromptTemplate[source]¶
Unified method for loading a prompt from LangChainHub or local fs.
Examples using load_prompt¶
Amazon Comprehend Moderation Chain
Serialization | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.loading.load_prompt.html |
8f6c2c507615-0 | langchain_core.prompts.chat.SystemMessagePromptTemplate¶
class langchain_core.prompts.chat.SystemMessagePromptTemplate[source]¶
Bases: BaseStringMessagePromptTemplate
System message prompt template.
This is a message that is not sent to the user.
Create a new model by parsing and validating input data from keyword argu... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.SystemMessagePromptTemplate.html |
8f6c2c507615-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/prompts/langchain_core.prompts.chat.SystemMessagePromptTemplate.html |
8f6c2c507615-2 | Returns
A new instance of this class.
classmethod from_template_file(template_file: Union[str, Path], input_variables: List[str], **kwargs: Any) → MessagePromptTemplateT¶
Create a class from a template file.
Parameters
template_file – path to a template file. String or Path.
input_variables – list of input variables.
*... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.SystemMessagePromptTemplate.html |
8f6c2c507615-3 | 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/prompts/langchain_core.prompts.chat.SystemMessagePromptTemplate.html |
f19a85d0faa8-0 | langchain_core.prompts.loading.load_prompt_from_config¶
langchain_core.prompts.loading.load_prompt_from_config(config: dict) → BasePromptTemplate[source]¶
Load prompt from Config Dict. | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.loading.load_prompt_from_config.html |
d3580eb568c3-0 | langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates¶
class langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates[source]¶
Bases: StringPromptTemplate
Prompt template that contains few shot examples.
Create a new model by parsing and validating input data from keyword arguments.... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-1 | param template_format: str = 'f-string'¶
The format of the prompt template. Options are: ‘f-string’, ‘jinja2’.
param validate_template: bool = False¶
Whether or not to try validating the template.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exception... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-2 | 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/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-3 | 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/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-4 | 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/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-5 | Parameters
config – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate input.
classmethod get_lc_namespace() → List[str][source]¶
Get the namespace of the langchain object.
get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model t... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-6 | classmethod is_lc_serializable() → bool¶
Return whether this class is 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 = Fals... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-7 | Save the prompt.
Parameters
file_path – Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=”path/prompt.yaml”)
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: ... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-8 | Add fallbacks to a runnable, returning a new Runnable.
Parameters
fallbacks – A sequence of runnables to try if the original runnable fails.
exceptions_to_handle – A tuple of exception types to handle.
Returns
A new Runnable that will try the original runnable, and then each
fallback in order, upon failures.
with_liste... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
d3580eb568c3-9 | Bind input and output types to a Runnable, returning a new Runnable.
property InputType: Type[langchain_core.runnables.utils.Input]¶
The type of input this runnable accepts specified as a type annotation.
property OutputType: Any¶
The type of output this runnable produces specified as a type annotation.
property config... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.few_shot_with_templates.FewShotPromptWithTemplates.html |
67364f770f05-0 | langchain_core.prompts.chat.BaseStringMessagePromptTemplate¶
class langchain_core.prompts.chat.BaseStringMessagePromptTemplate[source]¶
Bases: BaseMessagePromptTemplate, ABC
Base class for message prompt templates that use a string prompt template.
Create a new model by parsing and validating input data from keyword ar... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.BaseStringMessagePromptTemplate.html |
67364f770f05-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/prompts/langchain_core.prompts.chat.BaseStringMessagePromptTemplate.html |
67364f770f05-2 | Returns
A new instance of this class.
classmethod from_template_file(template_file: Union[str, Path], input_variables: List[str], **kwargs: Any) → MessagePromptTemplateT[source]¶
Create a class from a template file.
Parameters
template_file – path to a template file. String or Path.
input_variables – list of input vari... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.chat.BaseStringMessagePromptTemplate.html |
67364f770f05-3 | 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/prompts/langchain_core.prompts.chat.BaseStringMessagePromptTemplate.html |
d3e1a633094e-0 | langchain_core.prompts.base.format_document¶
langchain_core.prompts.base.format_document(doc: Document, prompt: BasePromptTemplate) → str[source]¶
Format a document into a string based on a prompt template.
First, this pulls information from the document from two sources:
page_content:This takes the information from th... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.base.format_document.html |
d734e11ed1a0-0 | langchain_core.prompts.pipeline.PipelinePromptTemplate¶
class langchain_core.prompts.pipeline.PipelinePromptTemplate[source]¶
Bases: BasePromptTemplate
A prompt template for composing multiple prompt templates together.
This can be useful when you want to reuse parts of prompts.
A PipelinePrompt consists of two main pa... | https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.pipeline.PipelinePromptTemplate.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.