Tony20100/langchain_full huggingface dataset:
langchain_community.llms.fake.FakeStreamingListLLM¶
class langchain_community.llms.fake.FakeStreamingListLLM[source]¶
Bases: FakeListLLM
Fake streaming list LLM for testing purposes.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param i: int = 0¶
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param responses: List[str] [Required]¶
param sleep: Optional[float] = None¶
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
{'str': {'title': 'Str',
'type': 'string'}, 'hello': {'title': 'Hello', 'type': 'string'}}}
Parameters
kwargs (Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) – 
Return type
RunnableSerializable[Any, Any]
async astream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[str][source]¶
Default implementation of astream, which calls ainvoke.
Subclasses should override this method if they support streaming output.
Parameters
input (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) – 
config (Optional[RunnableConfig]) – 
stop (Optional[List[str]]) – 
kwargs (Any) – 
Return type
AsyncIterator[str]
astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[str]] = None, exclude_types: Optional[Sequence[str]] = None, exclude_tags: Optional[Sequence[str]] = None, **kwargs: Any) → AsyncIterator[StreamEvent]¶
[Beta] Generate a stream of events.
Use to create an iterator over StreamEvents that provide real-time information
Parameters
by_alias (bool) – 
ref_template (unicode) – 
dumps_kwargs (Any) – 
Return type
unicode
stream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[str][source]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
Parameters
input (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) – 
config (Optional[RunnableConfig]) – 
stop (Optional[List[str]]) – 
kwargs (Any) – 
Return type
Iterator[str]
to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶
Serialize the runnable to JSON.
Return type
Union[SerializedConstructor, SerializedNotImplemented]
to_json_not_implemented() → SerializedNotImplemented¶
Return type
SerializedNotImplemented
transform(input: Iterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶
Default implementation of transform, which buffers input and then calls stream.
Subclasses should override this method if they can start producing output while
input is still being generated.
Parameters
input (Iterator[Input]) – 
config (Optional[RunnableConfig]) – 
kwargs (Optional[Any]) – 
Return type
Iterator[Output]
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) – 
Return type
None
langchain_community.llms.sambanova.SVEndpointHandler¶
class langchain_community.llms.sambanova.SVEndpointHandler(host_url: str)[source]¶
SambaNova Systems Interface for Sambaverse endpoint.
Parameters
host_url (str) – Base URL of the DaaS API service
Initialize the SVEndpointHandler.
Parameters
host_url (str) – Base URL of the DaaS API service
Attributes
API_BASE_PATH
Methods
__init__(host_url)
Initialize the SVEndpointHandler.
nlp_predict(key, sambaverse_model_name, input)
NLP predict using inline input string.
nlp_predict_stream(key, ...[, params])
NLP predict using inline input string.
__init__(host_url: str)[source]¶
Initialize the SVEndpointHandler.
Parameters
host_url (str) – Base URL of the DaaS API service
nlp_predict(key: str, sambaverse_model_name: Optional[str], input: Union[List[str], str], params: Optional[str] = '', stream: bool = False) → Dict[source]¶
NLP predict using inline input string.
Parameters
project (str) – Project ID in which the endpoint exists
endpoint (str) – Endpoint ID
key (str) – API Key
input_str (str) – Input string
params (str) – Input params string
sambaverse_model_name (Optional[str]) – 
input (Union[List[str], str]) – 
stream (bool) – 
Returns
Prediction results
Return type
dict
nlp_predict_stream(key: str, sambaverse_model_name: Optional[str], input: Union[List[str], str], params: Optional[str] = '') → Iterator[Dict][source]¶
NLP predict using inline input string.
Parameters
project (str) – Project ID in which the endpoint exists
langchain_community.llms.petals.Petals¶
class langchain_community.llms.petals.Petals[source]¶
Bases: LLM
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_community.llms import petals
petals = Petals()
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param client: Any = None¶
The client to use for the API calls.
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param do_sample: bool = True¶
Whether or not to use sampling; use greedy decoding otherwise.
param huggingface_api_key: Optional[SecretStr] = None¶
Constraints
type = string
writeOnly = True
format = password
param max_length: Optional[int] = None¶
The maximum length of the sequence to be generated.
param max_new_tokens: int = 256¶
param max_new_tokens: int = 256¶
The maximum number of new tokens to generate in the completion.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_kwargs: Dict[str, Any] [Optional]¶
Holds any model parameters valid for create call
not explicitly specified.
param model_name: str = 'bigscience/bloom-petals'¶
The model to use.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: float = 0.7¶
What sampling temperature to use
param tokenizer: Any = None¶
The tokenizer to use for the API calls.
param top_k: Optional[int] = None¶
The number of highest probability vocabulary tokens
to keep for top-k-filtering.
param top_p: float = 0.9¶
The cumulative probability for top-p sampling.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
[Deprecated] Check Cache and run the LLM on the given prompt and input.
Notes
Deprecated since version langchain-core==0.1.7: Use invoke instead.
Parameters
prompt (str) – 
stop (Optional[List[str]]) – 
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – 
tags (Optional[List[str]]) – 
metadata (Optional[Dict[str, Any]]) – 
kwargs (Any) – 
Return type
str
Parameters
input_type (Optional[Type[Input]]) – 
output_type (Optional[Type[Output]]) – 
Return type
Runnable[Input, Output]
property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property config_specs: List[ConfigurableFieldSpec]¶
List configurable fields for this runnable.
property input_schema: Type[BaseModel]¶
The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
name: Optional[str] = None¶
The name of the runnable. Used for debugging and tracing.
property output_schema: Type[BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
Examples using Petals¶
Petals
langchain_community.llms.cerebriumai.CerebriumAI¶
class langchain_community.llms.cerebriumai.CerebriumAI[source]¶
Bases: LLM
CerebriumAI large language models.
To use, you should have the cerebrium python package installed.
You should also have the environment variable CEREBRIUMAI_API_KEY
set with your API key or pass it as a named argument in the constructor.
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_community.llms import CerebriumAI
cerebrium = CerebriumAI(endpoint_url="", cerebriumai_api_key="my-api-key")
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param cerebriumai_api_key: Optional[SecretStr] = None¶
Constraints
type = string
writeOnly = True
format = password
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param endpoint_url: str = ''¶
model endpoint to use
param endpoint_url: str = ''¶
model endpoint to use
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_kwargs: Dict[str, Any] [Optional]¶
Holds any model parameters valid for create call not
explicitly specified.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
[Deprecated] Check Cache and run the LLM on the given prompt and input.
Notes
Deprecated since version langchain-core==0.1.7: Use invoke instead.
Parameters
prompt (str) – 
stop (Optional[List[str]]) – 
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – 
tags (Optional[List[str]]) – 
metadata (Optional[Dict[str, Any]]) – 
kwargs (Any) – 
Return type
str
async abatch(inputs: List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
Parameters
input_type (Optional[Type[Input]]) – 
output_type (Optional[Type[Output]]) – 
Return type
Runnable[Input, Output]
property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property config_specs: List[ConfigurableFieldSpec]¶
List configurable fields for this runnable.
property input_schema: Type[BaseModel]¶
The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
name: Optional[str] = None¶
The name of the runnable. Used for debugging and tracing.
property output_schema: Type[BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
Examples using CerebriumAI¶
CerebriumAI
langchain_community.llms.symblai_nebula.make_request¶
langchain_community.llms.symblai_nebula.make_request(self: Nebula, prompt: str, url: str = 'https://api-nebula.symbl.ai/v1/model/generate', params: Optional[Dict] = None) → Any[source]¶
Generate text from the model.
Parameters
self (Nebula) – 
prompt (str) – 
url (str) – 
params (Optional[Dict]) – 
Return type
Any
langchain_community.llms.anyscale.create_llm_result¶
langchain_community.llms.anyscale.create_llm_result(choices: Any, prompts: List[str], token_usage: Dict[str, int], model_name: str) → LLMResult[source]¶
Create the LLMResult from the choices and prompts.
Parameters
choices (Any) – 
prompts (List[str]) – 
token_usage (Dict[str, int]) – 
model_name (str) – 
Return type
LLMResult
langchain_community.llms.aphrodite.Aphrodite¶
class langchain_community.llms.aphrodite.Aphrodite[source]¶
Bases: BaseLLM
Aphrodite language model.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param aphrodite_kwargs: Dict[str, Any] [Optional]¶
Holds any model parameters valid for aphrodite.LLM call not explicitly
specified.
param best_of: Optional[int] = None¶
Number of output sequences that are generated from the prompt.
From these best_of sequences, the top n sequences are returned.
best_of must be >= n. This is treated as the beam width when
use_beam_search is True. By default, best_of is set to n.
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param custom_token_bans: Optional[List[int]] = None¶
List of token IDs to ban from generating.
param download_dir: Optional[str] = None¶
Directory to download and load the weights. (Default to the default
cache dir of huggingface)
cache dir of huggingface)
param dtype: str = 'auto'¶
The data type for the model weights and activations.
param early_stopping: bool = False¶
Controls the stopping condition for beam search. It accepts the
following values: True, where the generation stops as soon as there
are best_of complete candidates; False, where a heuristic is applied
to the generation stops when it is very unlikely to find better candidates;
never, where the beam search procedure only stops where there cannot be
better candidates (canonical beam search algorithm).
param epsilon_cutoff: float = 0.0¶
Float that controls the cutoff threshold for Epsilon sampling
(simple probability threshold truncation). Specified in units of
1e-4. Set to 0 to disable.
param eta_cutoff: float = 0.0¶
Float that controls the cutoff threshold for Eta sampling
(a form of entropy adaptive truncation sampling). Threshold is
calculated as `min(eta, sqrt(eta)*entropy(probs)). Specified
in units of 1e-4. Set to 0 to disable.
param frequency_penalty: float = 0.0¶
Float that penalizes new tokens based on their frequency in the
generated text so far. Applied additively to the logits.
param ignore_eos: bool = False¶
Whether to ignore the EOS token and continue generating tokens after
the EOS token is generated.
param length_penalty: float = 1.0¶
Float that penalizes sequences based on their length. Used only
when use_beam_search is True.
param logit_bias: Optional[Dict[str, float]] = None¶
List of LogitsProcessors to change the probability of token
prediction at runtime.
param logprobs: Optional[int] = None¶
Number of log probabilities to return per output token.
Number of log probabilities to return per output token.
param max_tokens: int = 512¶
Maximum number of tokens to generate per output sequence.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param min_p: float = 0.0¶
Float that controls the cutoff for min-p sampling. Exact cutoff is
min_p*max_prob. Must be in [0,1], 0 to disable.
param mirostat_mode: int = 0¶
The mirostat mode to use. 0 for no mirostat, 2 for mirostat v2.
Mode 1 is not supported.
param mirostat_tau: float = 0.0¶
The target ‘surprisal’ that mirostat works towards. Range [0, inf).
param model: str = ''¶
The name or path of a HuggingFace Transformers model.
param n: int = 1¶
Number of output sequences to return for the given prompt.
param presence_penalty: float = 0.0¶
Float that penalizes new tokens based on whether they appear in the
generated text so far. Values > 0 encourage the model to generate new
tokens, while values < 0 encourage the model to repeat tokens.
param prompt_logprobs: Optional[int] = None¶
Number of log probabilities to return per prompt token.
param quantization: Optional[str] = None¶
Quantization mode to use. Can be one of awq or gptq.
param repetition_penalty: float = 1.0¶
Float that penalizes new tokens based on their frequency in the
generated text so far. Applied multiplicatively to the logits.
param skip_special_tokens: bool = True¶
Whether to skip special tokens in the output. Defaults to True.
Whether to skip special tokens in the output. Defaults to True.
param spaces_between_special_tokens: bool = True¶
Whether to add spaces between special tokens in the output.
Defaults to True.
param stop: Optional[List[str]] = None¶
List of strings that stop the generation when they are generated.
The returned output will not contain the stop tokens.
param stop_token_ids: Optional[List[int]] = None¶
List of tokens that stop the generation when they are generated.
The returned output will contain the stop tokens unless the stop tokens
are special tokens.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: float = 1.0¶
Float that controls the randomness of the sampling. Lower values
make the model more deterministic, while higher values make the model
more random. Zero is equivalent to greedy sampling.
param tensor_parallel_size: Optional[int] = 1¶
The number of GPUs to use for distributed execution with tensor parallelism.
param tfs: float = 1.0¶
Float that controls the cumulative approximate curvature of the
distribution to retain for Tail Free Sampling. Must be in (0, 1].
Set to 1.0 to disable.
param top_a: float = 0.0¶
Float that controls the cutoff for Top-A sampling. Exact cutoff is
top_a*max_prob**2. Must be in [0,inf], 0 to disable.
param top_k: int = -1¶
Integer that controls the number of top tokens to consider. Set to -1 to
consider all tokens (disabled).
param top_p: float = 1.0¶
Float that controls the cumulative probability of the top tokens to consider.
Must be in (0, 1]. Set to 1.0 to consider all tokens.
param trust_remote_code: Optional[bool] = False¶
Trust remote code (e.g., from HuggingFace) when downloading the model
and tokenizer.
param typical_p: float = 1.0¶
Float that controls the cumulative probability of tokens closest
in surprise to the expected surprise to consider. Must be in (0, 1].
Set to 1 to disable.
param use_beam_search: bool = False¶
Whether to use beam search instead of sampling.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
[Deprecated] Check Cache and run the LLM on the given prompt and input.
Notes
Deprecated since version langchain-core==0.1.7: Use invoke instead.
Parameters
prompt (str) – 
stop (Optional[List[str]]) – 
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – 
tags (Optional[List[str]]) – 
metadata (Optional[Dict[str, Any]]) – 
kwargs (Any) – 
Return type
str
async abatch(inputs: List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
Parameters
inputs (List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]]) – 
config (Optional[Union[RunnableConfig, List[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Any) – 
Return type
List[str]
async abatch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → AsyncIterator[Tuple[int, Union[Output, Exception]]]¶
Run ainvoke in parallel on a list of inputs,
yielding results as they complete.
Parameters
inputs (Sequence[Input]) – 
config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Optional[Any]) – 
Return type
AsyncIterator[Tuple[int, Union[Output, Exception]]]