id
stringlengths
14
16
text
stringlengths
4
1.28k
source
stringlengths
54
121
0e0436a883fe-411
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.base.BaseCal...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-412
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
0e0436a883fe-413
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 dict(). encoder is an optio...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-414
models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode max_tokens_for_prompt(prompt) Calculate the maximum number of tokens possible to generate for a prompt. Parameters prompt (str) – The prompt to pass into the model. Returns The maximum number of tokens to generate for a prompt. Return type int Example ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-415
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.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-416
stream(prompt, stop=None) Call OpenAI with streaming flag and return the resulting generator. BETA: this is a beta feature while we figure out the right abstraction. Once that happens, this interface could change. Parameters prompt (str) – The prompts to pass into the model. stop (Optional[List[str]]) – Optional list ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-417
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/llms.html
0e0436a883fe-418
Get max context size for this model. class langchain.llms.OpenAIChat(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='gpt-3.5-turbo', model_kwargs=None, openai_api_key=None, openai_api_base=None, openai_proxy=None, max_retries=6, prefix_messages=None, streaming=Fal...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-419
from langchain.llms import OpenAIChat openaichat = OpenAIChat(model_name="gpt-3.5-turbo") Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-420
streaming (bool) – allowed_special (Union[Literal['all'], typing.AbstractSet[str]]) – disallowed_special (Union[Literal['all'], typing.Collection[str]]) – Return type None attribute allowed_special: Union[Literal['all'], AbstractSet[str]] = {} Set of special tokens that are allowed。 attribute disallowed_special: Un...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-421
Series of messages for Chat input. attribute streaming: bool = False Whether to stream the results or not. 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...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-422
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, callbacks=...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-423
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
0e0436a883fe-424
Return type 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, MappingI...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-425
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.base.BaseCal...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-426
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
0e0436a883fe-427
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, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bo...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-428
Return type str predict_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 save(file_path) Save the LLM. Parameters file_path (Union[pathlib.Pat...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-429
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/llms.html
0e0436a883fe-430
instance and remote OpenLLM servers. To use, you should have the openllm library installed: pip install openllm Learn more at: https://github.com/bentoml/openllm Example running an LLM model locally managed by OpenLLM:from langchain.llms import OpenLLM llm = OpenLLM( model_name='flan-t5', model_id='google/flan-...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-431
Parameters model_name (Optional[str]) – 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.BaseCallbackMa...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-432
attribute model_id: Optional[str] = None Model Id to use. If not provided, will use the default model for the model name. See β€˜openllm models’ for all available model variants. attribute model_name: Optional[str] = None Model name to use. See β€˜openllm models’ for all available models. attribute server_type: ServerTyp...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-433
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], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbac...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-434
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
0e0436a883fe-435
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 data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = β€˜allow’ was set since it adds all passe...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-436
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
0e0436a883fe-437
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
0e0436a883fe-438
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_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs) Generate a JSON represen...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-439
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 predict_messages(messages, *, st...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-440
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
0e0436a883fe-441
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
0e0436a883fe-442
return agent.run(input_text) class langchain.llms.OpenLM(*, 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_of=1, model_kwargs=None, openai_api_key=None, openai...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-443
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) – temperature (float) – max_tokens (...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-444
batch_size (int) – request_timeout (Optional[Union[float, Tuple[float, float]]]) – logit_bias (Optional[Dict[str, float]]) – max_retries (int) – streaming (bool) – allowed_special (Union[Literal['all'], typing.AbstractSet[str]]) – disallowed_special (Union[Literal['all'], typing.Collection[str]]) – tiktoken_mode...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-445
attribute disallowed_special: Union[Literal['all'], Collection[str]] = 'all' Set of special tokens that are not allowed。 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...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-446
Model name to use. attribute n: int = 1 How many completions to generate for each prompt. attribute presence_penalty: float = 0 Penalizes repeated tokens. attribute request_timeout: Optional[Union[float, Tuple[float, float]]] = None Timeout for requests to OpenAI completion API. Default is 600 seconds. attribute str...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-447
them to be under a certain limit. By default, when set to None, this will 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 pr...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-448
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
0e0436a883fe-449
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
0e0436a883fe-450
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 _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-451
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 create_llm_result(choices, prompts, token_usage) Create the LLMResult from the choices and prompts. Parameters choices (Any) – prompts (List[str]) – token_...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-452
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, callbacks=None, **kwargs) Take in a lis...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-453
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 get_sub_prompts(params, prompts, stop=None) Get the sub prompts for llm call. Parameters params (Dict[str, Any]) – prompts (List[str]) – stop (O...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-454
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
0e0436a883fe-455
Returns The maximum number of tokens to generate for a prompt. Return type 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 kn...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-456
Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type langchain.schema.BaseMessage prep_streaming_params(stop=None) Prepare the params for streaming. Parameters stop (Optional[List[str]]) – Return type Dict[str, Any] sa...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-457
Parameters prompt (str) – The prompts 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 OpenAI. Return type Generator Example generator = openai.stream("Tell me a joke.") for token in generator: yield t...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-458
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 serializable. property max_context_size: int Get max context size for this model. class langchain.llms.Petals(*, cac...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-459
Wrapper around Petals Bloom models. To use, you should have the petals python package installed, and the 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...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-460
top_p (float) – top_k (Optional[int]) – do_sample (bool) – max_length (Optional[int]) – model_kwargs (Dict[str, Any]) – huggingface_api_key (Optional[str]) – Return type None attribute client: Any = None The client to use for the API calls. attribute do_sample: bool = True Whether or not to use sampling; use gr...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-461
The model to use. attribute tags: Optional[List[str]] = None 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 to...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-462
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 prompt and input. Parameter...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-463
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
0e0436a883fe-464
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 _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-465
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
0e0436a883fe-466
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
0e0436a883fe-467
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 dict(). encoder is an optio...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-468
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 predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messa...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-469
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 must be accepted by th...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-470
class langchain.llms.PipelineAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, pipeline_key='', pipeline_kwargs=None, pipeline_api_key=None)[source] Bases: langchain.llms.base.LLM, pydantic.main.BaseModel Wrapper around PipelineAI large language models. To use, you should have the pipel...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-471
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – pipeline_key (str) – pipeline_kwargs (Dict[str, Any]) – pipeline_api_key (Optional[str]) – Return type None attribute pipeline_key: str = '' The id or tag of the target pipeline attribute pipeline_kwargs: Dict...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-472
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 prompt and input. Parameter...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-473
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
0e0436a883fe-474
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 _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-475
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
0e0436a883fe-476
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
0e0436a883fe-477
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 dict(). encoder is an optio...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-478
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 predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messa...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-479
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 must be accepted by th...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-480
class langchain.llms.PredictionGuard(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='MPT-7B-Instruct', output=None, max_tokens=256, temperature=0.75, token=None, stop=None)[source] Bases: langchain.llms.base.LLM Wrapper around Prediction Guard large language models. T...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-481
"type": "boolean" }) 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...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-482
Model name to use. attribute output: Optional[Dict[str, Any]] = None The output type or structure for controlling the LLM output. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute temperature: float = 0.75 A non-negative float that tunes the degree of randomness in generation. attrib...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-483
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
0e0436a883fe-484
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) Predict text from text. Parameters text (str) – stop (Optio...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-485
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 _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-486
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
0e0436a883fe-487
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
0e0436a883fe-488
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 dict(). encoder is an optio...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-489
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 predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messa...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-490
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 must be accepted by th...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-491
class langchain.llms.PromptLayerOpenAI(*, 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_of=1, model_kwargs=None, openai_api_key=None, openai_api_base=None, op...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-492
and PROMPTLAYER_API_KEY set with your openAI API key and promptlayer key respectively. All parameters that can be passed to the OpenAI LLM can also be passed here. The PromptLayerOpenAI LLM adds two optional Parameters pl_tags (Optional[List[str]]) – List of strings to tag the request with. return_pl_id (Optional[bool]...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-493
temperature (float) – max_tokens (int) – top_p (float) – frequency_penalty (float) – 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]) – ba...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-494
tiktoken_model_name (Optional[str]) – Return type None Example from langchain.llms import PromptLayerOpenAI openai = PromptLayerOpenAI(model_name="text-davinci-003") __call__(prompt, stop=None, callbacks=None, **kwargs) Check Cache and run the LLM on the given prompt and input. Parameters prompt (str) – stop (Option...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-495
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, callbacks=None, **kwargs) Take i...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-496
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
0e0436a883fe-497
Return type 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, MappingI...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-498
Parameters choices (Any) – prompts (List[str]) – token_usage (Dict[str, int]) – 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 ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-499
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
0e0436a883fe-500
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 the tiktoken package. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclu...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-501
by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode max_tokens_for_prompt(prompt) Calculate the maximum number of tokens possible to ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-502
Parameters modelname (str) – The modelname we want to know the context size for. Returns The maximum context size Return type int Example 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]]...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-503
Return type Dict[str, Any] 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”) stream(prompt, stop=None) Call OpenAI with streaming flag and return the resulting generator....
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-504
for token in generator: yield token 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....
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-505
property max_context_size: int Get max context size for this model. class langchain.llms.PromptLayerOpenAIChat(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='gpt-3.5-turbo', model_kwargs=None, openai_api_key=None, openai_api_base=None, openai_proxy=None, max_ret...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-506
promptlayer key respectively. All parameters that can be passed to the OpenAIChat LLM can also be passed here. The PromptLayerOpenAIChat adds two optional Parameters pl_tags (Optional[List[str]]) – List of strings to tag the request with. return_pl_id (Optional[bool]) – If True, the PromptLayer request ID will be retur...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-507
openai_api_base (Optional[str]) – openai_proxy (Optional[str]) – max_retries (int) – prefix_messages (List) – streaming (bool) – allowed_special (Union[Literal['all'], typing.AbstractSet[str]]) – disallowed_special (Union[Literal['all'], typing.Collection[str]]) – Return type None Example from langchain.llms imp...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-508
Maximum number of retries to make when generating. attribute model_kwargs: Dict[str, Any] [Optional] Holds any model parameters valid for create call not explicitly specified. attribute model_name: str = 'gpt-3.5-turbo' Model name to use. attribute prefix_messages: List [Optional] Series of messages for Chat input. ...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-509
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.BaseCallbackManag...
https://api.python.langchain.com/en/latest/modules/llms.html
0e0436a883fe-510
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