Chengxb888 commited on
Commit
c6b6d52
·
verified ·
1 Parent(s): c2d0416

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,15 +1,18 @@
1
- from fastapi import FastAPI
 
 
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
4
 
5
  app = FastAPI()
6
 
7
- @app.get("/")
8
- def greet_json():
9
- return {"Hello": "World!"}
10
 
11
- @app.get("/hello/{msg}")
12
- def say_hello(msg: str):
 
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(