id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
115
ad57987e20ef-50
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
ad57987e20ef-51
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
ad57987e20ef-52
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
ad57987e20ef-53
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
ad57987e20ef-54
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
ad57987e20ef-55
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
ad57987e20ef-56
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
ad57987e20ef-57
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
ad57987e20ef-58
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
ad57987e20ef-59
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
ad57987e20ef-60
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
ad57987e20ef-61
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
ad57987e20ef-62
field pipeline_kwargs: Dict[str, Any] [Optional]# Holds any pipeline 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) ...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-63
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.schema.PromptValue], stop: Optional[List[str]] = None) β†’ ...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-64
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://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-65
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
ad57987e20ef-66
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
ad57987e20ef-67
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
ad57987e20ef-68
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
ad57987e20ef-69
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
ad57987e20ef-70
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
ad57987e20ef-71
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
ad57987e20ef-72
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
ad57987e20ef-73
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
ad57987e20ef-74
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
ad57987e20ef-75
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
ad57987e20ef-76
Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.Replicate[source]# Wrapper around Replicate models. To use, you should have the replicate python package installed, and the environment variable REPLICATE_API_TOKEN set with your API token. You can find your tok...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-77
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
ad57987e20ef-78
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
ad57987e20ef-79
Make sure the credentials / roles used have the required policies to access the Sagemaker endpoint. See: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html Validators set_callback_manager Β» callback_manager set_verbose Β» verbose validate_environment Β» all fields field content_handler: langchain.llms....
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-80
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
ad57987e20ef-81
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
ad57987e20ef-82
like Paperspace, Coreweave, etc.). To use, you should have the runhouse python package installed. Only supports text-generation and text2text-generation for now. Example using from_model_id:from langchain.llms import SelfHostedHuggingFaceLLM import runhouse as rh gpu = rh.cluster(name="rh-a10x", instance_type="A100:1")...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-83
field model_id: str = 'gpt2'# Hugging Face model_id to load the model. field model_kwargs: Optional[dict] = None# Key word arguments to pass to the model. field model_load_fn: Callable = <function _load_transformer># Function to load the model remotely on the server. field model_reqs: List[str] = ['./', 'transformers',...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-84
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
ad57987e20ef-85
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
ad57987e20ef-86
import runhouse as rh def load_pipeline(): tokenizer = AutoTokenizer.from_pretrained("gpt2") model = AutoModelForCausalLM.from_pretrained("gpt2") return pipeline( "text-generation", model=model, tokenizer=tokenizer, max_new_tokens=10 ) def inference_fn(pipeline, prompt, stop = None): ...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-87
field hardware: Any = None# Remote hardware to send the inference function to. field inference_fn: Callable = <function _generate_text># Inference function to send to the remote hardware. field load_fn_kwargs: Optional[dict] = None# Key word arguments to pass to the model load function. field model_load_fn: Callable [R...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-88
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
ad57987e20ef-89
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
ad57987e20ef-90
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
ad57987e20ef-91
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
ad57987e20ef-92
Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.Writer[source]# Wrapper around Writer large language models. To use, you should have the environment variable WRITER_API_KEY set with your API key. Example from langchain import Writer writer = Writer(model_id="...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-93
Penalizes repeated tokens according to frequency. field stop: Optional[List[str]] = None# Sequences when completion generation will stop field temperature: float = 1.0# What sampling temperature to use. field tokens_to_generate: int = 24# Max number of tokens to generate. field top_k: int = 1# The number of highest pro...
https://python.langchain.com/en/latest/reference/modules/llms.html
ad57987e20ef-94
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
ad57987e20ef-95
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
c8659f94f92c-0
.rst .pdf Agents Agents# Interface for agents. pydantic model langchain.agents.Agent[source]# Class responsible for calling the language model and deciding the action. This is driven by an LLMChain. The prompt in the LLMChain MUST include a variable called β€œagent_scratchpad” where the agent can put its intermediary wor...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-1
Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) β†’ Union[langchain.schema.AgentAction, langchain.schema.AgentFinish][source]# Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken t...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-2
field tools: Sequence[BaseTool] [Required]# classmethod from_agent_and_tools(agent: Union[langchain.agents.agent.BaseSingleActionAgent, langchain.agents.agent.BaseMultiActionAgent], tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, **kwargs:...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-3
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations **kwargs – User inputs. Returns Actions specifying what tool to use. dict(**kwargs: Any) β†’ Dict[source]# Return dictionary representation of agent. get_allowed_tools() β†’ Optional[List[str]][source]#...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-4
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations **kwargs – User inputs. Returns Action specifying what tool to use. dict(**kwargs: Any) β†’ Dict[source]# Return dictionary representation of agent. classmethod from_llm_and_tools(llm: langchain.schem...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-5
pydantic model langchain.agents.ConversationalAgent[source]# An agent designed to hold a conversation in addition to using tools. field ai_prefix: str = 'AI'# field output_parser: langchain.agents.agent.AgentOutputParser [Optional]#
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-6
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-7
powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the follo...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-8
'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None) β†’ langchain.prompts.prompt.PromptTemplate[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-9
Create prompt in the style of the zero shot agent. Parameters tools – List of tools the agent will have access to, used to format the prompt. prefix – String to put before the list of tools. suffix – String to put after the list of tools. ai_prefix – String to use before AI output. human_prefix – String to use before h...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-10
classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix: str = 'Assistant is a large language ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-11
receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-12
the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix: str = 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None, **kwargs: Any) β†’ langchain.agents.agent.Agent[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-13
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.ConversationalChatAgent[source]# An agent designed to hold a conversation in addition to using tools. field out...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-14
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], system_message: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide r...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-15
classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, system_message: str = 'Assistant is a large l...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-16
receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-17
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.LLMSingleActionAgent[source]# field llm_chain: langchain.chains.llm.LLMChain [Required]# field output_parser: l...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-18
Validators set_callback_manager Β» callback_manager set_verbose Β» verbose validate_return_direct_tool Β» all fields validate_tools Β» all fields field agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]# field callback_manager: BaseCallbackManager [Optional]# field early_stopping_method: str = 'force'# fi...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-19
action_name="Calculator", action=llm_math_chain.run, action_description="useful for doing math" ) ] mrkl = MRKLChain.from_chains(llm, chains) pydantic model langchain.agents.ReActChain[source]# Chain that implements the ReAct paper. Example from langchain import ReActChain, OpenAI react = ReAct(llm=...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-20
Validators set_callback_manager Β» callback_manager set_verbose Β» verbose validate_return_direct_tool Β» all fields validate_tools Β» all fields field agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required]# field callback_manager: BaseCallbackManager [Optional]# field early_stopping_method: str = 'force'# fi...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-21
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Answer the following questions as best you can. You have access to the following tools:', suffix: str = 'Begin!\n\nQuestion: {input}\nThought:{agent_scratchp...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-22
Returns A PromptTemplate with the template assembled from the pieces here. classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.age...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-23
langchain.agents.create_json_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.json.toolkit.JsonToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with JSON.\nYour goal is to return a final answer ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-24
cannot use it.\nYou should only add one key at a time to the path. You cannot add multiple keys at once.\nIf you encounter a "KeyError", go back to the previous key, look at the available keys, and try again.\n\nIf the question does not seem to be related to the JSON, just return "I don\'t know" as the answer.\nAlways ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-25
= 'Begin!"\n\nQuestion: {input}\nThought: I should look at the keys that exist in data to see what I have access to\n{agent_scratchpad}', format_instructions: str = 'Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-26
Construct a json agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-27
langchain.agents.create_openapi_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = "You are an agent designed to answer questions by making web requests to an API ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-28
which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.\n\nUse the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.\nIf you get a not found error, ensure that you are using a path that ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-29
None, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', verbose: bool = False, return_intermediate_steps: bool = False, **kwargs: Any) β†’ langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-30
Construct a json agent from an LLM and tools. langchain.agents.create_pandas_dataframe_agent(llm: langchain.llms.base.BaseLLM, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = '\nYou are working with a pandas dataframe in Python. The name of the dataframe is `df`.\...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-31
langchain.agents.create_pbi_agent(llm: langchain.llms.base.BaseLLM, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-32
should first ask which tables I have, then how each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a nice sentence that answers the question. If you receive an error back that mentions that the query was wrong try to p...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-33
what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input questio...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-34
Construct a pbi agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-35
langchain.agents.create_pbi_chat_agent(llm: langchain.chat_models.base.BaseChatModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-36
of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. \n\nGiven an input question, create a syntactically correct DAX query to run, then look at the results of the q...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-37
tool to create a query for me and then I should ask the query tool to execute it, finally create a complete sentence that answers the question. If you receive an error back that mentions that the query was wrong try to phrase the question differently and get a new query from the question to query tool.\n', suffix: str ...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-38
Construct a pbi agent from an Chat LLM and tools. If you supply only a toolkit and no powerbi dataset, the same LLM is used for both.
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-39
langchain.agents.create_sql_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with a SQL database.\nGiven an input question...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-40
rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the databas...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-41
str = 'force', verbose: bool = False, **kwargs: Any) β†’ langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-42
Construct a sql agent from an LLM and tools. langchain.agents.create_vectorstore_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent desig...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-43
Get a list of all possible tool names. langchain.agents.initialize_agent(tools: Sequence[langchain.tools.base.BaseTool], llm: langchain.schema.BaseLanguageModel, agent: Optional[langchain.agents.agent_types.AgentType] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, agent_path: O...
https://python.langchain.com/en/latest/reference/modules/agents.html
c8659f94f92c-44
llm – Optional language model, may be needed to initialize certain tools. callback_manager – Optional callback manager. If not provided, default global callback manager will be used. Returns List of tools. langchain.agents.tool(*args: Union[str, Callable], return_direct: bool = False, args_schema: Optional[Type[pydanti...
https://python.langchain.com/en/latest/reference/modules/agents.html
0e37f39b8177-0
.rst .pdf Experimental Modules Contents Autonomous Agents Generative Agents Experimental Modules# This module contains experimental modules and reproductions of existing work using LangChain primitives. Autonomous Agents# Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module. class ...
https://python.langchain.com/en/latest/reference/modules/experimental.html
0e37f39b8177-1
property output_keys: List[str]# Output keys this chain expects. prioritize_tasks(this_task_id: int, objective: str) β†’ List[Dict][source]# Prioritize tasks. class langchain.experimental.AutoGPT(ai_name: str, memory: langchain.vectorstores.base.VectorStoreRetriever, chain: langchain.chains.llm.LLMChain, output_parser: l...
https://python.langchain.com/en/latest/reference/modules/experimental.html
0e37f39b8177-2
React to a given observation. get_full_header(force_refresh: bool = False) β†’ str[source]# Return a full header of the agent’s status, summary, and current time. get_summary(force_refresh: bool = False) β†’ str[source]# Return a descriptive summary of the agent. field last_refreshed: datetime.datetime [Optional]# The last...
https://python.langchain.com/en/latest/reference/modules/experimental.html
0e37f39b8177-3
field traits: str = 'N/A'# Permanent traits to ascribe to the character. class langchain.experimental.GenerativeAgentMemory(*, llm: langchain.schema.BaseLanguageModel, memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever, verbose: bool = False, reflection_threshold: Optional[f...
https://python.langchain.com/en/latest/reference/modules/experimental.html
0e37f39b8177-4
Return key-value pairs given the text input to the chain. field memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever [Required]# The retriever to fetch related memories. property memory_variables: List[str]# Input keys this memory class will load dynamically. pause_to_reflect(...
https://python.langchain.com/en/latest/reference/modules/experimental.html
e256c4b00fa3-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
aa069beb2523-0
.rst .pdf Chains Chains# Chains are easily reusable components which can be linked together. pydantic model langchain.chains.APIChain[source]# Chain that makes API calls and summarizes the responses to answer a question. Validators set_callback_manager Β» callback_manager set_verbose Β» verbose validate_api_answer_prompt...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-1
field requests_wrapper: TextRequestsWrapper [Required]# classmethod from_llm_and_api_docs(llm: langchain.schema.BaseLanguageModel, api_docs: str, headers: Optional[dict] = None, api_url_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['api_docs', 'question'], output_parser=None, parti...
https://python.langchain.com/en/latest/reference/modules/chains.html
aa069beb2523-2
pydantic model langchain.chains.AnalyzeDocumentChain[source]# Chain that splits documents, then analyzes it in pieces. Validators set_callback_manager Β» callback_manager set_verbose Β» verbose field combine_docs_chain: langchain.chains.combine_documents.base.BaseCombineDocumentsChain [Required]# field text_splitter: lan...
https://python.langchain.com/en/latest/reference/modules/chains.html