Connect colab notebook chatbot to anvil with Anvil-uplink

What I’m trying to do: To connect my chatbot from colab notebook to anvil interface

What I’ve tried and what’s not working:
I’ve already created the chatbot, added the !pip install anvil_uplink, import server with server key, defined a function you can call from anvil to get bot response. Lastly, defined a function when button is clicked.
I seem to encounter issues with my button defined function.

Code Sample:

# ON MY COLAB NOTEBOOK I DID THE FOLLOWING.
!pip install anvil-uplink

import anvil.server

anvil.server.connect("SERVER_KEY INCLUDED")

#@anvil.server.callable
def get_chatbot_response(input_text):
    response = match_response(input_text)
    return response
#entire chatbot code here!!!!

anvil.server.wait_forever()






# ON ANVIL I DID THE FOLLOWING
#defined a function when the button is clicked a response is retrieved from colab notebook and displayed on rich text area.

def button_1_click(self, **event_args):
    """This method is called when the button is clicked"""

    # Establish the connection with the Anvil server
    anvil.server.connect("SERVER_KEY INCLUDED")
    
   # Get the user input from the text box component
    input_text = self.input_text.text

    # Call the Colab chatbot function using Anvil server
    response = anvil.server.call('my_colab_chatbot_function', input_text)

    # Set the response in the label component
    self.response.text = response

   # Set the event handler for the button click
   self.send_message.set_event_handler('click', button_click)

    #Inside the event handler for the send button click
    self.text_area_1.text = ''

#rich_text_1 renamed to "response"
#text_area_1 renamed to "input_text"
#button_1 renamed to "send_message"

Clone link:Anvil | Login

It generally helps if you’re encountering an issue if you say what error message you received. Helps give people a direction to look in.

Going just by the code samples you posted, some general comments:

You’ve commented out the @anvil.server.callable decoration. That means the function cannot be called as an Anvil server function.

Even if you uncommented out the decoration, you’re trying to call a server function named my_colab_chatbot_function, but your function is actually named get_chatbot_response. That won’t work.