.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Basic-RAG/BasicRAG_CustomPrompt.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_Basic-RAG_BasicRAG_CustomPrompt.py: Custom Prompts ==================== This cookbook demonstrates how to use custom prompts with Basic RAG. `Note that this cookbook assumes that you already have the` ``Llama-2-13b-chat`` `LLM ready,` `for more details on how to quantize and run an LLM locally,` `refer to the LLM section under Getting Started.` `Note that this cookbook also assumes that you have already ingested documents into a DeepLake collection called 'grag'` `for more details on how to ingest documents refer to the cookbook called` ``Document Ingestion``. .. GENERATED FROM PYTHON SOURCE LINES 13-38 .. code-block:: Python from grag.components.multivec_retriever import Retriever from grag.components.prompt import Prompt from grag.components.vectordb.deeplake_client import DeepLakeClient from grag.rag.basic_rag import BasicRAG custom_prompt = Prompt( input_keys={"context", "question"}, template="""Answer the following question based on the given context. question: {question} context: {context} answer: """, ) client = DeepLakeClient(collection_name="grag") retriever = Retriever(vectordb=client) rag = BasicRAG( model_name="Llama-2-13b-chat", custom_prompt=custom_prompt, retriever=retriever ) if __name__ == "__main__": while True: query = input("Query:") rag(query) .. _sphx_glr_download_auto_examples_Basic-RAG_BasicRAG_CustomPrompt.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: BasicRAG_CustomPrompt.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: BasicRAG_CustomPrompt.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_