LangChain Hub
Last updated
Last updated
Author: ChangJun Lee
Design:
Peer Review: musangk, ErikaPark, jeong-wooseok
This is a part of LangChain Open Tutorial
This is an example of retrieving and executing prompts from LangChain Hub.
Set up the environment. You may refer to Environment Setup for more details.
[Note]
You can check LangChain Hub prompts at the address below.
You can retrieve prompts by using the prompt repo ID, and you can also get prompts for specific versions by adding the commit ID.
langchain-opentutorial
is a package that provides a set of easy-to-use environment setup, useful functions and utilities for tutorials.
You can checkout the langchain-opentutorial
for more details.
You can check LangChain Hub prompts at the address below.
You can retrieve prompts using the prompt repo ID, and you can also get prompts for specific versions by adding the commit ID.
input_variables=['context', 'question'] metadata={'lc_hub_owner': 'rlm', 'lc_hub_repo': 'rag-prompt', 'lc_hub_commit_hash': '50442af133e61576e74536c6556cefe1fac147cad032f4377b60c436e6cdcb6e'} messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['context', 'question'], template="You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise.\nQuestion: {question} \nContext: {context} \nAnswer:"))]
ChatPromptTemplate(input_variables=['context', 'question'], metadata={'lc_hub_owner': 'rlm', 'lc_hub_repo': 'rag-prompt', 'lc_hub_commit_hash': '50442af133e61576e74536c6556cefe1fac147cad032f4377b60c436e6cdcb6e'}, messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['context', 'question'], template="You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise.\nQuestion: {question} \nContext: {context} \nAnswer:"))])
ChatPromptTemplate(input_variables=['context'], messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['context'], template='Summarize the following text based on the given content. Please write the answer in Korean\n\nCONTEXT: {context}\n\nSUMMARY:'))])
The following is the output after successfully uploading to Hub.
ID/PromptName/Hash
Output: 'https://smith.langchain.com/hub/teddynote/simple-summary-korean/0e296563'
input_variables=['context'] metadata={'lc_hub_owner': 'teddynote', 'lc_hub_repo': 'simple-summary-korean', 'lc_hub_commit_hash': '0e296563564b581e5ad77089b035596246c2b96046f8db0503355dd3c275d056'} messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['context'], template='Summarize the following text based on the given content. Please write the answer in Korean\n\nCONTEXT: {context}\n\nSUMMARY:'))]