I am trying to generate answers from a pdf content using langchain and gemini pro LLM but getting this error while generating the content-
TypeError: Unexpected value type: input_variables=[] input_types={} partial_variables={} template=’n Use the context to answer the question at the end.n You must always use the context and context only to answer the question. Never try to make up an answer. If the context is empty or you do not know the answer, just say “I don’t know”.nn Context: [‘ Temperature—In general, bacteria prefer warm temperatures. Those that prefer our food grow between 41–140°F (Temperature Danger Zone). This temperature range includes normal body temperature and usual room temperature. ‘]nn Question: What temperature range do Mesophilic Bacteria grow best in?nn answer:n ‘
The error is at the following line of code-
response = gen_model.generate_content(contents=prompt).text
The entire function block is here for the reference-
gen_model = GenerativeModel("gemini-1.5-pro-002")
context = search_vector_database(question)
# 1. Create a prompt_template with instructions to the model
# to use provided context info to answer the question.
prompt_template = f"""
Use the context to answer the question at the end.
You must always use the context and context only to answer the question. Never try to make up an answer. If the context is empty or you do not know the answer, just say "I don't know".
Context: {context}
Question: {question}
answer:
"""
# 3. Format the prompt template with the question & context
prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
# 4. Pass the complete prompt template to gemini and get the text
# of its response to return below.
response = gen_model.generate_content(contents=prompt).text
print("Answer:::", response)
I have checked the PromptTemplate class but could not figure out the error. Let me know if anybody has faced same issue or know how to fix this issue.