I am using if else block for conditioning the execution as follows:
is_initialized = False
def process_interaction(prompt, is_initialized):
# No need for global flag
if is_initialized == False:
# Assume this function extracts and processes the URL
url = prompt
print("Up....")
site_id = get_sharepoint_site_id(hostname, site_path)
content = fetch_file_content(token, site_id, extract_file_path(url))
response = processQuery(content, query=None, isStart=False)
st.write("Document is inserted..")
is_initialized = True
else:
# Assume this is when isStarted is True and you process the query
query = prompt
print("Lower if...")
response = processQuery(content="content", query=query, isStart=True)
st.write(response)
and i am calling this function like this:
with st.chat_message("assistant", avatar=BOT_AVATAR):
message_placeholder = st.empty()
response = process_interaction(prompt, is_initialized)
as is_initialized is set to True in the first run then it should run the else block but everytime it is running the if block.
I have tried to change the variable in the if block but it is always running the if block and not the else block.
I am new to python any help will be highly appreciable.