id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
45b46cec0462-129
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.GooseAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='gpt-neo-20b', temperature=0.7, max_tokens=256, top_p=1, min_tokens=1, frequency_penalty=0, presence_penalt...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-130
gooseai_api_key (Optional[str]) – Return type None attribute frequency_penalty: float = 0 Penalizes repeated tokens according to frequency. attribute logit_bias: Optional[Dict[str, float]] [Optional] Adjust the probability of specific tokens being generated. attribute max_tokens: int = 256 The maximum number of tok...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-131
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
45b46cec0462-132
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/llms.html
45b46cec0462-133
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.BaseCallbackManager]]) – kwargs (Any) – Return type langchain.schema....
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-134
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 predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schem...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-135
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.HuggingFaceEndpoint(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, endpoint_url='', task=None, model_kwargs=None, huggingfacehub_api_token=None)[source] Bases: langchain.llms.base.LLM W...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-136
Tags to add to the run trace. attribute task: Optional[str] = None Task to call the model with. Should be a task that returns generated_text or summary_text. 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...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-137
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) – Return type langchain.schema....
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-138
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-139
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-140
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-141
repo_id (str) – task (Optional[str]) – model_kwargs (Optional[dict]) – huggingfacehub_api_token (Optional[str]) – Return type None attribute model_kwargs: Optional[dict] = None Key word arguments to pass to the model. attribute repo_id: str = 'gpt2' Model name to use. attribute tags: Optional[List[str]] = None T...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-142
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.BaseCallbackManager]]) – kwargs (Any) – Return type langchain.schema....
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-143
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) Return a dictionary of ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-144
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_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs) Generate a JSON representati...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-145
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. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-146
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline model_id = "gpt2" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) pipe = pipeline( "text-generation", model=model, tokenizer=tokenizer, max_new_tokens=10 ) hf = HuggingFacePipeline(pipel...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-147
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
45b46cec0462-148
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/llms.html
45b46cec0462-149
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 generate_prompt(prompts, stop=None, callba...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-150
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-151
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-152
- timeout: The timeout value in seconds to use while connecting to inference server. - server_kwargs: The keyword arguments to pass to the inference server. - client: The client object used to communicate with the inference server. - async_client: The async client object used to communicate with the server. Methods: - ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-153
Parameters prompt (str) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-154
langchain.schema.BaseMessage 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 Par...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-155
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-156
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-157
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.HumanInputLLM(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, input_func=None, prompt_func=None, separator='\n', input_kwargs={}, prompt_kwargs={})[source] Bases: langchain.llms.base.LLM...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-158
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-159
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-160
kwargs (Any) – Return type langchain.schema.LLMResult get_num_tokens(text) Get the number of tokens present in the text. Parameters text (str) – Return type int get_num_tokens_from_messages(messages) Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-161
Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type langchain.schema.BaseMessage 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...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-162
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.LlamaCpp(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_path, lora_base=None, lora_path=None, n_ctx=512, n_parts=- 1, seed=- 1, f16_kv=True, logits_all=False, vocab_on...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-163
n_ctx (int) – n_parts (int) – seed (int) – f16_kv (bool) – logits_all (bool) – vocab_only (bool) – use_mlock (bool) – n_threads (Optional[int]) – n_batch (Optional[int]) – n_gpu_layers (Optional[int]) – suffix (Optional[str]) – max_tokens (Optional[int]) – temperature (Optional[float]) – top_p (Optional[fl...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-164
attribute max_tokens: Optional[int] = 256 The maximum number of tokens to generate. attribute model_path: str [Required] The path to the Llama model file. attribute n_batch: Optional[int] = 8 Number of tokens to process in parallel. Should be a number between 1 and n_ctx. attribute n_ctx: int = 512 Token context wi...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-165
The top-p value to use for sampling. attribute use_mlock: bool = False Force system to keep model in RAM. attribute use_mmap: Optional[bool] = True Whether to keep the model loaded in RAM attribute verbose: bool [Optional] Whether to print out response text. attribute vocab_only: bool = False Only load the vocabula...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-166
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-167
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-168
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-169
Once that happens, this interface could change. It also calls the callback manager’s on_llm_new_token event with similar parameters to the OpenAI LLM class method of the same name. Args:prompt: The prompts to pass into the model. stop: Optional list of stop words to use when generating. Returns:A generator representing...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-170
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 serializable. class langchain.llms.TextGen(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model_url, max_new_tokens=250, d...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-171
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – model_url (str) – max_new_tokens (Optional[int]) – do_sample (bool) – temperature (Optional[float]) – top_p (Optional[float]) – typical_p (Optional[float]) – epsilon_cutoff (Optional[float]) – eta_cutoff (O...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-172
Length Penalty attribute max_new_tokens: Optional[int] = 250 The maximum number of tokens to generate. attribute min_length: Optional[int] = 0 Minimum generation length in tokens. attribute model_url: str [Required] The full URL to the textgen webui including http[s]://host:port attribute no_repeat_ngram_size: Optio...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-173
attribute top_k: Optional[float] = 40 Similar to top_p, but select instead only the top_k most likely tokens. Higher value = higher range of possible random results. attribute top_p: Optional[float] = 0.1 If not set to 1, select tokens with probabilities adding up to less than this number. Higher value = higher range...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-174
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-175
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-176
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-177
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-178
llm_kwargs (Optional[Dict]) – Return type None 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 p...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-179
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-180
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-181
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-182
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-183
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]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler],...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-184
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, **values) Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-185
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 generate_prompt(prompts, stop=None, callba...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-186
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-187
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-188
endpoint_url (str) – inject_instruction_format (bool) – model_kwargs (Optional[dict]) – retry_sleep (float) – mosaicml_api_token (Optional[str]) – Return type None attribute endpoint_url: str = 'https://models.hosted-on.mosaicml.hosting/mpt-7b-instruct/v1/predict' Endpoint URL to use. attribute inject_instruction...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-189
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-190
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-191
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-192
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-193
Wrapper around NLPCloud large language models. To use, you should have the nlpcloud python package installed, and the environment variable NLPCLOUD_API_KEY set with your API key. Example from langchain.llms import NLPCloud nlpcloud = NLPCloud(model="gpt-neox-20b") Parameters cache (Optional[bool]) – verbose (bool) – ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-194
Whether min_length and max_length should include the length of the input. attribute length_penalty: float = 1.0 Exponential penalty to the length. attribute max_length: int = 256 The maximum number of tokens to generate in the completion. attribute min_length: int = 1 The minimum number of tokens to generate in the ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-195
Parameters prompt (str) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-196
langchain.schema.BaseMessage 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 Par...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-197
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-198
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-199
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.OpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='text-davinci-003', temperature=0.7, max_tokens=256, top_p=1, frequency_penalty=0, presence_penalty=0, n=1, best_...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-200
presence_penalty (float) – n (int) – best_of (int) – model_kwargs (Dict[str, Any]) – openai_api_key (Optional[str]) – openai_api_base (Optional[str]) – openai_organization (Optional[str]) – openai_proxy (Optional[str]) – batch_size (int) – request_timeout (Optional[Union[float, Tuple[float, float]]]) – logit_...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-201
-1 returns as many tokens as possible given the prompt and the models maximal context size. attribute model_kwargs: Dict[str, Any] [Optional] Holds any model parameters valid for create call not explicitly specified. attribute model_name: str = 'text-davinci-003' (alias 'model') Model name to use. attribute n: int = ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-202
Total probability mass of tokens to consider at each step. 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]]) – callbacks (Optiona...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-203
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, **values) Creates a new model sett...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-204
Return type langchain.schema.LLMResult 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]]) – callbacks (O...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-205
get_token_ids(text) Get the token IDs using the tiktoken package. 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 r...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-206
max_tokens = openai.modelname_to_contextsize("text-davinci-003") predict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters message...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-207
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 must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œo...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-208
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_name (s...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-209
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]]) – callbacks (Optional[Union[List[langchain.callba...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-210
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, **values) Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-211
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 generate_prompt(prompts, stop=None, callba...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-212
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-213
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-214
model_id (Optional[str]) – server_url (Optional[str]) – server_type (Literal['grpc', 'http']) – embedded (bool) – cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[la...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-215
Parameters prompt (str) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-216
langchain.schema.BaseMessage 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 Par...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-217
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-218
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-219
property lc_serializable: bool Return whether or not the class is serializable. property runner: openllm.LLMRunner Get the underlying openllm.LLMRunner instance for integration with BentoML. Example: .. code-block:: python llm = OpenLLM(model_name=’flan-t5’, model_id=’google/flan-t5-large’, embedded=False, ) tools = ...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-220
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – model (str) – temperature (float) – max_tokens (int) – top_p (float) – frequency_penalty (float) – presence_penalty (float) – n (int) – best_of (int) – model_kwargs (Dict[str, Any]) – open...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-221
attribute logit_bias: Optional[Dict[str, float]] [Optional] Adjust the probability of specific tokens being generated. attribute max_retries: int = 6 Maximum number of retries to make when generating. attribute max_tokens: int = 256 The maximum number of tokens to generate in the completion. -1 returns as many token...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-222
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 cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here. attribute top_p: float = 1 Total prob...
https://api.python.langchain.com/en/latest/modules/llms.html
45b46cec0462-223
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-224
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-225
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-226
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-227
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-228
environment variable HUGGINGFACE_API_KEY set with your API key. Any parameters that are valid to be passed to the call can be passed in, even if not explicitly saved on this class. Example from langchain.llms import petals petals = Petals() Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Unio...
https://api.python.langchain.com/en/latest/modules/llms.html