id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
45b46cec0462-229
Tags to add to the run trace. attribute temperature: float = 0.7 What sampling temperature to use attribute tokenizer: Any = None The tokenizer to use for the API calls. attribute top_k: Optional[int] = None The number of highest probability vocabulary tokens to keep for top-k-filtering. attribute top_p: float = 0.9...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-230
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-231
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-232
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-233
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-234
attribute pipeline_key: str = '' The id or tag of the target pipeline attribute pipeline_kwargs: Dict[str, Any] [Optional] Holds any pipeline parameters valid for create call not explicitly specified. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute verbose: bool [Optional] Whether...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-235
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-236
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-237
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-238
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-239
tags (Optional[List[str]]) – client (Any) – model (Optional[str]) – output (Optional[Dict[str, Any]]) – max_tokens (int) – temperature (float) – token (Optional[str]) – stop (Optional[List[str]]) – Return type None attribute max_tokens: int = 256 Denotes the number of tokens to predict per generation. attribut...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-240
tags (Optional[List[str]]) – kwargs (Any) – Return type langchain.schema.LLMResult 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...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-241
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-242
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-243
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-244
Bases: langchain.llms.openai.OpenAI Wrapper around OpenAI large language models. To use, you should have the openai and promptlayer python package installed, and the environment variable OPENAI_API_KEY and PROMPTLAYER_API_KEY set with your openAI API key and promptlayer key respectively. All parameters that can be pass...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-245
max_retries (int) – streaming (bool) – allowed_special (Union[Literal['all'], typing.AbstractSet[str]]) – disallowed_special (Union[Literal['all'], typing.Collection[str]]) – tiktoken_model_name (Optional[str]) – Return type None Example from langchain.llms import PromptLayerOpenAI openai = PromptLayerOpenAI(model...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-246
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-247
self (Model) – Returns new model instance Return type Model create_llm_result(choices, prompts, token_usage) Create the LLMResult from the choices and prompts. Parameters choices (Any) – prompts (List[str]) – token_usage (Dict[str, int]) – Return type langchain.schema.LLMResult dict(**kwargs) Return a dictionary ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-248
Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_sub_prompts(params, prompts, stop=None) Get the sub prompts for llm call. Parameters params (Dict[str, Any]) – prompts (List[str]) – stop (Optional[List[str]]) – Return type List[List[str]] get_token_ids(text) Get the token IDs using t...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-249
int Example max_tokens = openai.max_token_for_prompt("Tell me a joke.") static modelname_to_contextsize(modelname) Calculate the maximum number of tokens possible to generate for a model. Parameters modelname (str) – The modelname we want to know the context size for. Returns The maximum context size Return type int E...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-250
stop (Optional[List[str]]) – Optional list of stop words to use when generating. Returns A generator representing the stream of tokens from OpenAI. Return type Generator Example generator = openai.stream("Tell me a joke.") for token in generator: yield token classmethod update_forward_refs(**localns) Try to update...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-251
To use, you should have the openai and promptlayer python package installed, and the environment variable OPENAI_API_KEY and PROMPTLAYER_API_KEY set with your openAI API key and promptlayer key respectively. All parameters that can be passed to the OpenAIChat LLM can also be passed here. The PromptLayerOpenAIChat adds ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-252
Set of special tokens that are allowed。 attribute disallowed_special: Union[Literal['all'], Collection[str]] = 'all' Set of special tokens that are not allowed。 attribute max_retries: int = 6 Maximum number of retries to make when generating. attribute model_kwargs: Dict[str, Any] [Optional] Holds any model paramete...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-253
Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type langchain.schema.LLMResult async apredict(text, *, stop=None, **kwargs) P...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-254
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) Return a dictionary of the LLM. Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwarg...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-255
Parameters text (str) – Return type List[int] 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 di...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-256
.. 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. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be included in the...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-257
# Simplest invocation response = model("Once upon a time, ") 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]) –...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-258
attribute strategy: str = 'cpu fp32' Token context window. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute temperature: float = 1.0 The temperature to use for sampling. attribute tokens_path: str [Required] Path to the RWKV tokens file. attribute top_p: float = 0.5 The top-p valu...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-259
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-260
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-261
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-262
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-263
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – model (str) – input (Dict[str, Any]) – model_kwargs (Dict[str, Any]) – replicate_api_token (Optional[str]) – Return type None attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-264
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-265
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-266
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-267
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-268
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – endpoint_name (str) – region_name (str) – credentials_profile_name (Optional[str]) – content_handler (langchain.llms.sagemaker_endpoint.LLMContentHandler) – model_kwargs (Optional[Dict]) – end...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-269
attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute verbose: bool [Optional] Whether to print out response text. __call__(prompt, stop=None, callbacks=None, **kwargs) Check Cache and run the LLM on the given prompt and input. Parameters prompt (str) – stop (Optional[List[str]]) – cal...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-270
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) – Return type langchain.schema.BaseMessage classmethod construct(_fields_set=None, **value...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-271
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.BaseCallbackManager]]) – tags (Optional[List[str]]) – kwargs (Any) – Return type langchain.schema.LLMResult...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-272
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/llms.html
45b46cec0462-273
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 Return whether or not the class is s...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-274
model_id="google/flan-t5-large", task="text2text-generation", hardware=gpu ) Example passing fn that generates a pipeline (bc the pipeline is not serializable):from langchain.llms import SelfHostedHuggingFaceLLM from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline import runhouse as rh def get_pip...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-275
attribute hardware: Any = None Remote hardware to send the inference function to. attribute inference_fn: Callable = <function _generate_text> Inference function to send to the remote hardware. attribute load_fn_kwargs: Optional[dict] = None Key word arguments to pass to the model load function. attribute model_id: ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-276
Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – tags (Optional[List[str]]) – kwargs (Any) – Return type langchain.schema.LLMResult async agenerate_prompt(prompts, stop=None,...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-277
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/llms.html
45b46cec0462-278
kwargs (Any) – Return type langchain.schema.LLMResult generate_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....
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-279
exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode predict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str predi...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-280
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.SelfHostedPipeline(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, pipeline_ref=None, client=None, inference_fn=<function _generate_text>, hardware=None, model_load_fn, load_fn_kwargs=Non...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-281
import runhouse as rh gpu = rh.cluster(name="rh-a10x", instance_type="A100:1") my_model = ... llm = SelfHostedPipeline.from_pipeline( pipeline=my_model, hardware=gpu, model_reqs=["./", "torch", "transformers"], ) Example passing model path for larger models:from langchain.llms import SelfHostedPipeline impo...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-282
Key word arguments to pass to the model load function. attribute model_load_fn: Callable [Required] Function to load the model remotely on the server. attribute model_reqs: List[str] = ['./', 'torch'] Requirements to install on hardware to inference the model. attribute tags: Optional[List[str]] = None Tags to add t...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-283
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-284
Returns new model instance Return type Model dict(**kwargs) Return a dictionary of the LLM. Parameters kwargs (Any) – Return type Dict classmethod from_pipeline(pipeline, hardware, model_reqs=None, device=0, **kwargs)[source] Init the SelfHostedPipeline from a pipeline object or string. Parameters pipeline (Any) – ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-285
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-286
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-287
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]]) – api_url (str) – model_kwargs...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-288
kwargs (Any) – Return type langchain.schema.LLMResult 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.callback...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-289
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-290
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-291
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-292
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 (_LanguageModel) – mo...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-293
Sampling temperature, it controls the degree of randomness in token selection. attribute top_k: int = 40 How the model selects tokens for output, the next token is selected from attribute top_p: float = 0.95 Tokens are selected from most probable to least until the sum of their attribute tuned_model_name: Optional[st...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-294
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-295
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-296
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-297
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-298
max_tokens (Optional[int]) – temperature (Optional[float]) – top_p (Optional[float]) – stop (Optional[List[str]]) – presence_penalty (Optional[float]) – repetition_penalty (Optional[float]) – best_of (Optional[int]) – logprobs (bool) – n (Optional[int]) – writer_api_key (Optional[str]) – base_url (Optional[st...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-299
attribute verbose: bool [Optional] Whether to print out response text. attribute writer_api_key: Optional[str] = None Writer API key. attribute writer_org_id: Optional[str] = None Writer organization ID. __call__(prompt, stop=None, callbacks=None, **kwargs) Check Cache and run the LLM on the given prompt and input....
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-300
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) – Return type langchain.schema.BaseMessage classmethod c...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-301
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.base.BaseCallbackManager]]) – tags (Optional...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-302
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/llms.html
45b46cec0462-303
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 Return whether or not the class is s...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-304
) 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]]) – endpoint_url (Optional[str]...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-305
tags (Optional[List[str]]) – kwargs (Any) – Return type langchain.schema.LLMResult 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...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-306
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-307
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-308
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
06ea1ea7a2ba-0
Retrievers class langchain.retrievers.AmazonKendraRetriever(index_id, region_name=None, credentials_profile_name=None, top_k=3, attribute_filter=None, client=None)[source] Bases: langchain.schema.BaseRetriever Retriever class to query documents from Amazon Kendra Index. Parameters index_id (str) – Kendra index id reg...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-1
Parameters query (str) – string to find relevant documents for Returns List of relevant documents Return type List[langchain.schema.Document] class langchain.retrievers.ArxivRetriever(*, arxiv_search=None, arxiv_exceptions=None, top_k_results=3, load_max_docs=100, load_all_available_meta=False, doc_content_chars_max=40...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-2
Bases: langchain.schema.BaseRetriever, pydantic.main.BaseModel Wrapper around Azure Cognitive Search. Parameters service_name (str) – index_name (str) – api_key (str) – api_version (str) – aiosession (Optional[aiohttp.client.ClientSession]) – content_key (str) – Return type None attribute aiosession: Optional[aio...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-3
Bases: langchain.schema.BaseRetriever, pydantic.main.BaseModel Parameters url (str) – bearer_token (str) – top_k (int) – filter (Optional[dict]) – aiosession (Optional[aiohttp.client.ClientSession]) – Return type None attribute aiosession: Optional[aiohttp.client.ClientSession] = None attribute bearer_token: str ...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-4
attribute base_retriever: langchain.schema.BaseRetriever [Required] Base Retriever to use for getting relevant documents. async aget_relevant_documents(query)[source] Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant documents Return type List[...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-5
Wrapper around Elasticsearch using BM25 as a retrieval method. To connect to an Elasticsearch instance that requires login credentials, including Elastic Cloud, use the Elasticsearch URL format https://username:password@es_host:9243. For example, to connect to Elastic Cloud, create the Elasticsearch URL with the requir...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-6
refresh_indices (bool) – bool to refresh ElasticSearch indices Returns List of ids from adding the texts into the retriever. Return type List[str] get_relevant_documents(query)[source] Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant documents ...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-7
Parameters texts (List[str]) – embeddings (langchain.embeddings.base.Embeddings) – kwargs (Any) – Return type langchain.retrievers.knn.KNNRetriever get_relevant_documents(query)[source] Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant docume...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-8
Return type None attribute index: Any = None attribute query_kwargs: Dict [Optional] async aget_relevant_documents(query)[source] 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] get_relev...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-9
Returns A list of merged documents. Return type List[langchain.schema.Document] class langchain.retrievers.MetalRetriever(client, params=None)[source] Bases: langchain.schema.BaseRetriever Retriever that uses the Metal API. Parameters client (Any) – params (Optional[dict]) – get_relevant_documents(query)[source] Ge...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-10
Parameters query (str) – string to find relevant documents for Returns List of relevant documents Return type List[langchain.schema.Document] async aget_relevant_documents(query)[source] Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant document...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-11
retriever (langchain.schema.BaseRetriever) – retriever to query documents from llm (langchain.llms.base.BaseLLM) – llm for query generation using DEFAULT_QUERY_PROMPT prompt (langchain.prompts.prompt.PromptTemplate) – parser_key (str) – Returns MultiQueryRetriever Return type langchain.retrievers.multi_query.MultiQue...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-12
Bases: langchain.schema.BaseRetriever, pydantic.main.BaseModel Parameters embeddings (langchain.embeddings.base.Embeddings) – sparse_encoder (Any) – index (Any) – top_k (int) – alpha (float) – Return type None attribute alpha: float = 0.5 attribute embeddings: langchain.embeddings.base.Embeddings [Required] attr...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-13
Returns List of relevant documents Return type List[langchain.schema.Document] class langchain.retrievers.PubMedRetriever(*, top_k_results=3, load_max_docs=25, doc_content_chars_max=2000, load_all_available_meta=False, email='your_email@example.com', base_url_esearch='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esear...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-14
Returns List of relevant documents Return type List[langchain.schema.Document] class langchain.retrievers.RemoteLangChainRetriever(*, url, headers=None, input_key='message', response_key='response', page_content_key='page_content', metadata_key='metadata')[source] Bases: langchain.schema.BaseRetriever, pydantic.main.B...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-15
index (Any) – texts (List[str]) – k (int) – relevancy_threshold (Optional[float]) – Return type None attribute embeddings: langchain.embeddings.base.Embeddings [Required] attribute index: Any = None attribute k: int = 4 attribute relevancy_threshold: Optional[float] = None attribute texts: List[str] [Required]...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-16
search_type (str) – search_kwargs (dict) – structured_query_translator (langchain.chains.query_constructor.ir.Visitor) – verbose (bool) – use_original_query (bool) – Return type None attribute llm_chain: langchain.chains.llm.LLMChain [Required] The LLMChain for generating the vector store queries. attribute searc...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-17
metadata_field_info (List[langchain.chains.query_constructor.schema.AttributeInfo]) – structured_query_translator (Optional[langchain.chains.query_constructor.ir.Visitor]) – chain_kwargs (Optional[Dict]) – enable_limit (bool) – use_original_query (bool) – kwargs (Any) – Return type langchain.retrievers.self_query...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-18
Parameters documents (Iterable[langchain.schema.Document]) – tfidf_params (Optional[Dict[str, Any]]) – kwargs (Any) – Return type langchain.retrievers.tfidf.TFIDFRetriever classmethod from_texts(texts, metadatas=None, tfidf_params=None, **kwargs)[source] Parameters texts (Iterable[str]) – metadatas (Optional[Itera...
https://api.python.langchain.com/en/latest/modules/retrievers.html
06ea1ea7a2ba-19
attribute default_salience: Optional[float] = None The salience to assign memories not retrieved from the vector store. None assigns no salience to documents not fetched from the vector store. attribute k: int = 4 The maximum number of documents to retrieve in a given call. attribute memory_stream: List[langchain.sch...
https://api.python.langchain.com/en/latest/modules/retrievers.html