Upload RPC-Bench Space
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import json
|
|
|
|
| 4 |
import os
|
| 5 |
import shutil
|
| 6 |
import tempfile
|
|
@@ -11,6 +12,7 @@ from pathlib import Path
|
|
| 11 |
import gradio as gr
|
| 12 |
import pandas as pd
|
| 13 |
from huggingface_hub import Repository
|
|
|
|
| 14 |
|
| 15 |
try:
|
| 16 |
import gradio_client.utils as gradio_client_utils
|
|
@@ -26,6 +28,53 @@ try:
|
|
| 26 |
except Exception:
|
| 27 |
pass
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
from constants import (
|
| 30 |
ALL_COLUMNS,
|
| 31 |
CITATION,
|
|
@@ -284,4 +333,4 @@ with gr.Blocks(title=SPACE_TITLE) as demo:
|
|
| 284 |
|
| 285 |
|
| 286 |
if __name__ == "__main__":
|
| 287 |
-
demo.launch(
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import json
|
| 4 |
+
import inspect
|
| 5 |
import os
|
| 6 |
import shutil
|
| 7 |
import tempfile
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
import pandas as pd
|
| 14 |
from huggingface_hub import Repository
|
| 15 |
+
from starlette.templating import Jinja2Templates
|
| 16 |
|
| 17 |
try:
|
| 18 |
import gradio_client.utils as gradio_client_utils
|
|
|
|
| 28 |
except Exception:
|
| 29 |
pass
|
| 30 |
|
| 31 |
+
try:
|
| 32 |
+
_original_template_response = Jinja2Templates.TemplateResponse
|
| 33 |
+
_template_response_params = list(inspect.signature(_original_template_response).parameters.keys())
|
| 34 |
+
_template_response_request_first = len(_template_response_params) > 1 and _template_response_params[1] == "request"
|
| 35 |
+
|
| 36 |
+
def _compat_template_response(self, *args, **kwargs):
|
| 37 |
+
request = kwargs.pop("request", None)
|
| 38 |
+
name = kwargs.pop("name", None)
|
| 39 |
+
context = kwargs.pop("context", None)
|
| 40 |
+
|
| 41 |
+
if args:
|
| 42 |
+
if len(args) == 1:
|
| 43 |
+
if isinstance(args[0], str):
|
| 44 |
+
name = args[0]
|
| 45 |
+
else:
|
| 46 |
+
request = args[0]
|
| 47 |
+
else:
|
| 48 |
+
if isinstance(args[0], str) and isinstance(args[1], dict):
|
| 49 |
+
name = args[0]
|
| 50 |
+
context = args[1]
|
| 51 |
+
request = context.get("request", request)
|
| 52 |
+
else:
|
| 53 |
+
request = args[0]
|
| 54 |
+
name = args[1]
|
| 55 |
+
if len(args) > 2:
|
| 56 |
+
context = args[2]
|
| 57 |
+
|
| 58 |
+
if context is None:
|
| 59 |
+
context = {}
|
| 60 |
+
if request is None and isinstance(context, dict):
|
| 61 |
+
request = context.get("request")
|
| 62 |
+
if request is None:
|
| 63 |
+
raise TypeError("TemplateResponse requires a request object")
|
| 64 |
+
if not isinstance(context, dict):
|
| 65 |
+
context = dict(context)
|
| 66 |
+
if "request" not in context:
|
| 67 |
+
context = dict(context)
|
| 68 |
+
context["request"] = request
|
| 69 |
+
|
| 70 |
+
if _template_response_request_first:
|
| 71 |
+
return _original_template_response(self, request, name, context, **kwargs)
|
| 72 |
+
return _original_template_response(self, name, context, **kwargs)
|
| 73 |
+
|
| 74 |
+
Jinja2Templates.TemplateResponse = _compat_template_response
|
| 75 |
+
except Exception:
|
| 76 |
+
pass
|
| 77 |
+
|
| 78 |
from constants import (
|
| 79 |
ALL_COLUMNS,
|
| 80 |
CITATION,
|
|
|
|
| 333 |
|
| 334 |
|
| 335 |
if __name__ == "__main__":
|
| 336 |
+
demo.launch(show_api=False)
|