Hi, I'm using
RouterRetriever
with
LLMSingleSelector
. The problem is that the selector prompt in
SelectorOutputParser
isn't in the format that I want. I have prompt template like this:
SINGLE_SELECTOR_PROMPT_TEMPLATE = (
"### System:\n"
"You are a helpful assistant. "
"Using only the choices above and not prior knowledge, return "
"the choice that is most relevant to the question: '{query_str}'\n"
"### User:\n"
"Some choices are given below. It is provided in a numbered list "
"(1 to {num_choices}), "
"where each item in the list corresponds to a summary.\n"
"---------------------\n"
"{context_list}"
"\n---------------------\n"
"### Assistant:\n"
)
...
retriever = RouterRetriever(
selector=LLMSingleSelector.from_defaults(
prompt_template_str=SINGLE_SELECTOR_PROMPT_TEMPLATE),
retriever_tools=[vs_tool, summary_tool]
)
However, the
SelectionOutputParser.parse
automatically append a
FORMAT_STR
like this
prompt_template + "\n\n" + _escape_curly_braces(FORMAT_STR)
which results in:
### System:
You are a helpful assistant. Using only the choices above and not prior knowledge, return the choice that is most relevant to the question: 'Summarize the uploaded document'
### User:
Some choices are given below. It is provided in a numbered list (1 to 2), where each item in the list corresponds to a summary.
---------------------
(1) Useful for retrieving specific context from uploaded documents.
(2) Useful to retrieve all context from uploaded documents and summary tasks. Don't use if the question only requires more specific context.
---------------------
### Assistant: ====> This phrase is in the wrong position.
The output should be ONLY JSON formatted as a JSON instance.
Here is an example:
[
{{
choice: 1,
reason: "<insert reason for choice>"
}},
...
]
How can I move the
### Assistant:
to right after the
FORMAT_STR
?