Spaces:
Running on Zero
Running on Zero
Add Streamable HTTP MCP client and live DeepWiki example
Browse files- app.py +20 -0
- harnesslab_bundle.zip +2 -2
- manifest.json +6 -1
app.py
CHANGED
|
@@ -63,6 +63,20 @@ def main() -> None:
|
|
| 63 |
report_id = store_report(load_batch(Path(path)), "real_live")
|
| 64 |
return {**result, "workspace_report": f"/?report={report_id}"}
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
@spaces.GPU(duration=10)
|
| 67 |
def gpu_environment_check() -> dict[str, str | float]:
|
| 68 |
"""Optional real CUDA check; never invoked during startup or Mock runs."""
|
|
@@ -87,10 +101,16 @@ def main() -> None:
|
|
| 87 |
artifact = gr.File(label="평가 Trace JSON 다운로드")
|
| 88 |
event = execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)
|
| 89 |
event.then(publish_result, inputs=[summary, artifact], outputs=[summary], api_name=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
|
| 91 |
diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
|
| 92 |
gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
|
| 93 |
diagnostic.click(gpu_environment_check, inputs=[], outputs=[gpu_result], api_name="gpu_environment")
|
|
|
|
| 94 |
application = gr.mount_gradio_app(workspace, info, path="/gradio", ssr_mode=False)
|
| 95 |
# Mounting bypasses Blocks.launch(), which normally sends this registration.
|
| 96 |
try:
|
|
|
|
| 63 |
report_id = store_report(load_batch(Path(path)), "real_live")
|
| 64 |
return {**result, "workspace_report": f"/?report={report_id}"}
|
| 65 |
|
| 66 |
+
def test_public_mcp() -> tuple[dict, str]:
|
| 67 |
+
from harness.mcp_client import MCPClient
|
| 68 |
+
with MCPClient("https://mcp.deepwiki.com/mcp") as client:
|
| 69 |
+
server = client.initialize()
|
| 70 |
+
tools = client.list_tools()
|
| 71 |
+
result = client.call_tool("read_wiki_structure", {"repoName": "openai/openai-python"})
|
| 72 |
+
record = {"server": server, "protocol_version": client.protocol_version,
|
| 73 |
+
"endpoint": "https://mcp.deepwiki.com/mcp", "tools": [tool.name for tool in tools],
|
| 74 |
+
"called_tool": "read_wiki_structure", "arguments": {"repoName": "openai/openai-python"},
|
| 75 |
+
"call": result.model_dump(mode="json")}
|
| 76 |
+
path = Path(tempfile.gettempdir()) / f"harnesslab-mcp-{uuid4()}.json"
|
| 77 |
+
path.write_text(json.dumps(record, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 78 |
+
return record, str(path)
|
| 79 |
+
|
| 80 |
@spaces.GPU(duration=10)
|
| 81 |
def gpu_environment_check() -> dict[str, str | float]:
|
| 82 |
"""Optional real CUDA check; never invoked during startup or Mock runs."""
|
|
|
|
| 101 |
artifact = gr.File(label="평가 Trace JSON 다운로드")
|
| 102 |
event = execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)
|
| 103 |
event.then(publish_result, inputs=[summary, artifact], outputs=[summary], api_name=False)
|
| 104 |
+
gr.Markdown("## 외부 MCP 연동 예제 — DeepWiki\nGPU나 API 키 없이 외부 공개 MCP 서버의 도구 목록을 읽고, openai/openai-python 문서 목차를 조회합니다.")
|
| 105 |
+
mcp_button = gr.Button("DeepWiki MCP 연결 테스트 — GPU 미사용")
|
| 106 |
+
mcp_result = gr.JSON(label="MCP 실제 호출 결과")
|
| 107 |
+
mcp_file = gr.File(label="MCP 호출 기록 JSON")
|
| 108 |
+
mcp_button.click(test_public_mcp, inputs=[], outputs=[mcp_result, mcp_file], api_name="test_deepwiki_mcp", concurrency_limit=1)
|
| 109 |
gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
|
| 110 |
diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
|
| 111 |
gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
|
| 112 |
diagnostic.click(gpu_environment_check, inputs=[], outputs=[gpu_result], api_name="gpu_environment")
|
| 113 |
+
info.show_error = True
|
| 114 |
application = gr.mount_gradio_app(workspace, info, path="/gradio", ssr_mode=False)
|
| 115 |
# Mounting bypasses Blocks.launch(), which normally sends this registration.
|
| 116 |
try:
|
harnesslab_bundle.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c3be34498172cd817e39263fe2ed184401553dac95e026b1cbbdc50c23049096
|
| 3 |
+
size 59566
|
manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"release": "HarnessLab Gradio Space Prototype",
|
| 3 |
-
"bundle_sha256": "
|
| 4 |
"files": [
|
| 5 |
{
|
| 6 |
"path": "harness/__init__.py",
|
|
@@ -37,6 +37,11 @@
|
|
| 37 |
"bytes": 730,
|
| 38 |
"sha256": "14dd56423f323c5391d55dc70e5d10a070ffa37ae3a26c8080013aff4386a3f7"
|
| 39 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
{
|
| 41 |
"path": "harness/order_tools.py",
|
| 42 |
"bytes": 3171,
|
|
|
|
| 1 |
{
|
| 2 |
"release": "HarnessLab Gradio Space Prototype",
|
| 3 |
+
"bundle_sha256": "c3be34498172cd817e39263fe2ed184401553dac95e026b1cbbdc50c23049096",
|
| 4 |
"files": [
|
| 5 |
{
|
| 6 |
"path": "harness/__init__.py",
|
|
|
|
| 37 |
"bytes": 730,
|
| 38 |
"sha256": "14dd56423f323c5391d55dc70e5d10a070ffa37ae3a26c8080013aff4386a3f7"
|
| 39 |
},
|
| 40 |
+
{
|
| 41 |
+
"path": "harness/mcp_client.py",
|
| 42 |
+
"bytes": 8016,
|
| 43 |
+
"sha256": "0024aac13d1a646f97937fb5f3500f52d2f707f580d39c4f0b45eb5395d639f4"
|
| 44 |
+
},
|
| 45 |
{
|
| 46 |
"path": "harness/order_tools.py",
|
| 47 |
"bytes": 3171,
|