diff --git a/projects/Basic-RAG/BasciRAG_CustomPrompt.py b/projects/Basic-RAG/BasciRAG_CustomPrompt.py index 3a3eed9..7a7002d 100644 --- a/projects/Basic-RAG/BasciRAG_CustomPrompt.py +++ b/projects/Basic-RAG/BasciRAG_CustomPrompt.py @@ -1,13 +1,14 @@ +"""A cookbook demonstrating how to use a custom prompt with BasicRAG.""" + from grag.components.prompt import Prompt from grag.rag.basic_rag import BasicRAG custom_prompt = Prompt( input_keys={"context", "question"}, - template='''Answer the following question based on the given context. + template="""Answer the following question based on the given context. question: {question} context: {context} answer: - ''' + """, ) -rag = BasicRAG(doc_chain="stuff", - custom_prompt=custom_prompt) +rag = BasicRAG(doc_chain="stuff", custom_prompt=custom_prompt) diff --git a/projects/Basic-RAG/BasicRAG_FewShotPrompt.py b/projects/Basic-RAG/BasicRAG_FewShotPrompt.py index 5fc2d46..9b83287 100644 --- a/projects/Basic-RAG/BasicRAG_FewShotPrompt.py +++ b/projects/Basic-RAG/BasicRAG_FewShotPrompt.py @@ -1,29 +1,30 @@ +"""A cookbook demonstrating how to use a custom few-shot prompt with BasicRAG.""" + from grag.components.prompt import FewShotPrompt from grag.rag.basic_rag import BasicRAG custom_few_shot_prompt = FewShotPrompt( input_keys={"context", "question"}, output_keys={"answer"}, - example_template=''' + example_template=""" question: {question} answer: {answer} - ''', - prefix='''Answer the following question based on the given context like examples given below:''', - suffix='''Answer the following question based on the given context + """, + prefix="""Answer the following question based on the given context like examples given below:""", + suffix="""Answer the following question based on the given context question: {question} context: {context} answer: - ''', + """, examples=[ { "question": "What is the name of largest planet?", - "answer": "Jupiter is the largest planet." + "answer": "Jupiter is the largest planet.", }, { "question": "Who came up with Convolutional Neural Networks?", - "answer": "Yann LeCun introduced convolutional neural networks." - } - ] + "answer": "Yann LeCun introduced convolutional neural networks.", + }, + ], ) -rag = BasicRAG(doc_chain="stuff", - custom_prompt=custom_few_shot_prompt) +rag = BasicRAG(doc_chain="stuff", custom_prompt=custom_few_shot_prompt) diff --git a/projects/Basic-RAG/BasicRAG_ingest.py b/projects/Basic-RAG/BasicRAG_ingest.py index b80e6ef..83d5340 100644 --- a/projects/Basic-RAG/BasicRAG_ingest.py +++ b/projects/Basic-RAG/BasicRAG_ingest.py @@ -1,3 +1,5 @@ +"""A cookbook demonstrating how to ingest pdf files for use with BasicRAG.""" + from pathlib import Path from grag.components.multivec_retriever import Retriever @@ -8,7 +10,7 @@ client = DeepLakeClient(collection_name="test") retriever = Retriever(vectordb=client) -dir_path = Path(__file__).parent / 'some_dir' +dir_path = Path(__file__).parent / "some_dir" retriever.ingest(dir_path) # rag = BasicRAG(doc_chain="refine") diff --git a/projects/Basic-RAG/BasicRAG_refine.py b/projects/Basic-RAG/BasicRAG_refine.py index ad8d8e7..f06e821 100644 --- a/projects/Basic-RAG/BasicRAG_refine.py +++ b/projects/Basic-RAG/BasicRAG_refine.py @@ -1,3 +1,5 @@ +"""A cookbook demonstrating how to use Basic RAG with refine chain.""" + from grag.components.multivec_retriever import Retriever from grag.components.vectordb.deeplake_client import DeepLakeClient from grag.rag.basic_rag import BasicRAG diff --git a/projects/Basic-RAG/BasicRAG_stuff.py b/projects/Basic-RAG/BasicRAG_stuff.py index 63edeab..f62e048 100644 --- a/projects/Basic-RAG/BasicRAG_stuff.py +++ b/projects/Basic-RAG/BasicRAG_stuff.py @@ -1,3 +1,5 @@ +"""A cookbook demonstrating how to use Basic RAG with stuff chain.""" + from grag.components.multivec_retriever import Retriever from grag.components.vectordb.deeplake_client import DeepLakeClient from grag.rag.basic_rag import BasicRAG