from modules.lawbot.rag_with_langchain import load_documents, split_documents, create_vectorstore, setup_rag_chain, answer_query # Initialize RAg chain once documents = load_documents() docs = split_documents(documents) vectorstore = create_vectorstore(docs) qa_chain = setup_rag_chain(vectorstore) def lawbot_interface(query, chat_history=None): if not query.strip(): return "⚠️ Please enter a valid legal question." return answer_query(query, qa_chain, chat_history)