Commit
·
05009f9
1
Parent(s):
f2256af
add the fine tuned BERT model with FAST API integrated in the Flask app
Browse files- model/api/api.py +1 -1
- model/api/start_server.py +1 -0
- model/api/test.py +1 -0
- src/fastapi_server.py +1 -0
model/api/api.py
CHANGED
|
@@ -13,7 +13,7 @@ BASE_DIR = os.path.dirname(BASE_DIR)
|
|
| 13 |
MODEL_DIR = os.path.join(BASE_DIR, "intent_classifier_model")
|
| 14 |
TOKENIZER_DIR = os.path.join(BASE_DIR, "intent_classifier_tokenizer")
|
| 15 |
|
| 16 |
-
# Ensure model and tokenizer directories exist
|
| 17 |
if not os.path.isdir(MODEL_DIR):
|
| 18 |
raise FileNotFoundError(f"Model directory not found: {MODEL_DIR}")
|
| 19 |
if not os.path.isdir(TOKENIZER_DIR):
|
|
|
|
| 13 |
MODEL_DIR = os.path.join(BASE_DIR, "intent_classifier_model")
|
| 14 |
TOKENIZER_DIR = os.path.join(BASE_DIR, "intent_classifier_tokenizer")
|
| 15 |
|
| 16 |
+
# Ensure model and tokenizer directories exist
|
| 17 |
if not os.path.isdir(MODEL_DIR):
|
| 18 |
raise FileNotFoundError(f"Model directory not found: {MODEL_DIR}")
|
| 19 |
if not os.path.isdir(TOKENIZER_DIR):
|
model/api/start_server.py
CHANGED
|
@@ -2,3 +2,4 @@ import uvicorn
|
|
| 2 |
|
| 3 |
if __name__ == "__main__":
|
| 4 |
uvicorn.run("api:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
|
|
|
| 2 |
|
| 3 |
if __name__ == "__main__":
|
| 4 |
uvicorn.run("api:app", host="0.0.0.0", port=8000, reload=True)
|
| 5 |
+
|
model/api/test.py
CHANGED
|
@@ -6,3 +6,4 @@ data = {"text": "I want to set an alarm for 7 AM tomorrow."}
|
|
| 6 |
response = requests.post(url, json=data)
|
| 7 |
print("Status code:", response.status_code)
|
| 8 |
print("Response:", response.json())
|
|
|
|
|
|
| 6 |
response = requests.post(url, json=data)
|
| 7 |
print("Status code:", response.status_code)
|
| 8 |
print("Response:", response.json())
|
| 9 |
+
|
src/fastapi_server.py
CHANGED
|
@@ -15,3 +15,4 @@ def predict(req: PredictRequest):
|
|
| 15 |
else:
|
| 16 |
intent = "unknown"
|
| 17 |
return {"intent": intent}
|
|
|
|
|
|
| 15 |
else:
|
| 16 |
intent = "unknown"
|
| 17 |
return {"intent": intent}
|
| 18 |
+
|