I have a problem interfacing the main.py and stream lit.py ( OpenAi Assistant)

I have a problem when using streamlit interface to talk with the assistant. It works perfectly but when it has to call a function from the main.py it doesn’t work anymore. I think I should add in the streamlit_app.py the part of the main.py code where it has the chat part and calls the function. Here’s are the paste bin links. Please help me!! I think the part of the main to be copied/imported is the part of response generation and the part of the streamlit where it has to be pasted is from the raw 58 onwards (the part to create run with new thread)

streamlit_app.py streamlit_app.py - Pastebin.com

main.py main.py - Pastebin.com