Spaces:
Sleeping
Sleeping
File size: 930 Bytes
3cd1288 06be2af 2243607 3cd1288 2243607 3cd1288 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import gradio as gr
def letter_counter(word, letter):
"""Count the occurrences of a specific letter in a word.
Args:
word: The word or phrase to analyze
letter: The letter to count occurrences of
Returns:
The number of times the letter appears in the word
"""
return word.lower().count(letter.lower())
@gr.mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""Get a personalized greeting"""
return f"Hello, {name}!"
int1 = gr.Interface(
fn=letter_counter,
inputs=["text", "text"],
outputs="number",
title="Letter Counter",
description="Count how many times a letter appears in a word"
)
demo = gr.TabbedInterface(
[
int1,
gr.Interface(get_greeting, gr.Textbox("Abubakar"), gr.Textbox()),
],
[
"Add",
"Get Greeting",
"Greet User",
]
)
demo.launch(mcp_server=True)
|