how to deal with dict input type in langchain

334 views Asked by At

i tried to make the input type to the PromptTemplate dict type and access values in the f-string template

from langchain.prompts.prompt import PromptTemplate
from langchain.llms import GooglePalm
prompt_template_advice = PromptTemplate(
input_types={"data" : dict},
input_variables = ["data"],
template=" ...{data['Gender']} ...{data['Age']}... {data['output']} (etc)"
)
advisor=GooglePalm(temperature=0.9)
advice_chain = LLMChain(verbose = True , llm=advisor , prompt= prompt_template_advice,output_key="main_advice")
advice_chain.run(data)

returns this error

Missing some input keys: {"data['BMI']", "data['TUE']", "data['FAF']", "data['NCP']", "data['CAEC']", "data['Gender']", "data['FAVC']", "data['MTRANS']", "data['SCC']", "data['CALC']", "data['Age']", "data['family_history_with_overweight']", "data['output']"}
0

There are 0 answers