id
stringlengths
14
16
text
stringlengths
45
2.73k
source
stringlengths
49
114
cc47f48085d0-2
embed_documents(texts: List[str]) → List[List[float]][source]# Call out to Cohere’s embedding endpoint. Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Call out to Cohere’s embedding endpoint. Parameters text – The text to embed...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-3
embed_query(text: str) → List[float][source]# Compute query embeddings using a HuggingFace transformer model. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.HuggingFaceHubEmbeddings[source]# Wrapper around HuggingFaceHub embedding models. To use, you should hav...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-4
Wrapper around sentence_transformers embedding models. To use, you should have the sentence_transformers and InstructorEmbedding python package installed. Example from langchain.embeddings import HuggingFaceInstructEmbeddings model_name = "hkunlp/instructor-large" model_kwargs = {'device': 'cpu'} hf = HuggingFaceInstru...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-5
Example from langchain.embeddings import LlamaCppEmbeddings llama = LlamaCppEmbeddings(model_path="/path/to/model.bin") field f16_kv: bool = False# Use half-precision for key/value cache. field logits_all: bool = False# Return logits for all tokens, not just the last token. field n_batch: Optional[int] = 8# Number of t...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-6
environment variable OPENAI_API_KEY set with your API key or pass it as a named parameter to the constructor. Example from langchain.embeddings import OpenAIEmbeddings openai = OpenAIEmbeddings(openai_api_key="my-api-key") In order to use the library with Microsoft Azure endpoints, you need to set the OPENAI_API_TYPE, ...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-7
embed_query(text: str) → List[float][source]# Call out to OpenAI’s embedding endpoint for embedding query text. Parameters text – The text to embed. Returns Embedding for the text. pydantic model langchain.embeddings.SagemakerEndpointEmbeddings[source]# Wrapper around custom Sagemaker Inference Endpoints. To use, you m...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-8
field endpoint_name: str = ''# The name of the endpoint from the deployed Sagemaker model. Must be unique within an AWS Region. field model_kwargs: Optional[Dict] = None# Key word arguments to pass to the model. field region_name: str = ''# The aws region where the Sagemaker model is deployed, eg. us-west-2. embed_docu...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-9
def get_pipeline(): model_id = "facebook/bart-large" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) return pipeline("feature-extraction", model=model, tokenizer=tokenizer) embeddings = SelfHostedEmbeddings( model_load_fn=get_pipeline, h...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-10
Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.SelfHostedHuggingFaceEmbeddings[source]# Runs sentence_transformers embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as se...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-11
Runs InstructorEmbedding embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as servers specified by IP address and SSH credentials (such as on-prem, or another cloud like Paperspace, Coreweave, etc.). To use, you should have the r...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cc47f48085d0-12
pydantic model langchain.embeddings.TensorflowHubEmbeddings[source]# Wrapper around tensorflow_hub embedding models. To use, you should have the tensorflow_text python package installed. Example from langchain.embeddings import TensorflowHubEmbeddings url = "https://tfhub.dev/google/universal-sentence-encoder-multiling...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
af268a022377-0
.rst .pdf Docstore Docstore# Wrappers on top of docstores. class langchain.docstore.InMemoryDocstore(_dict: Dict[str, langchain.schema.Document])[source]# Simple in memory docstore in the form of a dict. add(texts: Dict[str, langchain.schema.Document]) → None[source]# Add texts to in memory dictionary. search(search: s...
https://python.langchain.com/en/latest/reference/modules/docstore.html
fbeba0d8e856-0
.rst .pdf SerpAPI SerpAPI# For backwards compatiblity. pydantic model langchain.serpapi.SerpAPIWrapper[source]# Wrapper around SerpAPI. To use, you should have the google-search-results python package installed, and the environment variable SERPAPI_API_KEY set with your API key, or pass serpapi_api_key as a named param...
https://python.langchain.com/en/latest/reference/modules/serpapi.html
31fa97c521c0-0
.rst .pdf SearxNG Search Contents Quick Start Searching Engine Parameters Search Tips SearxNG Search# Utility for using SearxNG meta search API. SearxNG is a privacy-friendly free metasearch engine that aggregates results from multiple search engines and databases and supports the OpenSearch specification. More detai...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
31fa97c521c0-1
# assuming the searx host is set as above or exported as an env variable s = SearxSearchWrapper(engines=['google', 'bing'], language='es') Search Tips# Searx offers a special search syntax that can also be used instead of passing engine parameters. For example the following query: s = SearxSearchWra...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
31fa97c521c0-2
use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your own network as described here. For a list of public SearxNG instances see https://searx.space/ class langchain.utilities.searx_search.SearxResults(data: str)[source]# Dict like wrappe...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
31fa97c521c0-3
field params: dict [Optional]# field query_suffix: Optional[str] = ''# field searx_host: str = ''# field unsecure: bool = False# async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) → List[Dict][source]# Asynchronously query with json results...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
31fa97c521c0-4
Run query through Searx API and parse results. You can pass any other params to the searx query API. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra param...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
a494bf45d4c4-0
.rst .pdf Example Selector Example Selector# Logic for selecting examples to include in prompts. pydantic model langchain.prompts.example_selector.LengthBasedExampleSelector[source]# Select examples based on length. Validators calculate_example_text_lengths » example_text_lengths field example_prompt: langchain.prompts...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
a494bf45d4c4-1
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An iniialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g....
https://python.langchain.com/en/latest/reference/modules/example_selector.html
a494bf45d4c4-2
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An initialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
01c61c5f8653-0
.rst .pdf Text Splitter Text Splitter# Functionality for splitting text. class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]# Implementation of splitting text that looks at characters. split_text(text: str) → List[str][source]# Split incoming text and return chunks. class...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
01c61c5f8653-1
Split incoming text and return chunks. class langchain.text_splitter.TextSplitter(chunk_size: int = 4000, chunk_overlap: int = 200, length_function: typing.Callable[[str], int] = <built-in function len>)[source]# Interface for splitting text into chunks. async atransform_documents(documents: Sequence[langchain.schema.D...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
01c61c5f8653-2
Transform sequence of documents by splitting them. class langchain.text_splitter.TokenTextSplitter(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any)[source]# Imp...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
88eb8a8384fe-0
.rst .pdf PromptTemplates PromptTemplates# Prompt template classes. pydantic model langchain.prompts.BaseChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt....
https://python.langchain.com/en/latest/reference/modules/prompt.html
88eb8a8384fe-1
file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.ChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt tem...
https://python.langchain.com/en/latest/reference/modules/prompt.html
88eb8a8384fe-2
A list of the names of the variables the prompt template expects. field prefix: str = ''# A prompt template string to put before the examples. field suffix: str [Required]# A prompt template string to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-str...
https://python.langchain.com/en/latest/reference/modules/prompt.html
88eb8a8384fe-3
field suffix: langchain.prompts.base.StringPromptTemplate [Required]# A PromptTemplate to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-string’, ‘jinja2’. field validate_template: bool = True# Whether or not to try validating the template. dict(**kwa...
https://python.langchain.com/en/latest/reference/modules/prompt.html
88eb8a8384fe-4
Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwarg...
https://python.langchain.com/en/latest/reference/modules/prompt.html
88eb8a8384fe-5
Create Chat Messages. langchain.prompts.load_prompt(path: Union[str, pathlib.Path]) → langchain.prompts.base.BasePromptTemplate[source]# Unified method for loading a prompt from LangChainHub or local fs. previous Prompts next Example Selector By Harrison Chase © Copyright 2023, Harrison Chase. Last ...
https://python.langchain.com/en/latest/reference/modules/prompt.html
6833f1fca458-0
.rst .pdf LLMs LLMs# Wrappers on top of large language models APIs. pydantic model langchain.llms.AI21[source]# Wrapper around AI21 large language models. To use, you should have the environment variable AI21_API_KEY set with your API key. Example from langchain.llms import AI21 ai21 = AI21(model="j2-jumbo-instruct") V...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-1
field numResults: int = 1# How many completions to generate for each prompt. field presencePenalty: langchain.llms.ai21.AI21PenaltyData = AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctuations=True, applyToNumbers=True, applyToStopwords=True, applyToEmojis=True)# Penalizes repeated tokens. field temperat...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-2
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-3
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forwar...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-4
If set to a non-None value, control parameters are also applied to similar tokens. field control_log_additive: Optional[bool] = True# True: apply control by adding the log(control_factor) to attention scores. False: (attention_scores - - attention_scores.min(-1)) * control_factor field echo: bool = False# Echo the prom...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-5
field repetition_penalties_include_prompt: Optional[bool] = False# Flag deciding whether presence penalty or frequency penalty are updated from the prompt. field stop_sequences: Optional[List[str]] = None# Stop sequences to use. field temperature: float = 0.0# A non-negative float that tunes the degree of randomness in...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-6
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model# Duplicate a model, optionally...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-7
Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-8
Model name to use. field streaming: bool = False# Whether to stream the results. field temperature: Optional[float] = None# A non-negative float that tunes the degree of randomness in generation. field top_k: Optional[int] = None# Number of most likely tokens to consider at each step. field top_p: Optional[float] = Non...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-9
exclude – fields to exclude from new model, as with values this takes precedence over include update – 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 – set to True to make a deep copy of the model Returns new model instance dict(**kw...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-10
Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) stream(prompt: str, stop: Optional[List[str]] = None) → Generator[source]# Call Anthropic completion_stream and return the resulting generator. BETA: this is a beta feature while we ...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-11
Set of special tokens that are allowed。 field batch_size: int = 20# Batch size to use when passing multiple documents to generate. field best_of: int = 1# Generates best_of completions server-side and returns the “best”. field deployment_name: str = ''# Deployment name to use. field disallowed_special: Union[Literal['a...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-12
Total probability mass of tokens to consider at each step. field verbose: bool [Optional]# Whether to print out response text. __call__(prompt: str, stop: Optional[List[str]] = None) → str# Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) →...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-13
deep – set to True to make a deep copy of the model Returns new model instance create_llm_result(choices: Any, prompts: List[str], token_usage: Dict[str, int]) → langchain.schema.LLMResult# Create the LLMResult from the choices and prompts. dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: L...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-14
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(). max_tokens_for_prompt(prompt: str) → int# Calculate the maximum number of tokens possible to generate for a prompt. Paramet...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-15
for token in generator: yield token classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.Banana[source]# Wrapper around Banana large language models. To use, you should have the banana-dev python package ...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-16
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model# Duplicate a model, optionally...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-17
Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-18
model endpoint to use field model_kwargs: Dict[str, Any] [Optional]# Holds any model parameters valid for create call not explicitly specified. __call__(prompt: str, stop: Optional[List[str]] = None) → str# Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[Lis...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-19
deep – set to True to make a deep copy of the model Returns new model instance dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schem...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-20
classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.Cohere[source]# Wrapper around Cohere large language models. To use, you should have the cohere python package installed, and the environment variable COHE...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-21
Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.sche...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-22
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Take in a list of prompt values and return an LLMResult. get_num_tokens(text: str) → int# Get the number of tokens present in the text. get_num_tokens_f...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-23
To use, you should have the requests python package installed, and the environment variable DEEPINFRA_API_TOKEN set with your API token, or pass it as a named parameter to the constructor. Only supports text-generation and text2text-generation for now. Example from langchain.llms import DeepInfra di = DeepInfra(model_i...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-24
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-25
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forwar...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-26
Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.sche...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-27
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Take in a list of prompt values and return an LLMResult. get_num_tokens(text: str) → int# Get the number of tokens present in the text. get_num_tokens_f...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-28
To use, you should have the pyllamacpp python package installed, the 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, ") Validators ...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-29
A list of strings to stop generation when encountered. field streaming: bool = False# Whether to stream the results or not. field temp: Optional[float] = 0.8# The temperature to use for sampling. field top_k: Optional[int] = 40# The top-k value to use for sampling. field top_p: Optional[float] = 0.95# The top-p value t...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-30
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-31
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forwar...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-32
Model name to use field n: int = 1# How many completions to generate for each prompt. field presence_penalty: float = 0# Penalizes repeated tokens. field temperature: float = 0.7# What sampling temperature to use field top_p: float = 1# Total probability mass of tokens to consider at each step. __call__(prompt: str, st...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-33
exclude – fields to exclude from new model, as with values this takes precedence over include update – 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 – set to True to make a deep copy of the model Returns new model instance dict(**kw...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-34
Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.HuggingFaceEndpoi...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-35
Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Take in a list of prompt values and return an LLMResult. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Crea...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-36
Take in a list of prompt values and return an LLMResult. get_num_tokens(text: str) → int# Get the number of tokens present in the text. get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) → int# Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingInt...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-37
Only supports text-generation and text2text-generation for now. Example from langchain.llms import HuggingFaceHub hf = HuggingFaceHub(repo_id="gpt2", huggingfacehub_api_token="my-api-key") Validators set_callback_manager » callback_manager set_verbose » verbose validate_environment » all fields field model_kwargs: Opti...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-38
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-39
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forwar...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-40
Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.sche...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-41
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. classmethod from_model_id(model_id: str, task: str, device: int = - 1, model_kwargs: Optional[dict] = None, **kwargs: Any) → langchain.llms.base.LLM[source]# Construct the pipeline object from model_id and task. generate(prompts: List[str], stop: Optional[List...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-42
Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.LlamaCpp[source]# Wrapper aroun...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-43
field n_ctx: int = 512# Token context window. field n_parts: int = -1# Number of parts to split the model into. If -1, the number of parts is automatically determined. field n_threads: Optional[int] = None# Number of threads to use. If None, the number of threads is automatically determined. field repeat_penalty: Optio...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-44
Take in a list of prompt values and return an LLMResult. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# 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 Confi...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-45
get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) → int# Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[b...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-46
Holds any model parameters valid for create call not explicitly specified. __call__(prompt: str, stop: Optional[List[str]] = None) → str# Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the give...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-47
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.schema.LLMResult#...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-48
Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.NLPCloud[source]# Wrapper around NLPCloud large language models. To use, you should have the nlpcloud python package installed, and the environment variable NLPCLOUD_API_KEY set with your API key. Example from l...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-49
Remove input text from API response field repetition_penalty: float = 1.0# Penalizes repeated tokens. 1.0 means no penalty. field temperature: float = 0.7# What sampling temperature to use. field top_k: int = 50# The number of highest probability tokens to keep for top-k filtering. field top_p: int = 1# Total probabili...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-50
Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – 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 – set to True to make a deep co...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-51
save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localn...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-52
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 copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclu...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-53
get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) → int# Get the number of tokens in the message. get_sub_prompts(params: Dict[str, Any], prompts: List[str], stop: Optional[List[str]] = None) → List[List[str]]# Get the sub prompts for llm call. json(*, include: Optional[Union[AbstractSetIntStr,...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-54
Prepare the params for streaming. save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) stream(prompt: str, stop: Optional[List[str]] = None) → Generator# Call OpenAI with streaming flag...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-55
Set of special tokens that are allowed。 field disallowed_special: Union[Literal['all'], Collection[str]] = 'all'# Set of special tokens that are not allowed。 field max_retries: int = 6# Maximum number of retries to make when generating. field model_kwargs: Dict[str, Any] [Optional]# Holds any model parameters valid for...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-56
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model# Duplicate a model, optionally...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-57
Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-58
Whether or not to use sampling; use greedy decoding otherwise. field max_length: Optional[int] = None# The maximum length of the sequence to be generated. field max_new_tokens: int = 256# The maximum number of new tokens to generate in the completion. field model_kwargs: Dict[str, Any] [Optional]# Holds any model param...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-59
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model# Duplicate a model, optionally...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-60
Get the number of tokens in the message. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-61
returned in the generation_info field of the Generation object. Example from langchain.llms import PromptLayerOpenAI openai = PromptLayerOpenAI(model_name="text-davinci-003") Validators build_extra » all fields set_callback_manager » callback_manager set_verbose » verbose validate_environment » all fields __call__(prom...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-62
update – 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 – set to True to make a deep copy of the model Returns new model instance create_llm_result(choices: Any, prompts: List[str], token_usage: Dict[str, int]) → langchain.schema.LLM...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-63
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(). max_tokens_for_prompt(prompt: str) → int# Calculate the maximum number of tokens possible to generate for a prompt. Paramet...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-64
for token in generator: yield token classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.PromptLayerOpenAIChat[source]# Wrapper around OpenAI large language models. To use, you should have the openai and ...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-65
Model name to use. field prefix_messages: List [Optional]# Series of messages for Chat input. field streaming: bool = False# Whether to stream the results or not. __call__(prompt: str, stop: Optional[List[str]] = None) → str# Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str],...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-66
deep – set to True to make a deep copy of the model Returns new model instance dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schem...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-67
classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.RWKV[source]# Wrapper around RWKV language models. To use, you should have the rwkv python package installed, the pre-trained model file, and the model’s c...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-68
The top-p value to use for sampling. __call__(prompt: str, stop: Optional[List[str]] = None) → str# Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. async agenerate_pr...
https://python.langchain.com/en/latest/reference/modules/llms.html
6833f1fca458-69
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None) → langchain.schema.LLMResult#...
https://python.langchain.com/en/latest/reference/modules/llms.html