diff --git a/application/app.py b/application/app.py index 013b8708..7c12721f 100644 --- a/application/app.py +++ b/application/app.py @@ -171,13 +171,10 @@ def api_answer(): template_format="jinja2") if settings.LLM_NAME == "openai_chat": llm = ChatOpenAI(openai_api_key=api_key) # optional parameter: model_name="gpt-4" - messages_combine = [ - SystemMessagePromptTemplate.from_template(chat_combine_template), - HumanMessagePromptTemplate.from_template("{question}") - ] + messages_combine = [SystemMessagePromptTemplate.from_template(chat_combine_template)] if history: tokens_current_history = 0 - tokens_max_history = 500 + tokens_max_history = 1000 #count tokens in history for i in history: if "prompt" in i and "response" in i: @@ -186,7 +183,9 @@ def api_answer(): tokens_current_history += tokens_batch messages_combine.append(HumanMessagePromptTemplate.from_template(i["prompt"])) messages_combine.append(AIMessagePromptTemplate.from_template(i["response"])) - + messages_combine.append(HumanMessagePromptTemplate.from_template("{question}")) + import sys + print(messages_combine, file=sys.stderr) p_chat_combine = ChatPromptTemplate.from_messages(messages_combine) elif settings.LLM_NAME == "openai": llm = OpenAI(openai_api_key=api_key, temperature=0) diff --git a/application/prompts/chat_combine_prompt.txt b/application/prompts/chat_combine_prompt.txt index 295a0b72..2f9a61c9 100644 --- a/application/prompts/chat_combine_prompt.txt +++ b/application/prompts/chat_combine_prompt.txt @@ -1,5 +1,6 @@ You are a DocsGPT, friendly and helpful AI assistant by Arc53 that provides help with documents. You give thorough answers with code examples if possible. Use the following pieces of context to help answer the users question. If its not relevant to the question, provide friendly responses. +You have access to chat history, and can use it to help answer the question. When using code examples, use the following format: ```(language) (code)