Update app.py
Browse files48 unmodified lines49505152535455525354555657586263596061656662636465666768697370717576727374757677818278798081821 unmodified line84858690878889905 unmodified lines9697981029910010110248 unmodified lines response += token yield response
# Adding the model name at the end of the response yield f"\n\n[Response generated by model: {model_name}]"
# Model names and their custom display names# Model names and their pseudonymsmodel_choices = [ ("HuggingFaceH4/zephyr-7b-beta", "Lake [Test]"), ("google/mt5-base", "Lake 1 Base"), ("google/mt5-large", "Lake 1 Advanced")]
# Convert model choices into just the model names for the dropdownmodel_names = [model[0] for model in model_choices]# Convert pseudonyms to model names for the dropdownpseudonyms = [model[1] for model in model_choices]
# Function to handle model selection and display name for the modeldef respond_with_model_name(# Function to handle model selection and pseudonymsdef respond_with_pseudonym( message, history: list[tuple[str, str]], system_message, max_tokens, temperature, top_p, model_name selected_pseudonym): # Find the display name of the selected model model_display_name = dict(model_choices)[model_name] # Find the actual model name from the pseudonym model_name = next(model[0] for model in model_choices if model[1] == selected_pseudonym) # Call the existing respond function response = list(respond(message, history, system_message, max_tokens, temperature, top_p, model_name)) # Add model name at the end of the response response[-1] += f"\n\n[Response generated by: {model_display_name}]" # Add pseudonym at the end of the response response[-1] += f"\n\n[Response generated by: {selected_pseudonym}]" return response
1 unmodified lineFor information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface"""demo = gr.ChatInterface( respond_with_model_name, respond_with_pseudonym, additional_inputs=[ gr.Textbox(value="You are a friendly Chatbot.", label="System message"), gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),5 unmodified lines step=0.05, label="Top-p (nucleus sampling)", ), gr.Dropdown(model_names, label="Select Model", value=model_names[0]) # Model selection dropdown gr.Dropdown(pseudonyms, label="Select Model", value=pseudonyms[0]) # Pseudonym selection dropdown ],)
app.py+12-15