Menu page calling a script that runs langchain

Dear,
I have a chatbot script that runs perfectly from the terminal. This script runs
a = qa_chain.invoke({“query”: query]})
b =a[“result”]
st.write(b)
But when I call it from the home.py, it runs everything until the line (a = qa_chain.invoke({“query”: query]})) it simply gets out from the code, without any error message. I have already used Try: , and streamlit run home.py --logger.level=debug: I am trying to figure out a problem but have had no answer.
Could someone help me?
tks a lot