id stringlengths 14 16 | text stringlengths 4 1.28k | source stringlengths 54 121 |
|---|---|---|
0e0436a883fe-211 | 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-212 | 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-213 | 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-214 | 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-215 | class langchain.llms.FakeListLLM(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, responses, i=0)[source]
Bases: langchain.llms.base.LLM
Fake LLM wrapper for testing purposes.
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.Ba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-216 | 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], langchain.callbacks.base.BaseCallba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-217 | 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 |
0e0436a883fe-218 | 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 |
0e0436a883fe-219 | 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 |
0e0436a883fe-220 | 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-221 | 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_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-222 | 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 (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-223 | 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:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-224 | 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.
class langchain.llms.ForefrontAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, ta... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-225 | from langchain.llms import ForefrontAI
forefrontai = ForefrontAI(endpoint_url="")
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.Ba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-226 | attribute endpoint_url: str = ''
Model name to use.
attribute length: int = 256
The maximum number of tokens to generate in the completion.
attribute repetition_penalty: int = 1
Penalizes repeated tokens according to frequency.
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute tempe... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-227 | 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-228 | 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-229 | 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-230 | 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-231 | 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-232 | 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-233 | 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-234 | 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-235 | property lc_serializable: bool
Return whether or not the class is serializable.
class langchain.llms.GPT4All(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model, backend=None, n_ctx=512, n_parts=- 1, seed=0, f16_kv=False, logits_all=False, vocab_only=False, use_mlock=False, embedding=F... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-236 | pre-trained model file, and the model’s config information.
Example
from langchain.llms import GPT4All
model = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8)
# Simplest invocation
response = model("Once upon a time, ")
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-237 | logits_all (bool) –
vocab_only (bool) –
use_mlock (bool) –
embedding (bool) –
n_threads (Optional[int]) –
n_predict (Optional[int]) –
temp (Optional[float]) –
top_p (Optional[float]) –
top_k (Optional[int]) –
echo (Optional[bool]) –
stop (Optional[List[str]]) –
repeat_last_n (Optional[int]) –
repeat_penalty... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-238 | Leave (n_ctx * context_erase) tokens
starting from beginning if the context has run out.
attribute echo: Optional[bool] = False
Whether to echo the prompt.
attribute embedding: bool = False
Use embedding mode only.
attribute f16_kv: bool = False
Use half-precision for key/value cache.
attribute logits_all: bool = Fa... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-239 | attribute n_predict: Optional[int] = 256
The maximum number of tokens to generate.
attribute n_threads: Optional[int] = 4
Number of threads to use.
attribute repeat_last_n: Optional[int] = 64
Last n tokens to penalize
attribute repeat_penalty: Optional[float] = 1.3
The penalty to apply to repeated tokens.
attribute... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-240 | The temperature to use for sampling.
attribute top_k: Optional[int] = 40
The top-k value to use for sampling.
attribute top_p: Optional[float] = 0.95
The top-p value to use for sampling.
attribute use_mlock: bool = False
Force system to keep model in RAM.
attribute verbose: bool [Optional]
Whether to print out resp... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-241 | 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-242 | 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-243 | 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-244 | 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-245 | 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-246 | 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-247 | 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-248 | 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-249 | class langchain.llms.GooglePalm(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, google_api_key=None, model_name='models/text-bison-001', temperature=0.7, top_p=None, top_k=None, max_output_tokens=None, n=1)[source]
Bases: langchain.llms.base.BaseLLM, pydantic.main.BaseModel
... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-250 | temperature (float) –
top_p (Optional[float]) –
top_k (Optional[int]) –
max_output_tokens (Optional[int]) –
n (int) –
Return type
None
attribute max_output_tokens: Optional[int] = None
Maximum number of tokens to include in a candidate. Must be greater than zero.
If unset, will default to 64.
attribute model_name... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-251 | [0.0, 1.0].
attribute top_k: Optional[int] = None
Decode using top-k sampling: consider the set of top_k most probable tokens.
Must be positive.
attribute top_p: Optional[float] = None
Decode using nucleus sampling: consider the smallest set of tokens whose
probability sum is at least top_p. Must be in the closed int... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-252 | 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-253 | 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-254 | 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-255 | 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-256 | 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-257 | 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-258 | 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-259 | 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-260 | 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_penalty=0, n=1, model_kwargs=None, logit_bias=None, gooseai_api_key=None)[source]
Base... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-261 | from langchain.llms import GooseAI
gooseai = GooseAI(model_name="gpt-neo-20b")
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.BaseC... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-262 | 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 |
0e0436a883fe-263 | attribute n: int = 1
How many completions to generate for each prompt.
attribute presence_penalty: float = 0
Penalizes repeated tokens.
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute temperature: float = 0.7
What sampling temperature to use
attribute top_p: float = 1
Total proba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-264 | 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-265 | 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-266 | 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-267 | 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-268 | 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-269 | 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-270 | 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-271 | 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-272 | 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
Wrapper around HuggingFaceHub Inference Endpoints.
To use, you should have the hug... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-273 | )
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) –
tags (Optional[List[str]]) –
endpoint_url (str) –
task ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-274 | 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 given prompt and input.
Parameters
prompt (str) –
stop (Optional[L... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-275 | 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-276 | 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-277 | 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-278 | 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-279 | 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-280 | 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-281 | 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-282 | 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-283 | Wrapper around HuggingFaceHub models.
To use, you should have the huggingface_hub python package installed, and the
environment variable HUGGINGFACEHUB_API_TOKEN set with your API token, or pass
it as a named parameter to the constructor.
Only supports text-generation, text2text-generation and summarization for now.
E... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-284 | 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 |
0e0436a883fe-285 | 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-286 | 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-287 | 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-288 | 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-289 | 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-290 | 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-291 | 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-292 | 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-293 | class langchain.llms.HuggingFacePipeline(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, pipeline=None, model_id='gpt2', model_kwargs=None, pipeline_kwargs=None)[source]
Bases: langchain.llms.base.LLM
Wrapper around HuggingFace Pipeline API.
To use, you should have the transformers pytho... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-294 | 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(pipeline=pipe)
Parameters
cache (Optional[bool]) –
verbose (bool) –
callba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-295 | Model name to use.
attribute model_kwargs: Optional[dict] = None
Key word arguments passed to the model.
attribute pipeline_kwargs: Optional[dict] = None
Key word arguments passed to the pipeline.
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute verbose: bool [Optional]
Whether to ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-296 | Run the LLM on the given prompt and input.
Parameters
prompts (List[str]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-297 | 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
messages (List[lang... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-298 | Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
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 ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-299 | Model
dict(**kwargs)
Return a dictionary of the LLM.
Parameters
kwargs (Any) –
Return type
Dict
classmethod from_model_id(model_id, task, device=- 1, model_kwargs=None, pipeline_kwargs=None, **kwargs)[source]
Construct the pipeline object from model_id and task.
Parameters
model_id (str) –
task (str) –
device (int... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-300 | 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-301 | 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_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-302 | 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 (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-303 | 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:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-304 | 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.
class langchain.llms.HuggingFaceTextGenInference(*, cache=None, verbose=None, callbacks=None, callback_... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-305 | It is used to generate text from a given prompt.
Attributes:
- max_new_tokens: The maximum number of tokens to generate.
- top_k: The number of top-k tokens to consider when generating text.
- top_p: The cumulative probability threshold for generating text.
- typical_p: The typical probability threshold for generating ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-306 | - async_client: The async client object used to communicate with the server.
Methods:
- _call: Generates text based on a given prompt and stop sequences.
- _acall: Async generates text based on a given prompt and stop sequences.
- _llm_type: Returns the type of LLM.
Parameters
cache (Optional[bool]) –
verbose (bool) –... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-307 | stop_sequences (List[str]) –
seed (Optional[int]) –
inference_server_url (str) –
timeout (int) –
server_kwargs (Dict[str, Any]) –
stream (bool) –
client (Any) –
async_client (Any) –
Return type
None
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute verbose: bool [Optional]
Whe... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-308 | 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-309 | 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 |
0e0436a883fe-310 | Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
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 ... | 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.