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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.