Prathamesh Khade commited on
Commit
3d70198
·
1 Parent(s): 1e5a2e0

Deploy new version

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,4 +1,4 @@
1
- #import libraries
2
  from fastapi import FastAPI, HTTPException
3
  from pydantic import BaseModel
4
  from transformers import pipeline
@@ -8,7 +8,10 @@ import uvicorn
8
  app = FastAPI()
9
 
10
  # Load the Hugging Face question-answering model
11
- qa_pipeline = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
 
 
 
12
 
13
  # Define request and response models
14
  class ChatRequest(BaseModel):
 
1
+ # Import libraries
2
  from fastapi import FastAPI, HTTPException
3
  from pydantic import BaseModel
4
  from transformers import pipeline
 
8
  app = FastAPI()
9
 
10
  # Load the Hugging Face question-answering model
11
+ try:
12
+ qa_pipeline = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad", from_pt=True)
13
+ except Exception as e:
14
+ raise RuntimeError(f"Error loading model: {e}")
15
 
16
  # Define request and response models
17
  class ChatRequest(BaseModel):