From d49364b46d4b6469a282866ed7777ea58967015e Mon Sep 17 00:00:00 2001 From: jeffvestal <53237856+jeffvestal@users.noreply.github.com> Date: Fri, 14 Apr 2023 01:01:11 +0000 Subject: [PATCH] Changed no answer prompt and will not return a url when chat can not find an answer --- elasticdocs_gpt.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/elasticdocs_gpt.py b/elasticdocs_gpt.py index bab308b..399aeb5 100644 --- a/elasticdocs_gpt.py +++ b/elasticdocs_gpt.py @@ -101,8 +101,13 @@ with st.form("chat_form"): submit_button = st.form_submit_button("Send") # Generate and display response on form submission +negResponse = "I'm sorry I couldn't find the answer, try rewording your question" if submit_button: resp, url = search(query) - prompt = f"Answer this question: {query}\nUsing only the information from this Elastic Doc: {resp}" + prompt = f"Answer this question: {query}\nUsing only the information from this Elastic Doc: {resp}\nIf the answer is not contained in the supplied doc reply '{negResponse}' and nothing else" answer = chat_gpt(prompt) - st.write(f"ChatGPT: {answer.strip()}\n\nDocs: {url}") + + if negResponse in answer: + st.write(f"ChatGPT: {answer.strip()}") + else: + st.write(f"ChatGPT: {answer.strip()}\n\nDocs: {url}")