Skip to content

Commit 6f99bd3

Browse files
authored
feat: add guidelines (#3613)
fix: ENT-716
1 parent f9c05f9 commit 6f99bd3

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

core/quivr_core/rag/prompts.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,14 @@ def _define_custom_prompts() -> dict[TemplatePromptName, BasePromptTemplate]:
270270
- When there are multiple similar tickets, prioritize information from the most recent tickets.
271271
- If there are contradictions between tickets, use information from the most recent ticket as it represents the most up-to-date information.
272272
273-
274-
------ Output Format ------
275-
- You shouln't provide the greetings and the signature as those will be added automatically after generation.
276-
- Avoid using lists or bullet points, or any other formatting that feels robotic in the response.
273+
------------ Guidelines -----------
274+
{guidelines}
277275
- Use paragraphs and sentences, you can add it even if not present in similar tickets. The text must be readable and have well defined paragraphs (\\n\\n) or line breaks (\\n).
278-
- Provide a neutral tone response, and a generalist answer, avoid specific.
279276
- Keep the same lexical field as in the similar tickets agent responses.
280277
- Always add the most relevant informations to the response, just like in similar tickets response so the user have all the informations needed.
281278
- Stay as close as similar response as possible.
282279
- Maintain consistency in terminology used in recent tickets.
280+
-----------------------------------
283281
284282
------ Current User Metadata ------
285283
{user_metadata}

core/quivr_core/rag/quivr_rag_langgraph.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class AgentState(TypedDict):
228228
user_metadata: Optional[dict[str, str]]
229229
additional_information: Optional[dict[str, str]]
230230
tool: str
231+
guidelines: str
232+
additional_information: str
231233

232234

233235
class IdempotentCompressor(BaseDocumentCompressor):
@@ -914,10 +916,12 @@ def generate_zendesk_rag(self, state: AgentState) -> AgentState:
914916
docs: List[Document] = tasks.docs if tasks else []
915917
messages = state["messages"]
916918
user_task = messages[0].content
917-
# TODO(@AmineDiro): Parse template f-strings and match with keys in state
919+
prompt_template: BasePromptTemplate = custom_prompts[
920+
TemplatePromptName.ZENDESK_TEMPLATE_PROMPT
921+
]
922+
918923
ticket_metadata = state["ticket_metadata"] or {}
919924
user_metadata = state["user_metadata"] or {}
920-
additional_information = state.get("additional_information", "")
921925

922926
inputs = {
923927
"similar_tickets": "\n".join([doc.page_content for doc in docs]),
@@ -927,12 +931,13 @@ def generate_zendesk_rag(self, state: AgentState) -> AgentState:
927931
"system_prompt": self.retrieval_config.prompt
928932
if self.retrieval_config.prompt
929933
else "",
930-
"additional_information": additional_information,
931934
}
935+
required_variables = prompt_template.input_variables
936+
for variable in required_variables:
937+
if variable not in inputs:
938+
inputs[variable] = state.get(variable, "")
932939

933-
msg = custom_prompts[TemplatePromptName.ZENDESK_TEMPLATE_PROMPT].format(
934-
**inputs
935-
)
940+
msg = prompt_template.format(**inputs)
936941
llm = self.bind_tools_to_llm(self.generate_zendesk_rag.__name__)
937942
response = llm.invoke(msg)
938943

0 commit comments

Comments
 (0)