Spaces:
Build error
Build error
| import gradio as gr | |
| import json | |
| from PIL import Image | |
| import numpy as np | |
| # --- User Defined Logic --- | |
| def strawberry(word: str, letter: str) -> int: | |
| """Count how many times a specific letter appears in a word. | |
| Args: | |
| word: The word in which to count occurrences. | |
| letter: The single letter to count within the word. | |
| Returns: | |
| The number of times the specified letter appears in the word. | |
| """ | |
| if not isinstance(word, str): | |
| raise TypeError("word must be a string") | |
| if not isinstance(letter, str): | |
| raise TypeError("letter must be a string") | |
| if len(letter) != 1: | |
| raise ValueError("letter must be a single character") | |
| return word.count(letter) | |
| # --- Interface Factory --- | |
| def create_interface(): | |
| return gr.Interface( | |
| fn=strawberry, | |
| inputs=[gr.Textbox(label=k) for k in ['word', 'letter']], | |
| outputs=gr.Textbox(label="Number of occurrences of the letter in the word"), | |
| title="strawberry", | |
| description="Auto-generated tool: strawberry" | |
| ) |