id
stringlengths
14
15
text
stringlengths
101
5.26k
source
stringlengths
57
120
a0c062c47ffd-2
> Finished chain. Memory: Add State to Chains and Agents# So far, all the chains and agents we’ve gone through have been stateless. But often, you may want a chain or agent to have some concept of “memory” so that it may remember information about its previous interactions. The clearest and simple example of this is wh...
https://langchain.readthedocs.io/en/latest/getting_started/getting_started.html
a0c062c47ffd-3
], ] result = chat.generate(batch_messages) result # -> LLMResult(generations=[[ChatGeneration(text="J'aime programmer.", generation_info=None, message=AIMessage(content="J'aime programmer.", additional_kwargs={}))], [ChatGeneration(text="J'aime l'intelligence artificielle.", generation_info=None, message=AIMessage(con...
https://langchain.readthedocs.io/en/latest/getting_started/getting_started.html
a0c062c47ffd-4
Action: { "action": "Search", "action_input": "Olivia Wilde boyfriend" } Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating s...
https://langchain.readthedocs.io/en/latest/getting_started/getting_started.html
916b6f2ad712-0
.md .pdf Tutorials Contents DeepLearning.AI course Handbook Tutorials Tutorials# ⛓ icon marks a new addition [last update 2023-05-15] DeepLearning.AI course# ⛓LangChain for LLM Application Development by Harrison Chase presented by Andrew Ng Handbook# LangChain AI Handbook By James Briggs and Francisco Ingham Tutoria...
https://langchain.readthedocs.io/en/latest/getting_started/tutorials.html
916b6f2ad712-1
# LangChain by Chat with data LangChain Beginner’s Tutorial for Typescript/Javascript GPT-4 Tutorial: How to Chat With Multiple PDF Files (~1000 pages of Tesla’s 10-K Annual Reports) GPT-4 & LangChain Tutorial: How to Chat With A 56-Page PDF Document (w/Pinecone) ⛓ LangChain & Supabase Tutorial: How to Build a ChatGPT ...
https://langchain.readthedocs.io/en/latest/getting_started/tutorials.html
a3931eab5795-0
.md .pdf Concepts Contents Chain of Thought Action Plan Generation ReAct Self-ask Prompt Chaining Memetic Proxy Self Consistency Inception MemPrompt Concepts# These are concepts and terminology commonly used when developing LLM applications. It contains reference to external papers or sources where the concept was fi...
https://langchain.readthedocs.io/en/latest/getting_started/concepts.html
7c050749d7c0-0
.md .pdf Installation Contents Official Releases Installing from source Installation# Official Releases# LangChain is available on PyPi, so to it is easily installable with: pip install langchain That will install the bare minimum requirements of LangChain. A lot of the value of LangChain comes when integrating it wi...
https://langchain.readthedocs.io/en/latest/reference/installation.html
4d4ae6790163-0
.rst .pdf Models Models# LangChain provides interfaces and integrations for a number of different types of models. LLMs Chat Models Embeddings previous API References next Chat Models By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/reference/models.html
0d193454d9a8-0
.rst .pdf Prompts Prompts# The reference guides here all relate to objects for working with Prompts. PromptTemplates Example Selector Output Parsers previous How to serialize prompts next PromptTemplates By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/reference/prompts.html
d6de872c0718-0
.rst .pdf Indexes Indexes# Indexes refer to ways to structure documents so that LLMs can best interact with them. LangChain has a number of modules that help you load, structure, store, and retrieve documents. Docstore Text Splitter Document Loaders Vector Stores Retrievers Document Compressors Document Transformers pr...
https://langchain.readthedocs.io/en/latest/reference/indexes.html
27aea6a4ff0f-0
.rst .pdf Agents Agents# Reference guide for Agents and associated abstractions. Agents Tools Agent Toolkits previous Memory next Agents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/reference/agents.html
e00d5fd22af8-0
.rst .pdf Output Parsers Output Parsers# pydantic model langchain.output_parsers.CommaSeparatedListOutputParser[source]# Parse out comma separated lists. get_format_instructions() → str[source]# Instructions on how the LLM output should be formatted. parse(text: str) → List[str][source]# Parse the output of an LLM call...
https://langchain.readthedocs.io/en/latest/reference/modules/output_parsers.html
e00d5fd22af8-1
parse(text: str) → Dict[str, str][source]# Parse the output of an LLM call. pydantic model langchain.output_parsers.RegexParser[source]# Class to parse the output into a dictionary. field default_output_key: Optional[str] = None# field output_keys: List[str] [Required]# field regex: str [Required]# parse(text: str) → D...
https://langchain.readthedocs.io/en/latest/reference/modules/output_parsers.html
e00d5fd22af8-2
Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so. Parameters completion – output of language model prompt – prompt value Returns structured output py...
https://langchain.readthedocs.io/en/latest/reference/modules/output_parsers.html
d548198f9a02-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://langchain.readthedocs.io/en/latest/reference/modules/example_selector.html
da5e8b5b7a2a-0
.rst .pdf Vector Stores Vector Stores# Wrappers on top of vector stores. class langchain.vectorstores.AnalyticDB(connection_string: str, embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'langchain', collection_metadata: Optional[dict] = None, pre_delete_collection: bool = False, logger: ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-1
k – Number of Documents to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, filter: Optional[dict] = None) → List[Tuple[langch...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-2
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. fetch_k – Number of Documents to fetch to pass to MMR algorithm. lambda_mult – Number between 0 and 1 that deter...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-3
k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1) → List[Tuple[lang...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-4
Parameters texts (List[str]) – The list of texts to ingest. name (str) – Name of the project to create. api_key (str) – Your nomic API key, embedding (Optional[Embeddings]) – Embedding function. Defaults to None. metadatas (Optional[List[dict]]) – List of metadatas. Defaults to None. ids (Optional[List[str]]) – Optiona...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-5
collection_name (str) – Name of the collection to create. persist_directory (Optional[str]) – Directory to persist the collection. embedding (Optional[Embeddings]) – Embedding function. Defaults to None. metadatas (Optional[List[dict]]) – List of metadatas. Defaults to None. ids (Optional[List[str]]) – List of document...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-6
Returns List of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. Return type List[Tuple[Document, float]] update_document(document_id: str, document: langchain.schema.Document) → None[source]# Update a document in the collection. Parameters document...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-7
Perform a similarity search with ClickHouse Parameters query (str) – query string k (int, optional) – Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional) – where condition string. Defaults to None. NOTE – Please do not let end-user to fill this and always be aware of SQL injection. When deal...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-8
}, "index_type": { "title": "Index Type", "default": "annoy", "env_names": "{'clickhouse_index_type'}", "type": "string" }, "index_param": { "title": "Index Param", "default": [ 100, "'L2Distance'" ], "env_...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-9
embeddings = OpenAIEmbeddings() vectorstore = DeepLake("langchain_store", embeddings.embed_query) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any) → List[str][source]# Run more texts through the embeddings and add to the vectorstore. Parameters text...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-10
fetch_k – Number of Documents to fetch to pass to MMR algorithm. lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. persist...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-11
connections in the graph. Defaults to 16. allow_replace_deleted (bool) – Enables replacing of deleted elements with new added ones. Defaults to True. num_threads (int) – Sets the number of cpu threads to use. Defaults to 1. **kwargs – Other keyword arguments to be passed to the get_doc_cls method. classmethod from_text...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-12
Locate the “elastic” user and click “Edit” Click “Reset password” Follow the prompts to reset the password The format for Elastic Cloud URLs is https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243. Example from langchain import ElasticVectorSearch from langchain.embeddings import OpenAIEmbeddings embeddi...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-13
Parameters text_embeddings – Iterable pairs of string and embedding to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. ids – Optional list of unique IDs. Returns List of ids from adding the texts into the vectorstore. add_texts(texts: Iterable[str], metadatas: Optional[List[dic...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-14
merge_from(target: langchain.vectorstores.faiss.FAISS) → None[source]# Merge another FAISS object with the current one. Add the target FAISS to the current one. Parameters target – FAISS object you wish to merge into the current one Returns None. save_local(folder_path: str, index_name: str = 'index') → None[source]# S...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-15
documents will be stored in GCS. An existing Index and corresponding Endpoint are preconditions for using this module. See usage in docs/modules/indexes/vectorstores/examples/matchingengine.ipynb Note that this implementation is mostly meant for reading if you are planning to do a real time implementation. While readin...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-16
Returns The resulting keys for each inserted element. Return type List[str] classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {'host': 'localhost', 'password': ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-17
Perform a similarity search against the query string. Parameters query (str) – The text to search. k (int, optional) – How many results to return. Defaults to 4. param (dict, optional) – The search params for the index type. Defaults to None. expr (str, optional) – Filtering expression. Defaults to None. timeout (int, ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-18
vectorstore = MongoDBAtlasVectorSearch(collection, embeddings) add_texts(texts: Iterable[str], metadatas: Optional[List[Dict[str, Any]]] = None, **kwargs: Any) → List[source]# Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings to add to the vectorstore. metadatas – ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-19
Helper function: Drop data escape_str(value: str) → str[source]# classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[Dict[Any, Any]]] = None, config: Optional[langchain.vectorstores.myscale.MyScaleSettings] = None, text_ids: Optional[Iterable[str]] = None, ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-20
column_map (Dict)Column type map to project column name onto langchainsemantics. Must have keys: text, id, vector, must be same size to number of columns. For example: .. code-block:: python {‘id’: ‘text_id’, ‘vector’: ‘text_embedding’, ‘text’: ‘text_plain’, ‘metadata’: ‘metadata_dictionary_in_json’, } Defaults to iden...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-21
Fields column_map (Dict[str, str]) database (str) host (str) index_param (Optional[Dict[str, str]]) index_type (str) metric (str) password (Optional[str]) port (int) table (str) username (Optional[str]) field column_map: Dict[str, str] = {'id': 'id', 'metadata': 'metadata', 'text': 'text', 'vector': 'vector'}# field da...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-22
to “text”. metadata_field: Document field that metadata is stored in. Defaults to “metadata”. Can be set to a special value “*” to include the entire document. Optional Args for Approximate Search:search_type: “approximate_search”; default: “approximate_search” boolean_filter: A Boolean filter consists of a Boolean que...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-23
embeddings = OpenAIEmbeddings() pinecone = Pinecone.from_texts( texts, embeddings, index_name="langchain-demo" ) similarity_search(query: str, k: int = 4, filter: Optional[dict] = None, namespace: Optional[str] = None, **kwargs: Any) → List[langchain.schema.Document][source]# Return pinecone documents most ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-24
grpc_port – Port of the gRPC interface. Default: 6334 prefer_grpc – If true - use gPRC interface whenever possible in custom methods. Default: False https – If true - use HTTPS(SSL) protocol. Default: None api_key – API key for authentication in Qdrant Cloud. Default: None prefix – If not None - add prefix to the REST ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-25
embeddings = OpenAIEmbeddings() vectorstore = Redis( redis_url="redis://username:password@localhost:6379" index_name="my-index", embedding_function=embeddings.embed_query, ) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, embeddings: Optional[List[List[float]]] = None, keys: Optional...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-26
similarity (Because the similarity calculation algorithm is based on cosine) – :param : :param the smaller the angle: :param the higher the similarity.: Returns A list of documents that are most similar to the query text, including the match score for each document. Return type List[Document] Note If there are no docu...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-27
This class serves as a Pythonic interface to the SingleStore DB database. The prerequisite for using this class is the installation of the singlestoredb Python package. The SingleStoreDB vectorstore can be created by providing an embedding function and the relevant parameters for the database connection, connection poo...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-28
classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, client: Optional[supabase.client.Client] = None, table_name: Optional[str] = 'documents', query_name: Union[str, None] = 'match_documents', **kwargs: Any) → SupabaseVectorStore[source]# Return VectorStore initialized...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-29
Returns List of Tuples of (doc, similarity_score) table_name: str# class langchain.vectorstores.Tair(embedding_function: langchain.embeddings.base.Embeddings, url: str, index_name: str, content_key: str = 'content', metadata_key: str = 'metadata', search_params: Optional[dict] = None, **kwargs: Any)[source]# add_texts(...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-30
Return type List[Tuple[Document, float]] class langchain.vectorstores.Typesense(typesense_client: Client, embedding: Embeddings, *, typesense_collection_name: Optional[str] = None, text_key: str = 'text')[source]# Wrapper around Typesense vector search. To use, you should have the typesense python package installed. Ex...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-31
vectara_api_key=vectara_api_key ) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str][source]# Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associa...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-32
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → langchain.vectorstores.base.VST[source]# Return VectorStore initialized from texts and embeddings. async...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-33
Return docs most similar to embedding vector. Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query vector. similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[langch...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
da5e8b5b7a2a-34
Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query. similarity_search_by_text(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most ...
https://langchain.readthedocs.io/en/latest/reference/modules/vectorstores.html
03890c24ea5c-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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-1
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(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler]...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-2
field maximum_tokens: int = 64# The maximum number of tokens to be generated. field minimum_tokens: Optional[int] = 0# Generate at least this number of tokens. field model: Optional[str] = 'luminous-base'# Model name to use. field n: int = 1# How many completions to generate for each prompt. field penalty_bias: Optiona...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-3
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a list of p...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-4
Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a li...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-5
Example prompt = "Write a poem about a stream." prompt = f"\n\nHuman: {prompt}\n\nAssistant:" generator = anthropic.stream(prompt) 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...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-6
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. get_token_ids(text: str) → List[int]# Get the token present in the text. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-7
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-8
-1 returns as many tokens as possible given the prompt and the models maximal context size. field model_kwargs: Dict[str, Any] [Optional]# Holds any model parameters valid for create call not explicitly specified. field model_name: str = 'text-davinci-003' (alias 'model')# Model name to use. field n: int = 1# How many ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-9
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. get_token_ids(text: str) → List[int]# Get the token IDs using the tiktoken package. json(*, include: Optional[Union[AbstractSetIntSt...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-10
Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a li...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-11
and BEAM_CLIENT_SECRET set with your client secret. Information on how to get these is available here: https://docs.beam.cloud/account/api-keys. The wrapper can then be called as follows, where the name, cpu, memory, gpu, python version, and python packages can be updated accordingly. Once deployed, the instance can be...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-12
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. get_token_ids(text: str) → List[int]# Get the token present in the text. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-13
Predict text from text. async apredict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from messages. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Creates a new model setting __dict__ a...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-14
field model: str [Required]# The path to a model file or directory or the name of a Hugging Face Hub model repo. field model_file: Optional[str] = None# The name of the model file in repo or directory. field model_type: Optional[str] = None# The model type. field verbose: bool [Optional]# Whether to print out response ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-15
Predict text from text. predict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from messages. save(file_path: Union[pathlib.Path, str]) → None# Save the LLM. Parameters file_path – Path to file to save the LLM to. Example: ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-16
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. get_token_ids(text: str) → List[int]# Get the token present i...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-17
Predict text from text. async apredict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from messages. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Creates a new model setting __dict__ a...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-18
One can load an LLM on a Databricks interactive cluster and start a local HTTP server on the driver node to serve the model at / using HTTP POST method with JSON input/output. Please use a port number between [3000, 8000] and let the server listen to the driver IP address or simply 0.0.0.0 instead of localhost only. To...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-19
Predict text from text. async apredict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from messages. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Creates a new model setting __dict__ a...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-20
field verbose: bool [Optional]# Whether to print out response text. __call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → str# Check Cache and run the LLM on the given prompt and inpu...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-21
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.FakeListLLM[source]# Fake LLM w...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-22
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(). predict(text: str, *, stop: Optional[Sequence[str]] = None) → str# Predict text from text. predict_messages(messages: List[...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-23
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt an...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-24
field stop: Optional[List[str]] = []# 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: Opt...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-25
Get the token present in the text. 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_none: ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-26
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-27
What sampling temperature to use field top_p: float = 1# 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, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], la...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-28
Predict message from messages. 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 ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-29
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a list of p...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-30
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-31
field model_id: str = 'gpt2'# Model name to use. field model_kwargs: Optional[dict] = None# Key word arguments passed to the model. field pipeline_kwargs: Optional[dict] = None# Key word arguments passed to the pipeline. field verbose: bool [Optional]# Whether to print out response text. __call__(prompt: str, stop: Opt...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-32
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(). predict(text: str, *, stop: Optional[Sequence[str]] = None) → str# Predict text from text. predict_messages(messages: List[...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-33
Returns new model instance dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Run the...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-34
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-35
field lora_path: Optional[str] = None# The path to the Llama LoRA. If None, no LoRa is loaded. field max_tokens: Optional[int] = 256# The maximum number of tokens to generate. field model_path: str [Required]# The path to the Llama model file. field n_batch: Optional[int] = 8# Number of tokens to process in parallel. S...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-36
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt an...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-37
field verbose: bool [Optional]# Whether to print out response text. __call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → str# Check Cache and run the LLM on the given prompt and inpu...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-38
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.MosaicML[source]# Wrapper aroun...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-39
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. get_token_ids(text: str) → List[int]# Get the token present i...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-40
Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a li...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-41
Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved on this class. Example from langchain.llms import OpenAI openai = OpenAI(model_name="text-davinci-003") Validators build_extra » all fields raise_deprecation » all fields set_verbose » verbose validate_en...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-42
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-43
environment variable OPENAI_API_KEY set with your API key. Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved on this class. Example from langchain.llms import OpenAIChat openaichat = OpenAIChat(model_name="gpt-3.5-turbo") Validators build_extra » all fie...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-44
Get the number of tokens in the message. get_token_ids(text: str) → List[int][source]# Get the token IDs using the tiktoken package. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-45
Take in a list of prompt values and return an LLMResult. async apredict(text: str, *, stop: Optional[Sequence[str]] = None) → str# Predict text from text. async apredict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from m...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-46
Predict message from messages. prep_streaming_params(stop: Optional[List[str]] = None) → Dict[str, Any]# 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....
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-47
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-48
Check Cache and run the LLM on the given prompt and input. async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Run the LLM on the given pro...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-49
Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.PredictionGuard[source]# Wrapper around Prediction Guard large language models. To use, you should have the predictionguard python package installed, and the environment variable PREDICTIONGUARD_TOKEN set with y...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html