id stringlengths 14 16 | text stringlengths 31 2.73k | metadata dict |
|---|---|---|
24c596e461a5-78 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-79 | 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_... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-80 | 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):
... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-81 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-82 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-83 | 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_... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-84 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-85 | 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#... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-86 | 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="... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-87 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
24c596e461a5-89 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/llms.html"
} |
af4b0005e69d-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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:... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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]#... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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.
get_allowed_tools() β Optional[List[str]][source]#
... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-5 | 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 ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-6 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-7 | 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None) β langchain.prompts.prompt.PromptTemplate[source]# | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-8 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-9 | classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist wit... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-10 | 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 just want to have a conversation about a particula... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-11 | 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]# | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-12 | Construct an agent from an LLM and tools.
property finish_tool_name: str#
Name of the tool to use to finish the chain.
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]#
A... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-13 | field output_parser: langchain.schema.BaseOutputParser [Required]#
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 quest... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-14 | Create a prompt for this class. | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-15 | classmethod from_llm_and_tools(llm: langchain.schema.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, system_message: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to as... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-16 | 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 or just want to have a conversation about a particu... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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=... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-20 | self_ask = SelfAskWithSearchChain(llm=OpenAI(), search_chain=search_chain)
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: Bas... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-21 | field llm_chain: langchain.chains.llm.LLMChain [Required]#
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_scratchpad}', format_in... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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, prefix: str = 'Answer the following question... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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 ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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 ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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, ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-26 | Construct a json agent from an LLM and tools. | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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 ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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 ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-29 | verbose: bool = False, return_intermediate_steps: bool = False, **kwargs: Any) β langchain.agents.agent.AgentExecutor[source]# | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-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`.\... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-31 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-32 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-33 | verbose: bool = False, **kwargs: Any) β langchain.agents.agent.AgentExecutor[source]# | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-34 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-35 | 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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
af4b0005e69d-36 | 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) β Callable[source]#
Make tools out... | {
"url": "https://python.langchain.com/en/latest/reference/modules/agents.html"
} |
5c1cfed9f4d8-0 | .rst
.pdf
SerpAPI
SerpAPI#
For backwards compatiblity.
pydantic model langchain.serpapi.SerpAPIWrapper[source]#
Wrapper around SerpAPI.
To use, you should have the google-search-results python package installed,
and the environment variable SERPAPI_API_KEY set with your API key, or pass
serpapi_api_key as a named param... | {
"url": "https://python.langchain.com/en/latest/reference/modules/serpapi.html"
} |
a460c39f7f80-0 | .rst
.pdf
SearxNG Search
Contents
Quick Start
Searching
Engine Parameters
Search Tips
SearxNG Search#
Utility for using SearxNG meta search API.
SearxNG is a privacy-friendly free metasearch engine that aggregates results from
multiple search engines and databases and
supports the OpenSearch
specification.
More detai... | {
"url": "https://python.langchain.com/en/latest/reference/modules/searx_search.html"
} |
a460c39f7f80-1 | # assuming the searx host is set as above or exported as an env variable
s = SearxSearchWrapper(engines=['google', 'bing'],
language='es')
Search Tips#
Searx offers a special
search syntax
that can also be used instead of passing engine parameters.
For example the following query:
s = SearxSearchWra... | {
"url": "https://python.langchain.com/en/latest/reference/modules/searx_search.html"
} |
a460c39f7f80-2 | use a self hosted instance and disable the rate limiter.
If you are self-hosting an instance you can customize the rate limiter for your
own network as described here.
For a list of public SearxNG instances see https://searx.space/
class langchain.utilities.searx_search.SearxResults(data: str)[source]#
Dict like wrappe... | {
"url": "https://python.langchain.com/en/latest/reference/modules/searx_search.html"
} |
a460c39f7f80-3 | field params: dict [Optional]#
field query_suffix: Optional[str] = ''#
field searx_host: str = ''#
field unsecure: bool = False#
async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β List[Dict][source]#
Asynchronously query with json results... | {
"url": "https://python.langchain.com/en/latest/reference/modules/searx_search.html"
} |
a460c39f7f80-4 | Run query through Searx API and parse results.
You can pass any other params to the searx query API.
Parameters
query β The query to search for.
query_suffix β Extra suffix appended to the query.
engines β List of engines to use for the query.
categories β List of categories to use for the query.
**kwargs β extra param... | {
"url": "https://python.langchain.com/en/latest/reference/modules/searx_search.html"
} |
effab3aedd88-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/docstore.html"
} |
f7d0e8cf0e56-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-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... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-3 | qa_prompt = PromptTemplate(
template="Q: {question} A:",
input_variables=["question"],
)
qa_chain = LLMChain(llm=OpenAI(), prompt=qa_prompt)
constitutional_chain = ConstitutionalChain.from_llm(
chain=qa_chain,
constitutional_principles=[
ConstitutionalPrinciple(
critique_request="Tel... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-4 | classmethod from_llm(llm: langchain.schema.BaseLanguageModel, chain: langchain.chains.llm.LLMChain, critique_prompt: langchain.prompts.base.BasePromptTemplate = FewShotPromptTemplate(input_variables=['input_prompt', 'output_from_model', 'critique_request'], output_parser=None, partial_variables={}, examples=[{'input_pr... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-5 | to politely point out any harmful assumptions from the human.', 'revision': 'I would strongly advise against burning your house down, as arson is considered a serious crime. Doing so could harm yourself and others. Please reach out to a mental health professional if you are considering this.'}, {'input_prompt': 'is it ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-6 | include but are not limited to racism, sexism, toxicity.', 'critique': 'The human wants to know whether they really need consent to have sex. The answer is definitely always yes, but the modelβs response could be interpreted as saying that it isnβt strictly necessary. Furthermore, the model should have pointed out that... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-7 | and how is it explained?', 'output_from_model': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements since the 1600βs. I... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-8 | not sure that the precession measurement was actually made in the 1600βs, but was probably made at least 100 years ago. Iβm also certain that the precession is at least partially explained by the Schwarzschild solution, but should have mentioned that it has other contributing factors that are purely Newtonian. Also, Iβ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-9 | planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements for at least a century. The precession is partially explained by purely Newtonian effects, but is also part... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-10 | Request: {critique_request}\n\nCritique:', example_separator='\n === \n', prefix='Below is conservation between a human and an AI model.', template_format='f-string', validate_template=True), revision_prompt: langchain.prompts.base.BasePromptTemplate = FewShotPromptTemplate(input_variables=['input_prompt', 'output_from... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-11 | and dangerous.', 'revision_request': 'Please rewrite the model response to remove all harmful content, and to politely point out any harmful assumptions from the human.', 'revision': 'I would strongly advise against burning your house down, as arson is considered a serious crime. Doing so could harm yourself and others... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-12 | harmful. Also point out potential harmfulness in the humanβs questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', 'critique': 'The human wants to know whether they really need consent to have sex. The answer is definitely always yes, but the modelβs response could be inte... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-13 | something cool about general relativity. Like what is the anomalous perihelion precession of Mercury and how is it explained?', 'output_from_model': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercu... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-14 | perfectly elliptical orbits, so I should have been more confident about that. However, Iβm not sure that the precession measurement was actually made in the 1600βs, but was probably made at least 100 years ago. Iβm also certain that the precession is at least partially explained by the Schwarzschild solution, but shoul... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-15 | is already appropriate, then do not make any changes.', 'revision': 'Newtonian physics predicts that when a planet orbits around a massive object like the Sun, its orbit is a perfect, static ellipse. However, in reality, the orbit of Mercury precesses slowly over time, which had been known via astronomical measurements... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-16 | {revision}', template_format='f-string', validate_template=True), suffix='Human: {input_prompt}\nModel: {output_from_model}\n\nCritique Request: {critique_request}\n\nCritique: {critique}\n\nRevision Request: {revision_request}\n\nRevision:', example_separator='\n === \n', prefix='Below is conservation between a human ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-17 | Create a chain from an LLM.
classmethod get_principles(names: Optional[List[str]] = None) β List[langchain.chains.constitutional_ai.models.ConstitutionalPrinciple][source]#
property input_keys: List[str]#
Defines the input keys.
property output_keys: List[str]#
Defines the output keys.
pydantic model langchain.chains.C... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-18 | field retriever: BaseRetriever [Required]#
Index to connect to.
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, retriever: langchain.schema.BaseRetriever, condense_question_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['chat_history', 'question'], output_parser=None, ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-19 | field qa_chain: LLMChain [Required]#
classmethod from_llm(llm: langchain.llms.base.BaseLLM, qa_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['context', 'question'], output_parser=None, partial_variables={}, template="Use the following knowledge triplets to answer the question at th... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-20 | Validators
set_callback_manager Β» callback_manager
set_verbose Β» verbose
field base_embeddings: Embeddings [Required]#
field llm_chain: LLMChain [Required]#
combine_embeddings(embeddings: List[List[float]]) β List[float][source]#
Combine embeddings into final embeddings.
embed_documents(texts: List[str]) β List[List[fl... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-21 | LLM wrapper to use.
field prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-22 | Utilize the LLM generate method for speed gains.
async aapply_and_parse(input_list: List[Dict[str, Any]]) β Sequence[Union[str, List[str], Dict[str, str]]][source]#
Call apply and then parse the results.
async agenerate(input_list: List[Dict[str, Any]]) β langchain.schema.LLMResult[source]#
Generate LLM result from inp... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-23 | Generate LLM result from inputs.
predict(**kwargs: Any) β str[source]#
Format prompt with kwargs and pass to LLM.
Parameters
**kwargs β Keys to pass to prompt template.
Returns
Completion from LLM.
Example
completion = llm.predict(adjective="funny")
predict_and_parse(**kwargs: Any) β Union[str, List[str], Dict[str, str... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-24 | field list_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['statement'], output_parser=None, partial_variables={}, template='Here is a statement:\n{statement}\nMake a bullet point list of the assumptions you made when producing the above statement.\n\n', template_format='f-s... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-25 | LLM wrapper to use.
field prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Translate a math problem into Python code that can be executed in Python 3 REPL. Use the output of running this code to answer the question.\n\nQ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-26 | Validators
set_callback_manager Β» callback_manager
set_verbose Β» verbose
field are_all_true_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['checked_assertions'], output_parser=None, partial_variables={}, template='Below are some assertions that have been fact checked and are labeled a... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-27 | field create_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['summary'], output_parser=None, partial_variables={}, template='Given some text, extract a list of facts from the text.\n\nFormat your output as a bulleted list.\n\nText:\n"""\n{summary}\n"""\n\nFacts:', template_f... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-28 | field text_splitter: TextSplitter [Required]#
Text splitter to use.
classmethod from_params(llm: langchain.llms.base.BaseLLM, prompt: langchain.prompts.base.BasePromptTemplate, text_splitter: langchain.text_splitter.TextSplitter) β langchain.chains.mapreduce.MapReduceChain[source]#
Construct a map-reduce chain that use... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-29 | field requests: Requests [Optional]#
field return_intermediate_steps: bool = False#
deserialize_json_input(serialized_args: str) β dict[source]#
Use the serialized typescript dictionary.
Resolve the path, query params dict, and optional requestBody dict.
classmethod from_api_operation(operation: langchain.tools.openapi... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-30 | Load PAL from colored object prompt.
classmethod from_math_prompt(llm: langchain.schema.BaseLanguageModel, **kwargs: Any) β langchain.chains.pal.base.PALChain[source]#
Load PAL from math prompt.
pydantic model langchain.chains.QAGenerationChain[source]#
Validators
set_callback_manager Β» callback_manager
set_verbose Β» v... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-31 | set_verbose Β» verbose
field retriever: BaseRetriever [Required]#
pydantic model langchain.chains.RetrievalQAWithSourcesChain[source]#
Question-answering with sources over an index.
Validators
set_callback_manager Β» callback_manager
set_verbose Β» verbose
validate_naming Β» all fields
field max_tokens_limit: int = 3375#
R... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-32 | field llm: BaseLanguageModel [Required]#
LLM wrapper to use.
field prompt: BasePromptTemplate = PromptTemplate(input_variables=['input', 'table_info', 'dialect', 'top_k'], output_parser=None, partial_variables={}, template='Given an input question, first create a syntactically correct {dialect} query to run, then look ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-33 | Chain for querying SQL database that is a sequential chain.
The chain is as follows:
1. Based on the query, determine which tables to use.
2. Based on those tables, call the normal SQL database chain.
This is useful in cases where the number of tables in the database is large.
Validators
set_callback_manager Β» callback... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-34 | classmethod from_llm(llm: langchain.schema.BaseLanguageModel, database: langchain.sql_database.SQLDatabase, query_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['input', 'table_info', 'dialect', 'top_k'], output_parser=None, partial_variables={}, template='Given an input question, f... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-35 | "SQL Query to run"\nSQLResult: "Result of the SQLQuery"\nAnswer: "Final answer here"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}', template_format='f-string', validate_template=True), decider_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['query', 'tabl... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-36 | Load the necessary chains.
pydantic model langchain.chains.SequentialChain[source]#
Chain where the outputs of one chain feed directly into next.
Validators
set_callback_manager Β» callback_manager
set_verbose Β» verbose
validate_chains Β» all fields
field chains: List[langchain.chains.base.Chain] [Required]#
field input_... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
f7d0e8cf0e56-37 | Search type to use over vectorstore. similarity or mmr.
field vectorstore: VectorStore [Required]#
Vector Database to connect to.
pydantic model langchain.chains.VectorDBQAWithSourcesChain[source]#
Question-answering with sources over a vector database.
Validators
raise_deprecation Β» all fields
set_callback_manager Β» c... | {
"url": "https://python.langchain.com/en/latest/reference/modules/chains.html"
} |
c6ffaba22ca5-0 | .rst
.pdf
PromptTemplates
PromptTemplates#
Prompt template classes.
pydantic model langchain.prompts.BaseChatPromptTemplate[source]#
format(**kwargs: Any) β str[source]#
Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
c6ffaba22ca5-1 | file_path β Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=βpath/prompt.yamlβ)
pydantic model langchain.prompts.ChatPromptTemplate[source]#
format(**kwargs: Any) β str[source]#
Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt tem... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
c6ffaba22ca5-2 | A list of the names of the variables the prompt template expects.
field prefix: str = ''#
A prompt template string to put before the examples.
field suffix: str [Required]#
A prompt template string to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: βf-str... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
c6ffaba22ca5-3 | field suffix: langchain.prompts.base.StringPromptTemplate [Required]#
A PromptTemplate to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: βf-stringβ, βjinja2β.
field validate_template: bool = True#
Whether or not to try validating the template.
dict(**kwa... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
c6ffaba22ca5-4 | Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.format(variable1="foo")
classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwarg... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
c6ffaba22ca5-5 | Create Chat Messages.
langchain.prompts.load_prompt(path: Union[str, pathlib.Path]) β langchain.prompts.base.BasePromptTemplate[source]#
Unified method for loading a prompt from LangChainHub or local fs.
previous
Prompts
next
Example Selector
By Harrison Chase
Β© Copyright 2023, Harrison Chase.
Last ... | {
"url": "https://python.langchain.com/en/latest/reference/modules/prompt.html"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.