Find answers from the community

Updated 2 months ago

where is the prompt template that I can edit for when I call `query` on a query engine?

where is the prompt template that I can edit for when I call query on a query engine?
k
L
r
14 comments
Please stand by @ryanglambert as I search the knowledge base. We are experiencing especially high traffic right now and might take longer than usual. :wave:
----------------------
To edit the prompt template when calling query on a query engine, you need to customize the prompt based on the index you are using. Here are the prompt templates for different indices:

  1. For GPTEmptyIndex:
    Source: Querying an Empty Index (https://gpt-index.readthedocs.io/en/latest/reference/indices/empty_query.html)
  1. For GPTTreeIndex:
    Source: Querying a Tree Index (https://gpt-index.readthedocs.io/en/latest/reference/indices/tree_query.html)
  1. For GPTKeywordTableIndex:
    Source: Querying a Keyword Table Index (https://gpt-index.readthedocs.io/en/latest/reference/indices/table_query.html)
  1. For GPTKGTableIndex:
    Source: Querying a Knowledge Graph Index (https://gpt-index.readthedocs.io/en/latest/reference/indices/kg_query.html)
You can customize these prompt templates according to your needs. For more details on customizing prompts, refer to the Custom Prompts How-To (https://gpt-index.readthedocs.io/en/latest/how_to/customization/custom_prompts.html) guide.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Lol do you want the location in the codebase of the existing prompt templates?
Usually you'll want to customize both the text_qa_template and refine_template
❀️ you da man!
I'm using ComposableGraph.from_indices(GPTListIndex, ...

Does your advice still apply then?
Where do you put the text_qa_template and refine_template thing?
@kapa.ai where do we put text_qa_template and refine_template when we use ComposableGraph?
Let me check the knowledge base for you. One moment! :books:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the GPT index documentation for more information on customization and usage: GPT index documentation (https://gpt-index.readthedocs.io/en/latest/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
You'll put that in the custom query engines for each index πŸ‘
For reference the default templates are here:
https://github.com/jerryjliu/llama_index/blob/main/llama_index/prompts/default_prompts.py#L90

And if you are using gpt-3.5, there are specific prompts here (it only has a specific refine template. The other text_qa_template is converted into a single human message for gpt-3.5)

https://github.com/jerryjliu/llama_index/blob/main/llama_index/prompts/chat_prompts.py#L12
Add a reply
Sign up and join the conversation on Discord