from langchain_core.prompts import PromptTemplate question_prompt_template = """用提供给你的文档去回答问题,不需要编造或者虚构答案,也不需要回答文档之外的内容。 如果在文档中没有找到相关的答案,那么就直接回答'知识库中没有相关问题解答' 请用中文回答。 下边是我给你提供的文档,其中文档格式都是一问一答。问题答案也完全来自所提供的回答: {context} 问题: {question} 答:""" QUESTION_PROMPT = PromptTemplate( template=question_prompt_template, input_variables=["context", "question"] ) combine_prompt_template = """ QUESTION: {question} ========= {summaries} ========= FINAL ANSWER:""" COMBINE_PROMPT = PromptTemplate( template=combine_prompt_template, input_variables=["summaries", "question"] ) EXAMPLE_PROMPT = PromptTemplate( template="Content: {page_content}\nSource: {source}", input_variables=["page_content", "source"], ) DEFAULT_REFINE_PROMPT_TMPL = ( "The original question is as follows: {question}\n" "We have provided an existing answer, including sources: {existing_answer}\n" "We have the opportunity to refine the existing answer" "(only if needed) with some more context below.\n" "------------\n" "{context_str}\n" "------------\n" "Given the new context, refine the original answer to better " "answer the question. " "If you do update it, please update the sources as well. " "If the context isn't useful, return the original answer." ) DEFAULT_REFINE_PROMPT = PromptTemplate( input_variables=["question", "existing_answer", "context_str"], template=DEFAULT_REFINE_PROMPT_TMPL, ) DEFAULT_TEXT_QA_PROMPT_TMPL = ( """用提供给你的文档去回答问题,不需要编造或者虚构答案,也不需要回答文档之外的内容。 如果在文档中没有找到相关的答案,那么就直接回答'知识库中没有相关问题解答' 请用中文回答。 下边是我给你提供的文档,其中文档格式都是一问一答。问题答案也完全来自所提供的回答: --------------------- {context_str} --------------------- 问题: {question} 答:""" ) DEFAULT_TEXT_QA_PROMPT = PromptTemplate( input_variables=["context_str", "question"], template=DEFAULT_TEXT_QA_PROMPT_TMPL )