serJD commited on
Commit
e424ebb
·
verified ·
1 Parent(s): dc0a1a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -1,30 +1,39 @@
1
  import gradio as gr
2
 
3
- def create_greeting_message(user_name, tone):
4
  """
5
  Creates a friendly or hostile user message for a user
 
6
  Args:
7
- user_name (str): the name of the user that needs a greeting message
8
- tone (str): choose between "friendly" and "hostile"
 
9
  Returns:
10
- A string with the user message
11
  """
12
-
13
  if tone == "friendly":
14
- greeting_msg = "Great to have you here " + user_name
15
  elif tone == "hostile":
16
- greeting_msg = "Ehm, soo cool to have you here " + user_name
17
  else:
18
- greeting_msg = "wrong argument for tone"
19
 
20
  return greeting_msg
21
 
 
 
 
 
 
 
22
  demo = gr.Interface(
23
  fn=create_greeting_message,
24
- inputs=[gr.Textbox(label="user_name"), gr.Textbox(label="tone")],
25
- outputs=gr.Textbox(label="Result"),
26
  title="create user greetings",
27
  description="creates user greeting text",
28
- api_name="user_greeting"
29
  )
30
- demo.launch(mcp_server=True)
 
 
 
1
  import gradio as gr
2
 
3
+ def create_greeting_message(user_name: str, tone: str) -> str:
4
  """
5
  Creates a friendly or hostile user message for a user
6
+
7
  Args:
8
+ user_name (str): the name of the user that needs a greeting message
9
+ tone (str): choose between "friendly" and "hostile"
10
+
11
  Returns:
12
+ str: A string with the user message
13
  """
 
14
  if tone == "friendly":
15
+ greeting_msg = "Great to have you here " + user_name
16
  elif tone == "hostile":
17
+ greeting_msg = "Ehm, soo cool to have you here " + user_name
18
  else:
19
+ greeting_msg = "wrong argument for tone"
20
 
21
  return greeting_msg
22
 
23
+ # Define components separately with labels matching function parameter names
24
+ user_name_input = gr.Textbox(label="user_name", placeholder="Enter your name")
25
+ tone_input = gr.Textbox(label="tone", placeholder="Enter friendly or hostile")
26
+ result_output = gr.Textbox(label="Result")
27
+
28
+ # Create interface with explicit api_name
29
  demo = gr.Interface(
30
  fn=create_greeting_message,
31
+ inputs=[user_name_input, tone_input],
32
+ outputs=result_output,
33
  title="create user greetings",
34
  description="creates user greeting text",
35
+ api_name="create_greeting_message"
36
  )
37
+
38
+ if __name__ == "__main__":
39
+ demo.launch(mcp_server=True)