Streamlit being static

guys im trying to create a chatbot using python
it is working well but i have a serious problem
before i go here’s my code
if “messages” not in st.session_state.keys(): # Initialize the chat message history
st.session_state.messages = [
{“role”: “assistant”, “content”: “Hello how are you?:face_with_hand_over_mouth:”}

3.3. Load and index data

if prompt := st.chat_input(“Enter a message✍”): # Prompt for user input and save to chat history
st.session_state.messages.append({“role”: “user”, “content”: prompt})

for message in st.session_state.messages: # Display the prior chat messages
with st.chat_message(message[“role”]):

if st.session_state.messages[-1][“role”] != “assistant”:
with st.chat_message(“assistant”):
with st.spinner(“Thinking…”):
if ‘uwu’ in prompt:
elif ‘your name’ in prompt:
response=“You can call me Alvin👍”

        elif 'hello' in prompt:
            reslist = ['Hello dude how are you?', 'Heyyyy', 'Hello Cortex at your service',
                               'How may I help you?', 'How are you doing?',
                               'Hello! What are we going to do today??', 'Good day, how may I assist you?',
                               'Welcome, how can I be of service?', 'Greetings, how may I help you today?',
                               'Hello, how may I be of assistance to you?',
                               'Pleased to meet you, how can I support you?']
            respons = random.choice(reslist)
        elif 'open' in prompt:
            if 'chrome' in prompt:
            elif 'youtube' in prompt:
            elif 'amazon' in prompt:
            elif 'github' in prompt:
            elif 'stackoverflow' in prompt:
            elif 'chatgpt' in prompt:
            elif 'gmail' in prompt:
        # elif ''
        elif 'close' in prompt:         
          if 'chrome' in prompt:
              response='Closing chrome❎'
              os.system("taskkill /im chrome.exe /f")
          elif 'whatsapp' in prompt:
              response='Closing whatsapp❎'
              os.system("taskkill /im Whatsapp.exe /f")
          elif 'discord' in prompt:
            response='Closing discord❎'
            os.system("taskkill /im Discord.exe /f")
          elif 'vs code' in prompt:
            response='closing vs code❎'
            os.system("taskkill /im Code.exe /f")
        # elif 'joke' or 'make me laugh' in prompt:
        #      response=pyjokes.get_joke(language='en',category='all')
        elif 'time' in prompt:
            res ="%H:%M %p")
            rez='The current time is ' + res + '🕙'

        elif 'search' in prompt:
            query=prompt.replace('search', ' ')
            query=prompt.replace('google',' ')
            query=prompt.replace('alvin',' ')
            query=prompt.replace('bot',' ')
            url = f"{query}"

            #  x= 
            response='Performing google search for ',query,'🔎'
        elif 'play' in prompt:
            query=prompt.replace('play', '')
            response='searching on youtube 🫡'
            url = f"{query}&aq=0"
        # elif 'jai shree ram'
          re = Reply(prompt)
        message = {"role": "assistant", "content": response}

THe problem is my chat bot become static after i gave it prompt and black out and re runs and shows the result … Here’s

while entering the query
and here’s when query is done

how can i make it running for infinite?? so that it doesnt blacks out when used…
Please resolve my issue guys

Hi @buroperson

The formatting of the code was difficult to read, you can encapsulate the code in trip tick (```) symbol before and after the code to get something like the following:

import streamlit as st


It seems that the error message arises from the missing response variable. Which if not detected in the various other conditions (if and elif, it will finally resort to else) and here it seems to be using the Reply function to generate the response. Can you check that the Reply function is functioning properly in generating the necessary response.

Hope this helps!

Sir the problem is whenever I enter I query it gets into a blackout phase and then restarts itself after 1-3 seconds as shown in the
Screenshot of the query. is there any way I can solve that … The response function is a well tested and im definately sure it doesn’t have any problem

hi sir
i want you to know that reply function is working well it doesnt have any issues

Is there any by which i can remove this blackout phase or reduce it ??

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.