id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
81099a94f427-227
for the full catalog. attribute 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. You can use these to eg identify a specific instance of a chain wi...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-228
kwargs (Any) – Return type Tuple[str, dict] apply(input_list, callbacks=None) Call the chain on all inputs in the list. Parameters input_list (List[Dict[str, Any]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – Return type List[Dict...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-229
return_only_outputs (bool) – Return type Dict[str, str] prompt_length(docs, **kwargs)[source] Get the prompt length by formatting the prompt. Parameters docs (List[langchain.schema.Document]) – kwargs (Any) – Return type Optional[int] run(*args, callbacks=None, tags=None, **kwargs) Run the chain as text in, text o...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-230
property lc_serializable: bool Return whether or not the class is serializable. class langchain.chains.MapRerankDocumentsChain(*, memory=None, callbacks=None, callback_manager=None, verbose=None, tags=None, input_key='input_documents', output_key='output_text', llm_chain, document_variable_name, rank_key, answer_key, ...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-231
Each custom chain can optionally call additional callback methods, see Callback docs for full details. attribute document_variable_name: str [Required] The variable name in the llm_chain to put the documents in. If only one variable in the llm_chain, this need not be provided. attribute llm_chain: LLMChain [Required]...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-232
only one param. return_only_outputs (bool) – boolean for 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 (Optional[Union[List[langchain.callbacks...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-233
tags (Optional[List[str]]) – kwargs (Any) – Return type str combine_docs(docs, callbacks=None, **kwargs)[source] Combine documents in a map rerank manner. Combine by mapping first chain over all documents, then reranking the results. Parameters docs (List[langchain.schema.Document]) – callbacks (Optional[Union[List...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-234
kwargs (Any) – Return type str save(file_path) Save the chain. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the chain to. Return type None Example: .. code-block:: python chain.save(file_path=”path/chain.yaml”) to_json() Return type Union[langchain.load.serializable.SerializedConstructor, l...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-235
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – verbose (bool) – tags (Optional[List[str]]) – input_key (str) – output_key (str) – llm_chain (langchain.chains.llm.LLMChain) – combine_document_chain (langchain.chains.combine_documents.base.BaseCombineDocumentsChain) – collapse_document...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-236
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 ca...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-237
include_run_info (bool) – Whether to include run info in the response. Defaults to False. tags (Optional[List[str]]) – Return type Dict[str, Any] async acombine_docs(docs, callbacks=None, **kwargs)[source] Combine documents in a map reduce manner. Combine by mapping first chain over all documents, then reducing the r...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-238
docs (List[langchain.schema.Document]) – token_max (int) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type Tuple[str, dict] dict(**kwargs) Return dictionary representation of chain. Parameters kwargs (Any) – ...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-239
Example: .. code-block:: python chain.save(file_path=”path/chain.yaml”) to_json() Return type Union[langchain.load.serializable.SerializedConstructor, langchain.load.serializable.SerializedNotImplemented] to_json_not_implemented() Return type langchain.load.serializable.SerializedNotImplemented property lc_attributes...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-240
input_key (str) – output_key (str) – initial_llm_chain (langchain.chains.llm.LLMChain) – refine_llm_chain (langchain.chains.llm.LLMChain) – document_variable_name (str) – initial_response_name (str) – document_prompt (langchain.prompts.base.BasePromptTemplate) – return_intermediate_steps (bool) – Return type No...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-241
There are many different types of memory - please see memory docs for the full catalog. attribute refine_llm_chain: LLMChain [Required] LLM chain to use when refining. attribute return_intermediate_steps: bool = False Return the results of the refine steps in the output. attribute tags: Optional[List[str]] = None Op...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-242
tags (Optional[List[str]]) – Return type Dict[str, Any] async acombine_docs(docs, callbacks=None, **kwargs)[source] Combine by mapping first chain over all, then stuffing into final chain. Parameters docs (List[langchain.schema.Document]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler]...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-243
Return type Dict prep_inputs(inputs) Validate and prep inputs. Parameters inputs (Union[Dict[str, Any], Any]) – Return type Dict[str, str] prep_outputs(inputs, outputs, return_only_outputs=False) Validate and prep outputs. Parameters inputs (Dict[str, str]) – outputs (Dict[str, str]) – return_only_outputs (bool) –...
https://api.python.langchain.com/en/latest/modules/chains.html
81099a94f427-244
serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_K...
https://api.python.langchain.com/en/latest/modules/chains.html
2dbde574187e-0
Base classes Common schema objects. langchain.schema.get_buffer_string(messages, human_prefix='Human', ai_prefix='AI')[source] Get buffer string of messages. Parameters messages (List[langchain.schema.BaseMessage]) – human_prefix (str) – ai_prefix (str) – Return type str class langchain.schema.AgentAction(tool, to...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-1
Default values are respected, but no other validation is performed. Behaves as if Config.extra = β€˜allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include=None, exclude=None, update=None, deep=False) Duplicate a model, optionally choo...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-2
exclude_none (bool) – Return type DictStrAny json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs) Generate a JSON representation of the model, include and exclude arguments as per dic...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-3
property lc_serializable: bool This class is LangChain serializable. class langchain.schema.BaseMessage(*, content, additional_kwargs=None)[source] Bases: langchain.load.serializable.Serializable Message object. Parameters content (str) – additional_kwargs (dict) – Return type None classmethod construct(_fields_set...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-4
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-5
constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool This class is LangChain...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-6
update (Optional[DictStrAny]) – 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 (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-7
models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be include...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-8
Model copy(*, include=None, exclude=None, update=None, deep=False) Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) ...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-9
Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-10
Return type None classmethod construct(_fields_set=None, **values) 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 Parameters _fie...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-11
exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs) Generate a JSON representation of the model, include and e...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-12
property lc_serializable: bool This class is LangChain serializable. property type: str Type of the message, used for serialization. class langchain.schema.FunctionMessage(*, content, additional_kwargs=None, name)[source] Bases: langchain.schema.BaseMessage Parameters content (str) – additional_kwargs (dict) – nam...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-13
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-14
constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool This class is LangChain...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-15
the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionar...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-16
Return type unicode classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be included in the serialized kwargs. These attributes mu...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-17
message (langchain.schema.BaseMessage) – Return type None attribute generation_info: Optional[Dict[str, Any]] = None Raw generation info response from the provider attribute text: str = '' Generated text output. classmethod construct(_fields_set=None, **values) Creates a new model setting __dict__ and __fields_set_...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-18
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny json(*, include=None, exclude=None, by...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-19
property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool This class is LangChain serializable...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-20
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-21
Parameters localns (Any) – Return type None class langchain.schema.ChatResult(*, generations, llm_output=None)[source] Bases: pydantic.main.BaseModel Class that contains all relevant information for a Chat Result. Parameters generations (List[langchain.schema.ChatGeneration]) – llm_output (Optional[dict]) – Return ...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-22
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-23
Parameters localns (Any) – Return type None class langchain.schema.LLMResult(*, generations, llm_output=None, run=None)[source] Bases: pydantic.main.BaseModel Class that contains all relevant information for an LLM Result. Parameters generations (List[List[langchain.schema.Generation]]) – llm_output (Optional[dict])...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-24
update (Optional[DictStrAny]) – 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 (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-25
exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters l...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-26
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-27
abstract to_string()[source] Return prompt as string. Return type str classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be inc...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-28
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes preced...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-29
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (b...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-30
property lc_serializable: bool Return whether or not the class is serializable. abstract property memory_variables: List[str] Input keys this memory class will load dynamically. class langchain.schema.BaseChatMessageHistory[source] Bases: abc.ABC Base interface for chat message history See ChatMessageHistory for def...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-31
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes preced...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-32
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (b...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-33
Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant documents Return type List[langchain.schema.Document] langchain.schema.Memory alias of langchain.schema.BaseMemory class langchain.schema.BaseLLMOutputParser[source] Bases: langchain.load.serial...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-34
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-35
Return type None 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_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets:...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-36
update (Optional[DictStrAny]) – 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 (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(**kwargs)[source] Return dictiona...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-37
Returns structured output Return type langchain.schema.T parse_result(result)[source] Parse LLM Result. Parameters result (List[langchain.schema.Generation]) – Return type langchain.schema.T parse_with_prompt(completion, prompt)[source] Optional method to parse the output of an LLM call with a prompt. The prompt is ...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-38
Return type None classmethod construct(_fields_set=None, **values) 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 Parameters _fie...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-39
Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-40
serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_K...
https://api.python.langchain.com/en/latest/modules/base_classes.html
2dbde574187e-41
Asynchronously transform a list of documents. Parameters documents (Sequence[langchain.schema.Document]) – kwargs (Any) – Return type Sequence[langchain.schema.Document]
https://api.python.langchain.com/en/latest/modules/base_classes.html
f09a5cce5e87-0
Chat Models class langchain.chat_models.ChatOpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='gpt-3.5-turbo', temperature=0.7, model_kwargs=None, openai_api_key=None, openai_api_base=None, openai_organization=None, openai_proxy=None, request_timeout=None, max_ret...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-1
max_retries (int) – streaming (bool) – n (int) – max_tokens (Optional[int]) – tiktoken_model_name (Optional[str]) – Return type None attribute max_retries: int = 6 Maximum number of retries to make when generating. attribute max_tokens: Optional[int] = None Maximum number of tokens to generate. attribute model_k...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-2
be the same as the embedding model name. However, there are some cases where you may want to use this Embedding class with a model name not supported by tiktoken. This can include when using Azure embeddings or when using one of the many model providers that expose an OpenAI-like API but with different models. In those...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-3
property lc_serializable: bool Return whether or not the class is serializable. class langchain.chat_models.AzureChatOpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='gpt-3.5-turbo', temperature=0.7, model_kwargs=None, openai_api_key='', openai_api_base='', opena...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-4
Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – model (str) –...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-5
Fake ChatModel for testing purposes. Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[st...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-6
Generation object. cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – model...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-7
Wrapper around Anthropic’s large language model. To use, you should have the anthropic python package installed, and the environment variable ANTHROPIC_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example import anthropic from langchain.llms import Anthropic model = ChatAnthropic(m...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-8
property lc_serializable: bool Return whether or not the class is serializable. class langchain.chat_models.ChatGooglePalm(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='models/chat-bison-001', google_api_key=None, temperature=None, top_p=None, top_k=None, n=1)[...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-9
not return the full n completions if duplicates are generated. attribute temperature: Optional[float] = None Run inference with this temperature. Must by in the closed interval [0.0, 1.0]. attribute top_k: Optional[int] = None Decode using top-k sampling: consider the set of top_k most probable tokens. Must be positi...
https://api.python.langchain.com/en/latest/modules/chat_models.html
f09a5cce5e87-10
location (str) – credentials (Any) – request_parallelism (int) – Return type None attribute model_name: str = 'chat-bison' Model name to use.
https://api.python.langchain.com/en/latest/modules/chat_models.html
45b46cec0462-0
LLMs Wrappers on top of large language models APIs. class langchain.llms.AI21(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model='j2-jumbo-instruct', temperature=0.7, maxTokens=256, minTokens=0, topP=1.0, presencePenalty=AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctua...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-1
maxTokens (int) – minTokens (int) – topP (float) – presencePenalty (langchain.llms.ai21.AI21PenaltyData) – countPenalty (langchain.llms.ai21.AI21PenaltyData) – frequencyPenalty (langchain.llms.ai21.AI21PenaltyData) – numResults (int) – logitBias (Optional[Dict[str, float]]) – ai21_api_key (Optional[str]) – sto...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-2
Model name to use. attribute numResults: int = 1 How many completions to generate for each prompt. attribute presencePenalty: langchain.llms.ai21.AI21PenaltyData = AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctuations=True, applyToNumbers=True, applyToStopwords=True, applyToEmojis=True) Penalizes repe...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-3
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs) Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.B...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-4
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – 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 (bool...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-5
Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_token_ids(text) Get the token present in the text. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-6
save(file_path) Save the LLM. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to. Return type None Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-7
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.AlephAlpha(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='luminous-base', maximum_tokens=64, temperature=0.0, top_k=0, top_p=0.0, presence_penalty=0.0, frequency_pena...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-8
Example from langchain.llms import AlephAlpha aleph_alpha = AlephAlpha(aleph_alpha_api_key="my-api-key") Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[lang...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-9
completion_bias_exclusion_first_token_only (bool) – contextual_control_threshold (Optional[float]) – control_log_additive (Optional[bool]) – repetition_penalties_include_completion (bool) – raw_completion (bool) – aleph_alpha_api_key (Optional[str]) – stop_sequences (Optional[List[str]]) – Return type None attri...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-10
The maximum number of tokens to be generated. attribute minimum_tokens: Optional[int] = 0 Generate at least this number of tokens. attribute model: Optional[str] = 'luminous-base' Model name to use. attribute n: int = 1 How many completions to generate for each prompt. attribute penalty_bias: Optional[str] = None P...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-11
Total probability mass of tokens to consider at each step. attribute use_multiplicative_presence_penalty: Optional[bool] = False Flag deciding whether presence penalty is applied multiplicatively (True) or additively (False). attribute verbose: bool [Optional] Whether to print out response text. __call__(prompt, stop...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-12
Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Retur...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-13
Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.b...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-14
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-15
Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor ar...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-16
output transform functions to handle formats between LLM and the endpoint. attribute model_kwargs: Optional[Dict] = None Key word arguments to pass to the model. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute verbose: bool [Optional] Whether to print out response text. __call__(pr...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-17
Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Retur...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-18
Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.b...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-19
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-20
Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor ar...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-21
# Or if you want to use the chat mode, build a few-shot-prompt, or # put words in the Assistant's mouth, use HUMAN_PROMPT and AI_PROMPT: raw_prompt = "What are the biggest risks facing humanity?" prompt = f"{anthropic.HUMAN_PROMPT} {prompt}{anthropic.AI_PROMPT}" response = model(prompt) Parameters client (Any) – model...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-22
Whether to stream the results. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute temperature: Optional[float] = None A non-negative float that tunes the degree of randomness in generation. attribute top_k: Optional[int] = None Number of most likely tokens to consider at each step. at...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-23
kwargs (Any) – Return type langchain.schema.LLMResult async apredict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters mes...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-24
Returns new model instance Return type Model dict(**kwargs) Return a dictionary of the LLM. Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callba...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-25
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-26
Parameters prompt (str) – The prompt to pass into the model. stop (Optional[List[str]]) – Optional list of stop words to use when generating. Returns A generator representing the stream of tokens from Anthropic. Return type Generator Example prompt = "Write a poem about a stream." prompt = f"\n\nHuman: {prompt}\n\nAssi...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-27
Service, or pass it as a named parameter to the constructor. Example from langchain.llms import Anyscale anyscale = Anyscale(anyscale_service_url="SERVICE_URL", anyscale_service_route="SERVICE_ROUTE", anyscale_service_token="SERVICE_TOKEN") # Use Ray for distributed processing im...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-28
kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.B...
https://api.python.langchain.com/en/latest/modules/llms.html