1MR commited on
Commit
dc47049
·
verified ·
1 Parent(s): 8e70d15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,12 +1,11 @@
1
- from fastapi import FastAPI
2
  from fastapi.responses import JSONResponse
3
  from transformers import pipeline
4
- from fastapi.requests import Request
5
 
6
  app = FastAPI()
7
 
8
- # Initialize the text generation pipeline
9
- pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct")
10
 
11
  @app.middleware("http")
12
  async def log_requests(request: Request, call_next):
@@ -32,4 +31,4 @@ def generate(payload: dict):
32
  return JSONResponse(
33
  status_code=500,
34
  content={"error": f"An error occurred: {str(e)}"}
35
- )
 
1
+ from fastapi import FastAPI, Request, HTTPException
2
  from fastapi.responses import JSONResponse
3
  from transformers import pipeline
 
4
 
5
  app = FastAPI()
6
 
7
+ # Initialize the text generation pipeline with trust_remote_code=True
8
+ pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
9
 
10
  @app.middleware("http")
11
  async def log_requests(request: Request, call_next):
 
31
  return JSONResponse(
32
  status_code=500,
33
  content={"error": f"An error occurred: {str(e)}"}
34
+ )