serJD's picture
Update app.py
e424ebb verified
raw
history blame
1.27 kB
import gradio as gr
def create_greeting_message(user_name: str, tone: str) -> str:
"""
Creates a friendly or hostile user message for a user
Args:
user_name (str): the name of the user that needs a greeting message
tone (str): choose between "friendly" and "hostile"
Returns:
str: A string with the user message
"""
if tone == "friendly":
greeting_msg = "Great to have you here " + user_name
elif tone == "hostile":
greeting_msg = "Ehm, soo cool to have you here " + user_name
else:
greeting_msg = "wrong argument for tone"
return greeting_msg
# Define components separately with labels matching function parameter names
user_name_input = gr.Textbox(label="user_name", placeholder="Enter your name")
tone_input = gr.Textbox(label="tone", placeholder="Enter friendly or hostile")
result_output = gr.Textbox(label="Result")
# Create interface with explicit api_name
demo = gr.Interface(
fn=create_greeting_message,
inputs=[user_name_input, tone_input],
outputs=result_output,
title="create user greetings",
description="creates user greeting text",
api_name="create_greeting_message"
)
if __name__ == "__main__":
demo.launch(mcp_server=True)