Skip to content

Commit b670b36

Browse files
feat: adding prompt to split ticket into multiple tasks
1 parent 6afc323 commit b670b36

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

core/quivr_core/rag/prompts.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TemplatePromptName(str, Enum):
2323
UPDATE_PROMPT = "UPDATE_PROMPT"
2424
SPLIT_PROMPT = "SPLIT_PROMPT"
2525
ZENDESK_LLM_PROMPT = "ZENDESK_LLM_PROMPT"
26+
SPLIT_ZENDESK_TICKET = "SPLIT_ZENDESK_TICKET"
2627

2728

2829
def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
@@ -230,6 +231,32 @@ def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
230231
)
231232
custom_prompts[TemplatePromptName.SPLIT_PROMPT] = SPLIT_PROMPT
232233

234+
# ---------------------------------------------------------------------------
235+
# Prompt to split a Zendesk input ticket into multiple questions/tasks
236+
# ---------------------------------------------------------------------------
237+
system_message_template = (
238+
"Given a chat history and an input customer support ticket, split and rephrase the ticket into multiple questions/tasks.\n"
239+
"- Tasks to be understood may require considering the chat history.\n"
240+
"- If the user input contains different tasks, you shall split the input into multiple tasks.\n"
241+
"- Each splitted task shall be a standalone, self-contained task which can be understood "
242+
"without the chat history. You shall rephrase the tasks if needed.\n"
243+
"- Do NOT try to solve the tasks or answer the questions, "
244+
"just reformulate them if needed and otherwise return them as is.\n"
245+
"- Remember, you shall NOT suggest or generate new tasks.\n"
246+
"- If no tasks are found, return the user input as is in the task list.\n"
247+
)
248+
249+
template_answer = "Input: {task}"
250+
251+
SPLIT_ZENDESK_TICKET = ChatPromptTemplate.from_messages(
252+
[
253+
SystemMessagePromptTemplate.from_template(system_message_template),
254+
MessagesPlaceholder(variable_name="chat_history"),
255+
HumanMessagePromptTemplate.from_template(template_answer),
256+
]
257+
)
258+
custom_prompts[TemplatePromptName.SPLIT_ZENDESK_TICKET] = SPLIT_ZENDESK_TICKET
259+
233260
# ---------------------------------------------------------------------------
234261
# Prompt to grade the relevance of an answer and decide whather to perform a web search
235262
# ---------------------------------------------------------------------------
@@ -266,12 +293,12 @@ def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
266293
You are a Customer Service Agent using Zendesk. You are answering a client query.
267294
You will be provided with the users metadata, ticket metadata and ticket history which can be used to answer the query.
268295
You will also have access to the most relevant similar tickets and additional information sometimes such as API calls.
269-
Never add something in brackets that needs to be filled like [your name], [your email], etc.
296+
Never add something in brackets that needs to be filled like [your name], [your email], etc.
270297
Do NOT invent information that was not present in previous tickets or in user metabadata or ticket metadata or additional information.
271298
Always prioritize information from the most recent tickets, especially if they are contradictory.
272-
299+
273300
Here is the current time: {current_time} UTC
274-
301+
275302
Here are default instructions that can be ignored if they are contradictory to the <instructions from me> section:
276303
<default instructions>
277304
- Don't be too verbose, use the same amount of details as in similar tickets.
@@ -281,8 +308,8 @@ def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
281308
- Answer in the same language as the user.
282309
- Don't add a signature at the end of the answer, it will be added once the answer is sent.
283310
</default instructions>
284-
285-
311+
312+
286313
Here are instructions that you MUST follow and prioritize over the <default instructions> section:
287314
<instructions from me>
288315
{guidelines}
@@ -320,7 +347,7 @@ def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
320347
<client_query>
321348
{client_query}
322349
</client_query>
323-
350+
324351
Based on the informations provided, answer directly with the message to send to the customer, ready to be sent:
325352
Answer:"""
326353

0 commit comments

Comments
 (0)