From 3a190bc5754cb1584624101ff7d4e8e3240fbbca Mon Sep 17 00:00:00 2001 From: wassname Date: Sat, 24 Feb 2024 08:39:58 +0800 Subject: [PATCH] prompt changes --- api/main.py | 8 ++++---- api/src/stampy_chat/chat.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/main.py b/api/main.py index abe30a0..94acb2a 100644 --- a/api/main.py +++ b/api/main.py @@ -43,8 +43,8 @@ def semantic(): # try elastic and other searches n = transform_query(query) - logging.info(f'query=`{query}`, new_query=`{n["new_query"]}` example=`{n["example"]}`') - query = f'{query}. {n["new_query"]}. {n["example"]}' + logging.info(f'query=`{query}`, new_query=`{n["new_query"]}` example=`{n["example_answer"]}`') + query = f'{query}. {n["new_query"]}. {n["example_answer"]}' return jsonify(get_top_k_blocks(query, k)) @@ -70,8 +70,8 @@ def chat(): # TODO: try elastic and other searches # TODO ideally separate searches for example and both queries n = transform_query(query) - logging.info(f'query=`{query}`, new_query=`{n["new_query"]}` example=`{n["example"]}`') - query = f'{query}. {n["new_query"]}. {n["example"]}' + logging.info(f'query=`{query}`, new_query=`{n["new_query"]}` example=`{n["example_answer"]}`') + query = f'{query}. {n["new_query"]}. {n["example_answer"]}' def formatter(item): if isinstance(item, Exception): diff --git a/api/src/stampy_chat/chat.py b/api/src/stampy_chat/chat.py index 276bb45..f43011c 100644 --- a/api/src/stampy_chat/chat.py +++ b/api/src/stampy_chat/chat.py @@ -169,7 +169,7 @@ def transform_query(query: str) -> str: """ llm=get_model(model=COMPLETIONS_MODEL) prompt_template = ChatPromptTemplate.from_messages([ - ChatMessagePromptTemplate.from_template(template="Please draft a search query that will find documents to answer the following question: {query}", role='user'), + ChatMessagePromptTemplate.from_template(template="Please draft an academic search query with synonyms and alternative phrases that will find documents to answer the following question: {query}", role='user'), ]) chain = LLMChain(llm=llm, prompt=prompt_template) new_query = chain.invoke({"query": query})['text']