id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
115
c9b7d85f6498-2
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last l...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-3
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-4
field entity_store: langchain.memory.entity.BaseEntityStore [Optional]# field entity_summarization_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['entity', 'summary', 'history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant helping a human kee...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-5
Knowledge graph memory for storing conversation memory. Integrates with external knowledge graph to store and retrieve information about knowledge triples in the conversation. field ai_prefix: str = 'AI'#
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-6
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last l...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-7
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-8
field human_prefix: str = 'Human'# field k: int = 2# field kg: langchain.graphs.networkx_graph.NetworkxEntityGraph [Optional]#
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-9
field knowledge_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template="You are a networked intelligence helping a human track knowledge triples about all relevant people, things, concepts, etc. and integrati...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-10
It's also the number 1 producer of gold in the US.\n\nOutput: (Nevada, is a, state)<|>(Nevada, is in, US)<|>(Nevada, is the number 1 producer of, gold)\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: Hello.\nAI: Hi! How are you?\nPerson #1: I'm good. How are you?\nAI: I'm good too.\nLast line of conversat...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-11
huh. I know Descartes likes to drive antique scooters and play the mandolin.\nOutput: (Descartes, likes to drive, antique scooters)<|>(Descartes, plays, mandolin)\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:", template_f...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-12
field llm: langchain.base_language.BaseLanguageModel [Required]# field summary_message_cls: Type[langchain.schema.BaseMessage] = <class 'langchain.schema.SystemMessage'># Number of previous utterances to include in the context. clear() → None[source]# Clear memory contents. get_current_entities(input_string: str) → Lis...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-13
field memory_key: str = 'history'# field moving_summary_buffer: str = ''# clear() → None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) → Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) → None[source]# Save context from this con...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-14
property buffer: List[langchain.schema.BaseMessage]# String buffer of memory. class langchain.memory.CosmosDBChatMessageHistory(cosmos_endpoint: str, cosmos_database: str, cosmos_container: str, session_id: str, user_id: str, credential: Optional[Any] = None, connection_string: Optional[str] = None, ttl: Optional[int] ...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-15
Append the message to the record in DynamoDB clear() → None[source]# Clear session memory from DynamoDB property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from DynamoDB class langchain.memory.InMemoryEntityStore[source]# Basic in-memory entity store. clear() → None[source]# Delete all entities...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-16
clear() → None[source]# Nothing to clear, got a memory like a vault. load_memory_variables(inputs: Dict[str, Any]) → Dict[str, str][source]# Load memory variables from memory. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) → None[source]# Nothing should be saved or changed property memory_variables: List...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-17
delete(key: str) → None[source]# Delete entity value from store. exists(key: str) → bool[source]# Check if entity exists in store. property full_key_prefix: str# get(key: str, default: Optional[str] = None) → Optional[str][source]# Get entity value from store. key_prefix: str = 'memory_store'# recall_ttl: Optional[int]...
https://python.langchain.com/en/latest/reference/modules/memory.html
c9b7d85f6498-18
field retriever: langchain.vectorstores.base.VectorStoreRetriever [Required]# VectorStoreRetriever object to connect to. field return_docs: bool = False# Whether or not to return the result of querying the database directly. clear() → None[source]# Nothing to clear. load_memory_variables(inputs: Dict[str, Any]) → Dict[...
https://python.langchain.com/en/latest/reference/modules/memory.html
acaa60aeda34-0
.rst .pdf Tools Tools# Core toolkit implementations. pydantic model langchain.tools.AIPluginTool[source]# field api_spec: str [Required]# field args_schema: Type[AIPluginToolSchema] = <class 'langchain.tools.plugin.AIPluginToolSchema'># Pydantic model class to validate and parse the tool’s input arguments. field plugin...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-1
to_typescript() → str[source]# Get typescript string representation of the operation. static ts_type_from_python(type_: Union[str, Type, tuple, None, enum.Enum]) → str[source]# property body_params: List[str]# property path_params: List[str]# property query_params: List[str]# pydantic model langchain.tools.BaseTool[sou...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-2
Run the tool asynchronously. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Any[s...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-3
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Create a copy of a file in a specified location'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'copy_file'# The unique name of the to...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-4
field num_results: int = 4# pydantic model langchain.tools.DuckDuckGoSearchRun[source]# Tool that adds the capability to query the DuckDuckGo search API. field api_wrapper: langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper [Optional]# pydantic model langchain.tools.ExtractHyperlinksTool[source]# Extract ...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-5
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Recursively search for files in a subdirectory that match the regex pattern'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'file_sear...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-6
Tool that adds the capability to ask user for input. field input_func: Callable [Optional]# field prompt_func: Callable[[str], None] [Optional]# pydantic model langchain.tools.IFTTTWebhook[source]# IFTTT Webhook. Parameters name – name of the tool description – description of the tool url – url to hit with the json eve...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-7
Navigate back to the previous page in the browser history. field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Navigate back to the previous page in the browser history'# Used to tell the model how/when/...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-8
REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. field jsonSchemaDialect: Optional[str] = None# The default value for the $schema keyword within [Schema Objects](#schemaObject) contained within this OAS document. This MUST be in the form of a URI. field openapi: str = '3.1.0'#...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-9
A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools’ logic. ...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-10
Get an OpenAPI spec from a URL. static get_cleaned_operation_id(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation, path: str, method: str) → str[source]# Get a cleaned operation id from an operation id. get_methods_for_path(path: str) → List[str][source]# Return a list of valid methods for the specified ...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-11
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Read file from disk'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'read_file'# The unique name of the tool that clearly communicates...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-12
The function to run when the tool is called. classmethod from_function(func: Callable, name: Optional[str] = None, description: Optional[str] = None, return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, infer_schema: bool = True, **kwargs: Any) → langchain.tools.base.StructuredTool[...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-13
field verbose: bool = False# Whether to log the tool’s progress. classmethod from_function(func: Callable, name: str, description: str, return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, **kwargs: Any) → langchain.tools.base.Tool[source]# Initialize tool from a function. property ...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-14
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Write file to disk'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'write_file'# The unique name of the tool that clearly communicates...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-15
(the set api_key must be associated with the action owner) instructions – a natural language instruction string for using the action (eg. “get the latest email from Mike Knoop” for “Gmail: find email” action) params – a dict, optional. Any params provided will override AI guesses from instructions (see “understanding t...
https://python.langchain.com/en/latest/reference/modules/tools.html
acaa60aeda34-16
return previous Agents next Agent Toolkits By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https://python.langchain.com/en/latest/reference/modules/tools.html
c31a3c84efc8-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
c31a3c84efc8-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
c31a3c84efc8-2
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, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-3
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
c31a3c84efc8-4
Validators raise_deprecation » all fields set_verbose » verbose validate_environment » all fields field aleph_alpha_api_key: Optional[str] = None# API key for Aleph Alpha API. field best_of: Optional[int] = None# returns the one with the “best of” results (highest log probability per token) field completion_bias_exclus...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-5
field penalty_bias: Optional[str] = None# Penalty bias for the completion. field penalty_exceptions: Optional[List[str]] = None# List of strings that may be generated without penalty, regardless of other penalty settings field penalty_exceptions_include_stop_sequences: Optional[bool] = None# Should stop_sequences be in...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-6
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-7
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-8
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.Anthropic[source]# Wrapper arou...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-9
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-10
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-11
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 figure out the...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-12
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
c31a3c84efc8-13
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], langchain.callbacks.base.BaseCallbackManager]] = None) → st...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-14
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
c31a3c84efc8-15
Get the sub prompts for llm call. 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: b...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-16
.. code-block:: python llm.save(file_path=”path/llm.yaml”) stream(prompt: str, stop: Optional[List[str]] = None) → Generator# Call OpenAI with streaming flag and return the resulting generator. BETA: this is a beta feature while we figure out the right abstraction. Once that happens, this interface could change. Parame...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-17
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-18
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-19
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.CerebriumAI[source]# Wrapper ar...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-20
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-21
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-22
Wrapper around Cohere large language models. To use, you should have the cohere python package installed, and the environment variable COHERE_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example from langchain.llms import Cohere cohere = Cohere(model="gptd-instruct-tft", cohere_api...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-23
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-24
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-25
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.DeepInfra[source]# Wrapper arou...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-26
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
c31a3c84efc8-27
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
c31a3c84efc8-28
Validators raise_deprecation » all fields set_verbose » verbose validate_environment » all fields field base_url: Optional[str] = None# Base url to use, if None decides based on model name. field endpoint_url: str = ''# Model name to use. field length: int = 256# The maximum number of tokens to generate in the completi...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-29
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
c31a3c84efc8-30
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, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-31
# Simplest invocation response = model("Once upon a time, ") Validators raise_deprecation » all fields set_verbose » verbose validate_environment » all fields field echo: Optional[bool] = False# Whether to echo the prompt. field embedding: bool = False# Use embedding mode only. field f16_kv: bool = False# Use half-prec...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-32
field top_p: Optional[float] = 0.95# The top-p value to use for sampling. field use_mlock: bool = False# Force system to keep model in RAM. field vocab_only: bool = False# Only load the vocabulary, no weights. __call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.bas...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-33
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
c31a3c84efc8-34
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
c31a3c84efc8-35
field temperature: float = 0.7# Run inference with this temperature. Must by in the closed interval [0.0, 1.0]. field top_k: Optional[int] = None# Decode using top-k sampling: consider the set of top_k most probable tokens. Must be positive. field top_p: Optional[float] = None# Decode using nucleus sampling: consider t...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-36
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, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-37
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
c31a3c84efc8-38
field logit_bias: Optional[Dict[str, float]] [Optional]# Adjust the probability of specific tokens being generated. field max_tokens: int = 256# The maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the models maximal context size. field min_tokens: int =...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-39
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-40
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-41
pydantic model langchain.llms.HuggingFaceEndpoint[source]# Wrapper around HuggingFaceHub Inference Endpoints. To use, you should have the huggingface_hub python package installed, and the environment variable HUGGINGFACEHUB_API_TOKEN set with your API token, or pass it as a named parameter to the constructor. Only supp...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-42
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-43
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-44
pydantic model langchain.llms.HuggingFaceHub[source]# Wrapper around HuggingFaceHub models. To use, you should have the huggingface_hub python package installed, and the environment variable HUGGINGFACEHUB_API_TOKEN set with your API token, or pass it as a named parameter to the constructor. Only supports text-generat...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-45
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
c31a3c84efc8-46
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
c31a3c84efc8-47
model_id="gpt2", task="text-generation" ) Example passing pipeline in directly:from langchain.llms import HuggingFacePipeline from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline model_id = "gpt2" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-48
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
c31a3c84efc8-49
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-50
Wrapper around the 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: abetlen/llama-cpp-python Example from langchain.llms import LlamaCppEmbeddings llm = LlamaCppEmbeddings(model_path="/path/to/lla...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-51
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: Optional[float] = 1.1# The penalty to apply to repe...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-52
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-53
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-54
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, run_manager: Optional[langchain.callbacks.manager.CallbackManagerForLLMRun] = None) → Generator[Dict, None, None][source]# Yields results obje...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-55
Any parameters that are valid to be passed to the call can be passed in, even if not explicitly saved on this class. Example Validators build_extra » all fields raise_deprecation » all fields set_verbose » verbose field endpoint_url: str = ''# model endpoint to use field model_kwargs: Dict[str, Any] [Optional]# Holds a...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-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
c31a3c84efc8-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
c31a3c84efc8-58
field do_sample: bool = True# Whether to use sampling (True) or greedy decoding. field early_stopping: bool = False# Whether to stop beam search at num_beams sentences. field length_no_input: bool = True# Whether min_length and max_length should include the length of the input. field length_penalty: float = 1.0# Expone...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-59
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-60
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-61
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.OpenAI[source]# Wrapper around ...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-62
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-63
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://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-64
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. Parameters prompt – The prompt to pass into the model. Returns The maximum number of tokens to ge...
https://python.langchain.com/en/latest/reference/modules/llms.html
c31a3c84efc8-65
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.OpenAIChat[source]# Wrapper around OpenAI Chat large language models. To use, you should have the openai python package installed, and the envi...
https://python.langchain.com/en/latest/reference/modules/llms.html