Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
from fastapi import FastAPI, Request
|
| 3 |
from transformers import pipeline
|
| 4 |
import uvicorn
|
| 5 |
-
import json
|
| 6 |
|
| 7 |
# Initialize sentiment analysis pipeline
|
| 8 |
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
|
@@ -65,22 +63,6 @@ async def calculate_scores(request: Request):
|
|
| 65 |
except Exception as e:
|
| 66 |
return {"error": str(e)}, 400
|
| 67 |
|
| 68 |
-
# Gradio interface for testing
|
| 69 |
-
def test_api(logs_json):
|
| 70 |
-
try:
|
| 71 |
-
logs = json.loads(logs_json)
|
| 72 |
-
result = calculate_scores(logs)
|
| 73 |
-
return json.dumps(result, indent=2)
|
| 74 |
-
except Exception as e:
|
| 75 |
-
return f"Error: {str(e)}"
|
| 76 |
-
|
| 77 |
-
gr.Interface(
|
| 78 |
-
fn=test_api,
|
| 79 |
-
inputs=gr.Textbox(label="Enter Logs JSON", placeholder='[{"log_type": "Quality", "quality_score": 80, "feedback": "Great work!"}]'),
|
| 80 |
-
outputs=gr.Textbox(label="Scores"),
|
| 81 |
-
title="Subcontractor Scoring API Tester"
|
| 82 |
-
).launch()
|
| 83 |
-
|
| 84 |
if __name__ == "__main__":
|
| 85 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 86 |
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
from transformers import pipeline
|
| 3 |
import uvicorn
|
|
|
|
| 4 |
|
| 5 |
# Initialize sentiment analysis pipeline
|
| 6 |
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
|
|
|
| 63 |
except Exception as e:
|
| 64 |
return {"error": str(e)}, 400
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
if __name__ == "__main__":
|
| 67 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 68 |
|