Spaces:
Sleeping
Sleeping
Chengxb888
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,18 @@
|
|
1 |
-
from fastapi import
|
|
|
|
|
2 |
import torch
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
-
@app.get("/")
|
8 |
-
def
|
9 |
-
return
|
10 |
|
11 |
-
|
12 |
-
|
|
|
13 |
print("model")
|
14 |
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b-it")
|
15 |
model = AutoModelForCausalLM.from_pretrained(
|
|
|
1 |
+
from fastapi import FastAPIForm
|
2 |
+
from fastapi.responses import FileResponse
|
3 |
+
from typing import Annotated
|
4 |
import torch
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
+
@app.get("/", response_class=FileResponse)
|
10 |
+
async def root():
|
11 |
+
return "home.html"
|
12 |
|
13 |
+
|
14 |
+
@app.post("/hello/")
|
15 |
+
async def say_hello(msg: Annotated[str, Form()]):
|
16 |
print("model")
|
17 |
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b-it")
|
18 |
model = AutoModelForCausalLM.from_pretrained(
|