Use the Hello World LLMChain
masterhello-world chain is a simple LLMChain designed to generate a joke based on a provided topic. It requires a single input variable to function.repository·master·Indexed 25 days ago
https://github.com/hwchase17/langchain-hubA central repository for sharing and discovering high-quality LangChain primitives, including prompts, chains, and agents. It provides pre-configured artifacts such as LLMMathChain, LLMBashChain, and LLMCheckerChain, as well as specialized prompts for API responses, conversation memory, and Program-Aided Language models (PAL). Users can load these artifacts using the `lc://` URI scheme via `load_chain` or `load_prompt` and export their own chains in JSON or YAML format.
hello-world chain is a simple LLMChain designed to generate a joke based on a provided topic. It requires a single input variable to function.The LLMBashChain is a chain designed to take a natural language task description and generate a sequence of bash commands required to execute that task.
question: A string describing the task you want to perform in bash.LLMMathChain is a specialized chain designed to solve complex word math problems by leveraging an LLM and a Python REPL. It translates natural language math questions into Python code to ensure computational accuracy.The LLMCheckerChain is a specialized chain designed to improve the quality of answers to factual questions through a multi-step verification process.
When you run this chain, it performs the following workflow:
API URL Prompts are specialized prompts designed to construct an API URL to answer a specific question. These prompts require two specific inputs:
api_docs: The documentation for the target API.question: The specific question being asked of the API.You can use these prompts within an APIChain by loading them via the lc:// URI scheme.
from langchain.prompts import load_prompt
from langchain.chains import APIChain
llm = ...
api_docs = ...
prompt = load_prompt('lc://prompts/api/api_url/<file-name>')
chain = APIChain.from_llm_and_api_docs(llm, api_docs, api_url_prompt=prompt)These prompts are specifically designed for summarization chains utilizing the stuff method. The prompt expects a single input variable:
text: The raw text content that needs to be summarized.You can load any prompt from the LangChainHub by using the lc:// prefix followed by the path relative to the langchain-hub repository.
For example, if a prompt is located at langchain-hub/prompts/qa/stuff/basic/prompt.yaml, you should use the path lc://prompts/qa/stuff/basic/prompt.yaml with the load_prompt function.
from langchain.prompts import load_prompt
prompt = load_prompt('lc://prompts/qa/stuff/basic/prompt.yaml')These prompts are designed for question-answering tasks where the chain uses the refine method to iteratively improve an answer using multiple pieces of context.
The prompt expects the following input variables:
question: The original question to be answered.existing_answer: The answer generated from previous documents.context_str: The new piece of context used to refine the existing answer.from langchain.prompts import load_prompt
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
llm = ...
prompt = load_prompt('lc://prompts/qa_with_sources/refine/<file-name>')
chain = load_qa_with_sources_chain(llm, chain_type="refine", refine_prompt=prompt)The llm_math prompt is designed to answer mathematical questions by optionally generating iPython syntax. This allows the model to execute code to solve complex math problems more accurately.
Expected Input:
question: The user's mathematical question string.from langchain.prompts import load_prompt
from langchain.chains import LLMMathChain
llm = ... # Initialize your LLM
prompt = load_prompt('lc://prompts/llm_math/<file-name>')
chain = LLMMathChain(llm=llm, prompt=prompt)This prompt is designed for the 'reduce' step of a Map Reduce QA chain. It takes the individual summaries generated during the 'map' phase and reduces them into a final answer that includes relevant sources.
Expected Inputs:
summaries: The summaries generated during the map step.question: The original question being answered.from langchain.prompts import load_prompt
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
llm = ...
# Replace <file-name> with the specific prompt file name
prompt = load_prompt('lc://prompts/qa_with_sources/map_reduce/reduce/<file-name>')
chain = load_qa_with_sources_chain(llm, chain_type="map_reduce", combine_prompt=prompt)To upload a prompt to the LangChainHub, you must provide two files:
json, yaml, and python.Organization Rules: