Update app.py
Browse files1 unmodified line234567891011121319 unmodified lines333435363738394041424344454647481 unmodified linefrom transformers import pipeline# Function to generate text based on the modeldef chatbot(user_input, history, max_length=50, temperature=1.0):# Load the selected model (using a hard-coded model for now)model = pipeline("text-generation", model="google/mt5-base")# Get the model's responseresponse = model(user_input, max_length=max_length, temperature=temperature)[0]["generated_text"]# Append the user input and model's response to the historyhistory.append({"role": "user", "content": user_input})19 unmodified lineswith gr.Column(scale=0.1):send_button = gr.Button("📤", elem_id="send_button", scale=1)# Define settings menu, initially hiddenwith gr.Accordion("Settings", open=False) as settings:with gr.Column():max_length = gr.Slider(minimum=10, maximum=200, value=50, label="Max Length")temperature = gr.Slider(minimum=0.1, maximum=2.0, step=0.1, value=1.0, label="Temperature")# Connect the input to the chatbot function via the Send buttonsend_button.click(chatbot,inputs=[user_input, chatbot_component, max_length, temperature],outputs=chatbot_component,)1 unmodified line234567891011121319 unmodified lines333435363738394041421 unmodified linefrom transformers import pipeline# Function to generate text based on the modeldef chatbot(user_input, history):# Load the selected model (using a hard-coded model for now)model = pipeline("text-generation", model="google/mt5-base")# Get the model's responseresponse = model(user_input, max_length=50, temperature=1.0)[0]["generated_text"]# Append the user input and model's response to the historyhistory.append({"role": "user", "content": user_input})19 unmodified lineswith gr.Column(scale=0.1):send_button = gr.Button("📤", elem_id="send_button", scale=1)# Connect the input to the chatbot function via the Send buttonsend_button.click(chatbot,inputs=[user_input, chatbot_component],outputs=chatbot_component,)
app.py+3-9