from langchain_core.prompts import ChatPromptTemplate from langchain_core.output_parsers import StrOutputParser from langchain_core.runnables import RunnablePassthrough from langchain_groq import ChatGroq rag_template = """ Provide a summary from the context, which contains interpretations of Quranic Texts that highlight the importance of the topic mentioned in the question. Do not include the Quranic Texts themselves, but mention which Surah and verse. Context: {context} Question: {question} """ def create_chain(retreiver): llm=ChatGroq(api_key="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" ,model="mixtral-8x7b-32768") rag_prompt=ChatPromptTemplate.from_template(rag_template) rag_chain=({"context":retreiver,"question":RunnablePassthrough()} | rag_prompt | llm | StrOutputParser() ) return rag_chain