File size: 1,825 Bytes
709c089
4e61a88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709c089
4e61a88
709c089
4e61a88
 
 
 
 
709c089
4e61a88
709c089
4e61a88
 
 
709c089
4e61a88
 
 
709c089
4e61a88
709c089
4e61a88
709c089
4e61a88
 
 
 
 
 
 
 
 
 
 
709c089
 
 
4e61a88
 
 
709c089
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gradio Lite Test</title>

    <script type="module" crossorigin
        src="https://gradio-lite-previews.s3.amazonaws.com/PINNED_HF_HUB/dist/lite.js">
    </script>

    <link rel="stylesheet"
        href="https://gradio-lite-previews.s3.amazonaws.com/PINNED_HF_HUB/dist/lite.css"/>

    <style>
        html, body {
            height: 100%;
            margin: 0;
        }
        gradio-lite {
            display: block;
            height: 100%;
        }
    </style>
</head>

<body>

<gradio-lite>

<gradio-file name="app.py" entrypoint>
# ------------------------------------------------------------------
# Workaround for Starlette expecting query_string as bytes
# ------------------------------------------------------------------
import starlette.datastructures as _sd

_original_init = _sd.URL.__init__

def _patched_init(self, url="", scope=None, **kwargs):
    if scope is not None:
        scope = dict(scope)

        qs = scope.get("query_string")
        if isinstance(qs, str):
            scope["query_string"] = qs.encode("latin-1")

    return _original_init(self, url=url, scope=scope, **kwargs)

_sd.URL.__init__ = _patched_init

# ------------------------------------------------------------------
# Gradio app
# ------------------------------------------------------------------
import gradio as gr

def respond(message, history):
    response = f"You said: {message}\nAnd I say I love learning AI Engineering with SuperDataScience!"
    return response

gr.ChatInterface(fn=respond).launch()
</gradio-file>
            <gradio-requirements>
# Same syntax as requirements.txt
            </gradio-requirements>
</gradio-lite>

</body>
</html>