Tony20100/langchain_full huggingface dataset:
langchain_community.llms.moonshot.Moonshot¶
class langchain_community.llms.moonshot.Moonshot[source]¶
Bases: MoonshotCommon, LLM
Moonshot large language models.
To use, you should have the environment variable MOONSHOT_API_KEY set with your
API key. Referenced from https://platform.moonshot.cn/docs
Example
from langchain_community.llms.moonshot import Moonshot
moonshot = Moonshot(model="moonshot-v1-8k")
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 base_url: str = 'https://api.moonshot.cn/v1'¶
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 max_tokens = 1024¶
Maximum number of tokens to generate.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: str = 'moonshot-v1-8k' (alias 'model')¶
Model name. Available models listed here: https://platform.moonshot.cn/pricing
Model name. Available models listed here: https://platform.moonshot.cn/pricing
param moonshot_api_key: Optional[SecretStr] = None (alias 'api_key')¶
Moonshot API key. Get it here: https://platform.moonshot.cn/console/api-keys
Constraints
type = string
writeOnly = True
format = password
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature = 0.3¶
Temperature parameter (higher values make the model more creative).
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.
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¶
A map of constructor argument names to secret ids.
For example,{“moonshot_api_key”: “MOONSHOT_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 Moonshot¶
MoonshotChat
langchain_google_vertexai.llms.VertexAI¶
class langchain_google_vertexai.llms.VertexAI[source]¶
Bases: _VertexAICommon, BaseLLM
Google Vertex AI large language models.
Needed for mypy typing to recognize model_name as a valid arg.
param additional_headers: Optional[Dict[str, str]] = None¶
A key-value dictionary representing additional headers for the model call
param api_endpoint: Optional[str] = None¶
Desired API endpoint, e.g., us-central1-aiplatform.googleapis.com
param api_transport: Optional[str] = None¶
The desired API transport method, can be either ‘grpc’ or ‘rest’
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_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None¶
A callback which returns client certificate bytes and private key bytes both
param credentials: Any = None¶
The default custom credentials (google.auth.credentials.Credentials) to use
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param full_model_name: Optional[str] = None¶
The full name of the model’s endpoint.
param location: str = 'us-central1'¶
The default location to use when making API calls.
The default location to use when making API calls.
param max_output_tokens: Optional[int] = None (alias 'max_tokens')¶
Token limit determines the maximum amount of text output from one prompt.
param max_retries: int = 6¶
The maximum number of retries to make when generating.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: str = 'text-bison' (alias 'model')¶
The name of the Vertex AI large language model.
param n: int = 1¶
How many completions to generate for each prompt.
param project: Optional[str] = None¶
The default GCP project to use when making Vertex API calls.
param request_parallelism: int = 5¶
The amount of parallelism allowed for requests issued to VertexAI models.
param safety_settings: Optional['SafetySettingsType'] = None¶
The default safety settings to use for all generations.
For example:
from langchain_google_vertexai import HarmBlockThreshold, HarmCategory
safety_settings = {HarmCategory.HARM_CATEGORY_UNSPECIFIED: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_ONLY_HIGH,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
}
param stop: Optional[List[str]] = None (alias 'stop_sequences')¶
Optional list of stop words to use when generating.
param streaming: bool = False¶
Whether to stream the results or not.
param tags: Optional[List[str]] = None¶
Whether to stream the results or not.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: Optional[float] = None¶
Sampling temperature, it controls the degree of randomness in token selection.
param top_k: Optional[int] = None¶
How the model selects tokens for output, the next token is selected from
param top_p: Optional[float] = None¶
Tokens are selected from most probable to least until the sum of their
param tuned_model_name: Optional[str] = None¶
The name of a tuned model. If tuned_model_name is passed
model_name will be used to determine the model family
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 async_prediction_client: PredictionServiceAsyncClient¶
Returns PredictionServiceClient.
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.
property prediction_client: PredictionServiceClient¶
Returns PredictionServiceClient.
task_executor: ClassVar[Optional[Executor]] = FieldInfo(exclude=True, extra={})¶
Examples using VertexAI¶
Google Cloud Vertex AI
Google Cloud Vertex AI Reranker
Google Vertex AI Vector Search
langchain_community.llms.mlflow_ai_gateway.MlflowAIGateway¶
class langchain_community.llms.mlflow_ai_gateway.MlflowAIGateway[source]¶
Bases: LLM
MLflow AI Gateway LLMs.
To use, you should have the mlflow[gateway] python package installed.
For more information, see https://mlflow.org/docs/latest/gateway/index.html.
Example
from langchain_community.llms import MlflowAIGateway
completions = MlflowAIGateway(
    gateway_uri="<your-mlflow-ai-gateway-uri>",
    route="<your-mlflow-ai-gateway-completions-route>",
    params={
        "temperature": 0.1
    }
)
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 gateway_uri: Optional[str] = None¶
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param params: Optional[Params] = None¶
Metadata to add to the run trace.
param params: Optional[Params] = None¶
param route: str [Required]¶
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;
e.g., if the underlying runnable uses an API which supports a batch mode.
Parameters
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 MlflowAIGateway¶
MLflow AI Gateway
langchain_community.llms.fireworks.acompletion_with_retry¶
async langchain_community.llms.fireworks.acompletion_with_retry(llm: Fireworks, use_retry: bool, *, run_manager: Optional[AsyncCallbackManagerForLLMRun] = None, **kwargs: Any) → Any[source]¶
Use tenacity to retry the completion call.
Parameters
llm (Fireworks) – 
use_retry (bool) – 
run_manager (Optional[AsyncCallbackManagerForLLMRun]) – 
kwargs (Any) – 
Return type
Any
langchain_community.llms.google_palm.completion_with_retry¶
langchain_community.llms.google_palm.completion_with_retry(llm: GooglePalm, prompt: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], is_gemini: bool = False, stream: bool = False, run_manager: Optional[CallbackManagerForLLMRun] = None, **kwargs: Any) → Any[source]¶
Use tenacity to retry the completion call.
Parameters
llm (GooglePalm) – 
prompt (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) – 
is_gemini (bool) – 
stream (bool) – 
run_manager (Optional[CallbackManagerForLLMRun]) – 
kwargs (Any) – 
Return type
Any
langchain_community.llms.vertexai.VertexAIModelGarden¶
class langchain_community.llms.vertexai.VertexAIModelGarden[source]¶
Bases: _VertexAIBase, BaseLLM
[Deprecated] Vertex AI Model Garden large language models.
Notes
Deprecated since version 0.0.12.
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 allowed_model_args: Optional[List[str]] = None¶
Allowed optional args to be passed to the 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 endpoint_id: str [Required]¶
A name of an endpoint where the model has been deployed.
param location: str = 'us-central1'¶
The default location to use when making API calls.
param max_retries: int = 6¶
The maximum number of retries to make when generating.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: Optional[str] = None¶
Underlying model name.
param project: Optional[str] = None¶
Underlying model name.
param project: Optional[str] = None¶
The default GCP project to use when making Vertex API calls.
param prompt_arg: str = 'prompt'¶
param request_parallelism: int = 5¶
The amount of parallelism allowed for requests issued to VertexAI models.
param result_arg: Optional[str] = 'generated_text'¶
Set result_arg to None if output of the model is expected to be a string.
param stop: Optional[List[str]] = None¶
Optional list of stop words to use when generating.
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
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 endpoint_path: str¶
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.
task_executor: ClassVar[Optional[Executor]] = FieldInfo(exclude=True, extra={})¶
Examples using VertexAIModelGarden¶
Google
Google Cloud Vertex AI
langchain_community.llms.llamacpp.LlamaCpp¶
class langchain_community.llms.llamacpp.LlamaCpp[source]¶
Bases: LLM
llama.cpp model.
To use, you should have the llama-cpp-python library installed, and provide the
path to the Llama model as a named parameter to the constructor.
Check out: https://github.com/abetlen/llama-cpp-python
Example
from langchain_community.llms import LlamaCpp
llm = LlamaCpp(model_path="/path/to/llama/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 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 echo: Optional[bool] = False¶
Whether to echo the prompt.
param f16_kv: bool = True¶
Use half-precision for key/value cache.
param grammar: Optional[Union[str, Any]] = None¶
grammar: formal grammar for constraining model outputs. For instance, the grammar
can be used to force the model to generate valid JSON or to speak exclusively in
can be used to force the model to generate valid JSON or to speak exclusively in
emojis. At most one of grammar_path and grammar should be passed in.
param grammar_path: Optional[Union[str, Path]] = None¶
grammar_path: Path to the .gbnf file that defines formal grammars
for constraining model outputs. For instance, the grammar can be used
to force the model to generate valid JSON or to speak exclusively in emojis. At most
one of grammar_path and grammar should be passed in.
param last_n_tokens_size: Optional[int] = 64¶
The number of tokens to look back when applying the repeat_penalty.
param logits_all: bool = False¶
Return logits for all tokens, not just the last token.
param logprobs: Optional[int] = None¶
The number of logprobs to return. If None, no logprobs are returned.
param lora_base: Optional[str] = None¶
The path to the Llama LoRA base model.
param lora_path: Optional[str] = None¶
The path to the Llama LoRA. If None, no LoRa is loaded.
param max_tokens: Optional[int] = 256¶
The maximum number of tokens to generate.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_kwargs: Dict[str, Any] [Optional]¶
Any additional parameters to pass to llama_cpp.Llama.
param model_path: str [Required]¶
The path to the Llama model file.
param n_batch: Optional[int] = 8¶
Number of tokens to process in parallel.
Should be a number between 1 and n_ctx.
param n_ctx: int = 512¶
Token context window.
param n_gpu_layers: Optional[int] = None¶
Token context window.
param n_gpu_layers: Optional[int] = None¶
Number of layers to be loaded into gpu memory. Default None.
param n_parts: int = -1¶
Number of parts to split the model into.
If -1, the number of parts is automatically determined.
param n_threads: Optional[int] = None¶
Number of threads to use.
If None, the number of threads is automatically determined.
param repeat_penalty: Optional[float] = 1.1¶
The penalty to apply to repeated tokens.
param rope_freq_base: float = 10000.0¶
Base frequency for rope sampling.
param rope_freq_scale: float = 1.0¶
Scale factor for rope sampling.
param seed: int = -1¶
Seed. If -1, a random seed is used.
param stop: Optional[List[str]] = []¶
A list of strings to stop generation when encountered.
param streaming: bool = True¶
Whether to stream the results, token by token.
param suffix: Optional[str] = None¶
A suffix to append to the generated text. If None, no suffix is appended.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: Optional[float] = 0.8¶
The temperature to use for sampling.
param top_k: Optional[int] = 40¶
The top-k value to use for sampling.
param top_p: Optional[float] = 0.95¶
The top-p value to use for sampling.
param use_mlock: bool = False¶
Force system to keep model in RAM.
param use_mmap: Optional[bool] = True¶
Whether to keep the model loaded in RAM
param verbose: bool = True¶
Print verbose output to stderr.