Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
| 1 |
"""
|
| 2 |
-
NWFWO Practice
|
| 3 |
|
| 4 |
-
This file does two things:
|
| 5 |
1) Runs a normal Gradio web app (for debugging in your browser)
|
| 6 |
2) Exposes an MCP server + HTML UI card for ChatGPT Apps
|
| 7 |
"""
|
| 8 |
|
| 9 |
-
import gradio as gr
|
| 10 |
from dataclasses import dataclass
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
-
# ---- 1. Data model for the
|
| 14 |
|
| 15 |
@dataclass
|
| 16 |
class NWFWOExample:
|
|
@@ -19,17 +20,17 @@ class NWFWOExample:
|
|
| 19 |
# The correct NWFWO answer (what the learner should guess)
|
| 20 |
correct_nwfwo: str
|
| 21 |
# Optional: explanation to show after checking
|
| 22 |
-
explanation: str
|
| 23 |
|
| 24 |
|
| 25 |
-
# ---- 2. Core tool logic: check the learner
|
| 26 |
|
| 27 |
@gr.mcp.tool() # exposes the function as an MCP tool to ChatGPT / MCP clients
|
| 28 |
def check_nwfwo(
|
| 29 |
transliteration: str,
|
| 30 |
correct_nwfwo: str,
|
| 31 |
user_guess: str,
|
| 32 |
-
explanation: str
|
| 33 |
):
|
| 34 |
"""
|
| 35 |
Simple checker for NWFWO practice.
|
|
@@ -69,7 +70,7 @@ def check_nwfwo(
|
|
| 69 |
return result
|
| 70 |
|
| 71 |
|
| 72 |
-
# ---- 3. Normal Gradio UI (handy while you
|
| 73 |
|
| 74 |
def local_check_ui(transliteration, correct_nwfwo, user_guess, explanation):
|
| 75 |
res = check_nwfwo(
|
|
|
|
| 1 |
"""
|
| 2 |
+
NWFWO Practice - Gradio MCP app for ChatGPT
|
| 3 |
|
|
|
|
| 4 |
1) Runs a normal Gradio web app (for debugging in your browser)
|
| 5 |
2) Exposes an MCP server + HTML UI card for ChatGPT Apps
|
| 6 |
"""
|
| 7 |
|
|
|
|
| 8 |
from dataclasses import dataclass
|
| 9 |
+
from typing import Optional
|
| 10 |
+
|
| 11 |
+
import gradio as gr
|
| 12 |
|
| 13 |
|
| 14 |
+
# ---- 1. Data model for the "game state" ----
|
| 15 |
|
| 16 |
@dataclass
|
| 17 |
class NWFWOExample:
|
|
|
|
| 20 |
# The correct NWFWO answer (what the learner should guess)
|
| 21 |
correct_nwfwo: str
|
| 22 |
# Optional: explanation to show after checking
|
| 23 |
+
explanation: Optional[str] = None
|
| 24 |
|
| 25 |
|
| 26 |
+
# ---- 2. Core tool logic: check the learner's guess ----
|
| 27 |
|
| 28 |
@gr.mcp.tool() # exposes the function as an MCP tool to ChatGPT / MCP clients
|
| 29 |
def check_nwfwo(
|
| 30 |
transliteration: str,
|
| 31 |
correct_nwfwo: str,
|
| 32 |
user_guess: str,
|
| 33 |
+
explanation: Optional[str] = None,
|
| 34 |
):
|
| 35 |
"""
|
| 36 |
Simple checker for NWFWO practice.
|
|
|
|
| 70 |
return result
|
| 71 |
|
| 72 |
|
| 73 |
+
# ---- 3. Normal Gradio UI (handy while you're developing) ----
|
| 74 |
|
| 75 |
def local_check_ui(transliteration, correct_nwfwo, user_guess, explanation):
|
| 76 |
res = check_nwfwo(
|