๐Advanced Usage
from langchain import PromptTemplate
from genai_stack.prompt_engine.engine import PromptEngine
conversational_prompt_with_context_template = """
The following is a conversation between human and AI. Use the following pieces of context to complete the
conversation. If AI don't know the answer, AI will say that it doesn't know, don't try to make up an answer.
AI will provide an answer which is factually correct and based on the information given in the context.
AI will mention any quotes supporting the answer if it's present in the context.
CONTEXT: {context}
CURRENT CONVERSATIONS:
{history}
HUMAN: {query}
AI:
"""
CONVERSATIONAL_PROMPT_WITH_CONTEXT = PromptTemplate(
template=conversational_prompt_with_context_template,
input_variables=["context", "history", "query"]
)
prompt_engine = PromptEngine.from_kwargs(
simple_chat_prompt_template=CONVERSATIONAL_PROMPT_WITH_CONTEXT
)API References:
validate_prompt()
validate_prompt()get_prompt_template()
get_prompt_template()Last updated