mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-09 11:36:23 +08:00
prompt changes
This commit is contained in:
+4
-4
@@ -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):
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user