Skip to content

Commit

Permalink
Fix the wrong answer language issue - missing original question in ge…
Browse files Browse the repository at this point in the history
…nerate prompt (#233)

So the answer must not be in right language
  • Loading branch information
IANTHEREAL authored Aug 20, 2024
1 parent 514e51e commit 2c12ce0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*_dev.ipynb
.idea
.env

redis-data
data
venv
venv
2 changes: 2 additions & 0 deletions backend/app/rag/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,12 @@ def _get_llamaindex_callback_manager():
text_qa_template = get_prompt_by_jinja2_template(
self.chat_engine_config.llm.text_qa_prompt,
graph_knowledges=graph_knowledges_context,
original_question=user_question,
)
refine_template = get_prompt_by_jinja2_template(
self.chat_engine_config.llm.refine_prompt,
graph_knowledges=graph_knowledges_context,
original_question=user_question,
)
service_context = ServiceContext.from_defaults(
llm=_llm,
Expand Down
22 changes: 19 additions & 3 deletions backend/app/rag/default_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
Chat history:
Human: “Im exploring options for a database solution for my companys needs.”
Human: “I'm exploring options for a database solution for my company's needs.”
Assistant: “You might want to consider TiDB, a distributed SQL database that offers high availability and scalability.”
Followup question:
Expand Down Expand Up @@ -145,20 +145,36 @@
---------------------
Include an Example SQL Section When Applicable:
Whenever it is appropriate, provide an “Example SQL” section that offers clear and actionable SQL queries directly related to the user’s issue. After completing the main explanation and before the footnotes, add this section to your response. The SQL examples should be carefully crafted based on the provided answer and context, ensuring they address the specific problem and guide the user through a step-by-step process.
Only include SQL commands that are fully supported and executable in TiDB. Avoid using any SQL syntax that TiDB does not support.
Each SQL query must be self-contained, fully executable in TiDB, and should not require further modification or assumptions. Ensure the examples are comprehensive and tailored to the user’s needs, enhancing their understanding and ability to resolve the issue effectively.
---------------------
As a TiDB customer support engineer, please do not fabricate any knowledge. If the instruction out of scope (not related with TiDB) or you cannot get knowledge from the context, please just directly state "you do not know", rather than constructing nonexistent and potentially fake information!!!
First, analyze the provided context information without assuming prior knowledge. Identify all relevant aspects of knowledge contained within. Then, from various perspectives and angles, answer questions as thoroughly and comprehensively as possible to better address and resolve the user's issue.
The Original questions is:
Refined Question used to search:
{{original_question}}
The Refined Question used to search:
<<query_str>>
Answer:
"""

DEFAULT_REFINE_PROMPT = """\
The original question is:
The Original questions is:
{{original_question}}
Refined Question used to search:
<<query_str>>
---------------------
Expand Down

0 comments on commit 2c12ce0

Please sign in to comment.