Find answers from the community

Updated last year

LlamaIndex prompts

Hello, I'm using this import for prompt template
from llama_index.prompts.base import PromptTemplate
from llama_index.prompts.prompt_type import PromptType

Ang get below warnings:

UserWarning: Importing BasePromptTemplate from langchain root module is no longer supported.

UserWarning: Importing PromptTemplate from langchain root module is no longer supported.

Any updates on llamaindex impacting this ? BTW why langchain is mentioned ?
W
x
L
11 comments
I don't think there would be any impact.

langchain prompts were also there in llamaindex. And I think llamaindex is slowly removing dependency on langchain.
and why are this warnings?

UserWarning: Importing BasePromptTemplate from langchain root module is no longer supported.

UserWarning: Importing PromptTemplate from langchain root module is no longer supported.
sounds like langchain updated their imports and is causing these warnings
If you update llama-index, we no longer use langchain for our prompt templates
I updated to latest versions, I think this was the reason geting the warnings

langchain 0.0.303
llama-index 0.8.35
hmm it might be coming from the latest langchain version then
I will see if I can remove the imports to the prompts, it must be happening in our bridge file -- we are hoping to move enitrely off of any langchain dependency soon.
I'm using now:
Plain Text
from llama_index.prompts.base import PromptTemplate
from llama_index.prompts.prompt_type import PromptType


CUST_QA_PROMPT = PromptTemplate(CUST_PROMPT_TEMPLATE, prompt_type=PromptType.QUESTION_ANSWER)
CUST_REFINE_PROMPT = PromptTemplate(CUST_REFINE_PROMPT_TEMPLATE, prompt_type=PromptType.REFINE)


I should fallow new format from here https://gpt-index.readthedocs.io/en/stable/core_modules/model_modules/prompts.html#usage-pattern ?
Plain Text
from llama_index.prompts 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"
)
qa_template = PromptTemplate(template)

# you can create text prompt (for completion API) 
prompt = qa_template.format(context_str=..., query_str=...)

# or easily convert to message prompts (for chat API)
messages = qa_template.format_messages(context_str=..., query_str=...)
Add a reply
Sign up and join the conversation on Discord