Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +33 -0
- mcp_server.log +6 -0
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
# Configure logging to log to a file with .log extension
|
| 5 |
+
logging.basicConfig(filename="mcp_server.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s", filemode="a")
|
| 6 |
+
logger = logging.getLogger(__name__)
|
| 7 |
+
|
| 8 |
+
def letter_counter(word, letter):
|
| 9 |
+
"""Count the occurrences of a specific letter in a word.
|
| 10 |
+
|
| 11 |
+
Args:
|
| 12 |
+
word: The word or phrase to analyze
|
| 13 |
+
letter: The letter to count occurrences of
|
| 14 |
+
|
| 15 |
+
Returns:
|
| 16 |
+
The number of times the letter appears in the word
|
| 17 |
+
"""
|
| 18 |
+
logger.info(f"Called letter_counter with word='{word}', letter='{letter}'")
|
| 19 |
+
count = word.lower().count(letter.lower())
|
| 20 |
+
logger.info(f"Count result: {count}")
|
| 21 |
+
return count
|
| 22 |
+
|
| 23 |
+
logger.info("Creating Gradio Interface for letter_counter.")
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=letter_counter,
|
| 26 |
+
inputs=["text", "text"],
|
| 27 |
+
outputs="number",
|
| 28 |
+
title="Letter Counter",
|
| 29 |
+
description="Count how many times a letter appears in a word"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
logger.info("Launching Gradio Interface with MCP server mode.")
|
| 33 |
+
demo.launch(mcp_server=True, server_port=8889)
|
mcp_server.log
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-05-03 10:56:29,011 - INFO - Creating Gradio Interface for letter_counter.
|
| 2 |
+
2025-05-03 10:56:29,069 - INFO - Launching Gradio Interface with MCP server mode.
|
| 3 |
+
2025-05-03 10:56:29,305 - INFO - HTTP Request: GET http://127.0.0.1:8889/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 4 |
+
2025-05-03 10:56:29,325 - INFO - HTTP Request: HEAD http://127.0.0.1:8889/ "HTTP/1.1 200 OK"
|
| 5 |
+
2025-05-03 10:56:30,278 - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 6 |
+
2025-05-03 10:59:29,929 - INFO - Processing request of type ListToolsRequest
|