Spaces:
Running on Zero
Running on Zero
mcp
Browse files- apitest.py +2 -2
- app.py +5 -1
- requirements.txt +2 -2
- tests/test_markup.py +6 -0
apitest.py
CHANGED
|
@@ -2,8 +2,8 @@ from gradio_client import Client
|
|
| 2 |
|
| 3 |
client = Client("al1808th/macronizer")
|
| 4 |
result = client.predict(
|
| 5 |
-
text="
|
| 6 |
-
model_label="
|
| 7 |
api_name="/render_results",
|
| 8 |
)
|
| 9 |
print(result)
|
|
|
|
| 2 |
|
| 3 |
client = Client("al1808th/macronizer")
|
| 4 |
result = client.predict(
|
| 5 |
+
text="ἀάατος",
|
| 6 |
+
model_label="mega",
|
| 7 |
api_name="/render_results",
|
| 8 |
)
|
| 9 |
print(result)
|
app.py
CHANGED
|
@@ -16,7 +16,7 @@ MODEL_OPTIONS: Dict[str, str] = {
|
|
| 16 |
"Macronizer Mega v1 (Pretrained ModernBERT)": "Ericu950/SyllaMoBert-grc-macronizer-v1",
|
| 17 |
"Macronizer Mini v1 (Fine-tuned RoBERTa)": "Ericu950/macronizer_mini",
|
| 18 |
}
|
| 19 |
-
DEFAULT_MODEL_LABEL = "Macronizer
|
| 20 |
DEFAULT_MODEL_ID = MODEL_OPTIONS[DEFAULT_MODEL_LABEL]
|
| 21 |
MODEL_ALIASES: Dict[str, str] = {
|
| 22 |
"mega": MODEL_OPTIONS["Macronizer Mega v1 (Pretrained ModernBERT)"],
|
|
@@ -513,6 +513,7 @@ def render_results(text: str, model_label: str):
|
|
| 513 |
|
| 514 |
|
| 515 |
def render_plain_output(text: str, model_label: str = "mega") -> str:
|
|
|
|
| 516 |
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
| 517 |
if not lines:
|
| 518 |
return ""
|
|
@@ -692,11 +693,13 @@ with gr.Blocks(title="Ancient Greek Macronizer") as demo:
|
|
| 692 |
inputs=[text_input, model_choice],
|
| 693 |
outputs=[html_output, text_output],
|
| 694 |
api_name=False,
|
|
|
|
| 695 |
)
|
| 696 |
clear_btn.click(
|
| 697 |
lambda: ("", "", ""),
|
| 698 |
outputs=[text_input, html_output, text_output],
|
| 699 |
api_name=False,
|
|
|
|
| 700 |
)
|
| 701 |
api_btn.click(
|
| 702 |
render_plain_output,
|
|
@@ -710,5 +713,6 @@ if __name__ == "__main__":
|
|
| 710 |
demo.launch(
|
| 711 |
css=CSS,
|
| 712 |
footer_links=["settings", "api"],
|
|
|
|
| 713 |
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="cyan", neutral_hue="slate"),
|
| 714 |
)
|
|
|
|
| 16 |
"Macronizer Mega v1 (Pretrained ModernBERT)": "Ericu950/SyllaMoBert-grc-macronizer-v1",
|
| 17 |
"Macronizer Mini v1 (Fine-tuned RoBERTa)": "Ericu950/macronizer_mini",
|
| 18 |
}
|
| 19 |
+
DEFAULT_MODEL_LABEL = "Macronizer Mini v1 (Fine-tuned RoBERTa)"
|
| 20 |
DEFAULT_MODEL_ID = MODEL_OPTIONS[DEFAULT_MODEL_LABEL]
|
| 21 |
MODEL_ALIASES: Dict[str, str] = {
|
| 22 |
"mega": MODEL_OPTIONS["Macronizer Mega v1 (Pretrained ModernBERT)"],
|
|
|
|
| 513 |
|
| 514 |
|
| 515 |
def render_plain_output(text: str, model_label: str = "mega") -> str:
|
| 516 |
+
"""Return Ancient Greek vowel-length markup for text using model_label mega or mini."""
|
| 517 |
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
| 518 |
if not lines:
|
| 519 |
return ""
|
|
|
|
| 693 |
inputs=[text_input, model_choice],
|
| 694 |
outputs=[html_output, text_output],
|
| 695 |
api_name=False,
|
| 696 |
+
api_visibility="private",
|
| 697 |
)
|
| 698 |
clear_btn.click(
|
| 699 |
lambda: ("", "", ""),
|
| 700 |
outputs=[text_input, html_output, text_output],
|
| 701 |
api_name=False,
|
| 702 |
+
api_visibility="private",
|
| 703 |
)
|
| 704 |
api_btn.click(
|
| 705 |
render_plain_output,
|
|
|
|
| 713 |
demo.launch(
|
| 714 |
css=CSS,
|
| 715 |
footer_links=["settings", "api"],
|
| 716 |
+
mcp_server=True,
|
| 717 |
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="cyan", neutral_hue="slate"),
|
| 718 |
)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio
|
| 2 |
grc-utils==0.2.2
|
| 3 |
torch
|
| 4 |
-
transformers
|
|
|
|
| 1 |
+
gradio[mcp]
|
| 2 |
grc-utils==0.2.2
|
| 3 |
torch
|
| 4 |
+
transformers
|
tests/test_markup.py
CHANGED
|
@@ -208,6 +208,12 @@ def test_public_api_endpoint_is_plain_output_only():
|
|
| 208 |
assert len(public_deps[0].get("outputs", [])) == 1
|
| 209 |
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
def test_public_api_text_example_is_greek():
|
| 212 |
import app
|
| 213 |
|
|
|
|
| 208 |
assert len(public_deps[0].get("outputs", [])) == 1
|
| 209 |
|
| 210 |
|
| 211 |
+
def test_mcp_tool_surface_exposes_only_plain_endpoint():
|
| 212 |
+
import app
|
| 213 |
+
|
| 214 |
+
assert set(app.demo.get_api_info()["named_endpoints"]) == {"/render_results"}
|
| 215 |
+
|
| 216 |
+
|
| 217 |
def test_public_api_text_example_is_greek():
|
| 218 |
import app
|
| 219 |
|