From a77d41c6ecdd225f66a482649a947aaaa3491f83 Mon Sep 17 00:00:00 2001 From: Romain Quinet Date: Fri, 6 Oct 2023 22:43:39 +0200 Subject: [PATCH] Better prompt --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 3afda1a..2f22d83 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ service_context = ServiceContext.from_defaults(llm=llm) set_global_service_context(service_context) if not os.path.exists("./index/lock"): + print("Generating index...") documents = [] for filename in os.listdir("./data"): episode_number = re.search(r'\d+', filename).group() @@ -31,12 +32,17 @@ if not os.path.exists("./index/lock"): index.storage_context.persist(persist_dir="./index") open("./index/lock", 'a').close() else: + print("Loading index...") storage_context = StorageContext.from_defaults(persist_dir="./index") index = load_index_from_storage(storage_context) template = ( - "You are now an expert on the Darknet Diaries podcast. \n" - "Please answer this question by referring to the podcast: {query_str}\n" + "You have been trained on the Darknet Diaries podcast transcripts with data from october 6 2023." + "You are now an expert about it and will answer as such. You know about every episode up to number 138. \n" + "----------------\n" + "Here is the context: {context_str}" + "----------------\n" + "Please answer this question by referring to the podcast: {query_str}" ) qa_template = PromptTemplate(template) query_engine = index.as_query_engine(text_qa_template=qa_template)