Spaces:
Runtime error
Runtime error
gmerrill
commited on
Commit
·
d7cc957
1
Parent(s):
02b4c7b
update
Browse files- main.py +4 -5
- requirements.txt +2 -1
- static/index.html +15 -19
- static/script.js +1 -1
- static/style.css +5 -33
main.py
CHANGED
@@ -8,13 +8,12 @@ app = FastAPI()
|
|
8 |
|
9 |
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
|
11 |
-
@app.get("/
|
12 |
-
def
|
13 |
-
output
|
14 |
-
return {"output": output[0]["generated_text"]}
|
15 |
|
16 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
17 |
|
18 |
@app.get("/")
|
19 |
def index() -> FileResponse:
|
20 |
-
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
|
|
8 |
|
9 |
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
|
11 |
+
@app.get("/query_gorilla")
|
12 |
+
def query_gorilla(input):
|
13 |
+
return {"output": "Test Result"}
|
|
|
14 |
|
15 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
16 |
|
17 |
@app.get("/")
|
18 |
def index() -> FileResponse:
|
19 |
+
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
requirements.txt
CHANGED
@@ -4,4 +4,5 @@ sentencepiece==0.1.*
|
|
4 |
torch==1.11.*
|
5 |
transformers==4.*
|
6 |
uvicorn[standard]==0.17.*
|
7 |
-
|
|
|
|
4 |
torch==1.11.*
|
5 |
transformers==4.*
|
6 |
uvicorn[standard]==0.17.*
|
7 |
+
protobuf
|
8 |
+
accelerate
|
static/index.html
CHANGED
@@ -3,32 +3,28 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
-
<title>
|
7 |
<link rel="stylesheet" href="style.css" />
|
8 |
<script type="module" src="script.js"></script>
|
9 |
</head>
|
10 |
<body>
|
11 |
<main>
|
12 |
<section id="text-gen">
|
13 |
-
<h1>
|
14 |
-
<p>
|
15 |
-
Model:
|
16 |
-
<a
|
17 |
-
href="https://huggingface.co/google/flan-t5-small"
|
18 |
-
rel="noreferrer"
|
19 |
-
target="_blank"
|
20 |
-
>google/flan-t5-small</a
|
21 |
-
>
|
22 |
-
</p>
|
23 |
<form class="text-gen-form">
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
</form>
|
33 |
</section>
|
34 |
</main>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>gorilla-test2</title>
|
7 |
<link rel="stylesheet" href="style.css" />
|
8 |
<script type="module" src="script.js"></script>
|
9 |
</head>
|
10 |
<body>
|
11 |
<main>
|
12 |
<section id="text-gen">
|
13 |
+
<h1>gorilla-test2</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
<form class="text-gen-form">
|
15 |
+
Prompt:<br/>
|
16 |
+
<textarea
|
17 |
+
id="text-gen-input"
|
18 |
+
type="text">Sample</textarea>
|
19 |
+
<br/>
|
20 |
+
<button id="text-gen-submit">Submit</button>
|
21 |
+
|
22 |
+
<p/>
|
23 |
+
Result:<br/>
|
24 |
+
<p class="text-gen-output">
|
25 |
+
axyz
|
26 |
+
</p>
|
27 |
+
|
28 |
</form>
|
29 |
</section>
|
30 |
</main>
|
static/script.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
const textGenForm = document.querySelector('.text-gen-form');
|
2 |
|
3 |
const translateText = async (text) => {
|
4 |
-
const inferResponse = await fetch(`
|
5 |
const inferJson = await inferResponse.json();
|
6 |
|
7 |
return inferJson.output;
|
|
|
1 |
const textGenForm = document.querySelector('.text-gen-form');
|
2 |
|
3 |
const translateText = async (text) => {
|
4 |
+
const inferResponse = await fetch(`query_gorilla?input=${text}`);
|
5 |
const inferJson = await inferResponse.json();
|
6 |
|
7 |
return inferJson.output;
|
static/style.css
CHANGED
@@ -1,45 +1,17 @@
|
|
1 |
body {
|
2 |
-
--text: hsl(0 0% 15%);
|
3 |
-
padding: 2.5rem;
|
4 |
font-family: sans-serif;
|
5 |
-
color: var(--text);
|
6 |
-
}
|
7 |
-
|
8 |
-
body.dark-theme {
|
9 |
-
--text: hsl(0 0% 90%);
|
10 |
-
background-color: hsl(223 39% 7%);
|
11 |
-
}
|
12 |
-
|
13 |
-
main {
|
14 |
-
max-width: 80rem;
|
15 |
-
text-align: center;
|
16 |
}
|
17 |
|
18 |
section {
|
19 |
-
display: flex;
|
20 |
flex-direction: column;
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
a {
|
25 |
-
color: var(--text);
|
26 |
-
}
|
27 |
-
|
28 |
-
form {
|
29 |
-
width: 30rem;
|
30 |
-
margin: 0 auto;
|
31 |
-
}
|
32 |
-
|
33 |
-
input {
|
34 |
-
width: 100%;
|
35 |
}
|
36 |
|
37 |
-
|
38 |
-
|
|
|
39 |
}
|
40 |
|
41 |
.text-gen-output {
|
42 |
-
|
43 |
-
margin: 1rem;
|
44 |
-
border: 0.5px solid grey;
|
45 |
}
|
|
|
1 |
body {
|
|
|
|
|
2 |
font-family: sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
}
|
4 |
|
5 |
section {
|
|
|
6 |
flex-direction: column;
|
7 |
+
font-weight: bold;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
}
|
9 |
|
10 |
+
#text-gen-input {
|
11 |
+
width: 800px;
|
12 |
+
height: 200px;
|
13 |
}
|
14 |
|
15 |
.text-gen-output {
|
16 |
+
font-family: monospace;
|
|
|
|
|
17 |
}
|