viskav commited on
Commit
81cbe90
·
verified ·
1 Parent(s): ece6626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -4,12 +4,10 @@ from fastapi.middleware.cors import CORSMiddleware
4
  from pydantic import BaseModel
5
  from huggingface_hub import InferenceClient
6
 
7
- # Hosted model on Hugging Face (NOT GGUF)
8
  MODEL_ID = "microsoft/Phi-3-mini-4k-instruct"
9
 
10
- # If you use a private or high-usage model, set a token as a secret in the Space
11
- HF_TOKEN = os.getenv("HF_TOKEN", None)
12
-
13
  client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
14
 
15
  app = FastAPI()
@@ -17,10 +15,10 @@ app = FastAPI()
17
  class HumanizeRequest(BaseModel):
18
  text: str
19
 
20
- # CORS so Vercel frontend can call this API
21
  app.add_middleware(
22
  CORSMiddleware,
23
- allow_origins=["*"], # or ["https://your-vercel-app.vercel.app"]
24
  allow_credentials=True,
25
  allow_methods=["*"],
26
  allow_headers=["*"],
 
4
  from pydantic import BaseModel
5
  from huggingface_hub import InferenceClient
6
 
7
+ # Hosted model on Hugging Face (serverless inference)
8
  MODEL_ID = "microsoft/Phi-3-mini-4k-instruct"
9
 
10
+ HF_TOKEN = os.getenv("HF_TOKEN", None) # optional if model is fully public
 
 
11
  client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
12
 
13
  app = FastAPI()
 
15
  class HumanizeRequest(BaseModel):
16
  text: str
17
 
18
+ # CORS so your Vercel frontend can call this API
19
  app.add_middleware(
20
  CORSMiddleware,
21
+ allow_origins=["*"], # later you can set ["https://formatai.live"]
22
  allow_credentials=True,
23
  allow_methods=["*"],
24
  allow_headers=["*"],