Find answers from the community

Updated 4 months ago

is there away to build a custom response

At a glance

The community member is interested in building a custom response synthesizer to speak like a salesman. In the comments, another community member suggests modifying the prompt to achieve this, providing an example of a prompt template that can be used with the LlamaIndex library. However, the original community member has a follow-up question about whether the prompt template needs to be assigned to the response synthesizer object, rather than the query engine as shown in the example. Another community member clarifies that the prompt template will be used by the response synthesizer only, and provides a link to the LlamaIndex documentation for more information on advanced prompt capabilities. The community member then asks if there is a way to attach a prompt to the query engine that gets the "essence" of the user's input before passing it to the similarity search, or if they should do this separately and pass the response as the query to the query engine.

Useful resources
is there away to build a custom response synthesizer? i want to add it to speak like a salesman,
W
s
5 comments
You can modify the prompt to achieve this.
Plain Text
from llama_index.core import PromptTemplate

template = (
    "We have provided context information below. \n"
    "---------------------\n"
    "{context_str}"
    "\n---------------------\n"
    "Given this information, please answer the question: {query_str}\n"
"ANSWER in salesman style"
)
qa_template = PromptTemplate(template)

query_engine = index.as_query_engine(
    text_qa_template=qa_template
)
ty for your answer, but would I not need to assign the qa template to the reponseSynthesizer object? in the example you assign it to the query engine
it will be used by the response synthesizer only, This was a high level API change.

If you want to change it into response synthesizer, you can do that from here: https://docs.llamaindex.ai/en/stable/module_guides/models/prompts/usage_pattern.html#advanced-advanced-prompt-capabilities
ok ty , and i have another question if u don't mind, is there a way to attach to the query engine a prompt that gets the "essence" of the input from the user before passing it to the similiary search?
or I should do it seperately and then pass the response as the query to the queryEngine?
Add a reply
Sign up and join the conversation on Discord