generated from pymc-labs/project-starter
-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I've built a FastAPI wrapper that exposes the semantic-similarity-rating methodology through REST API
endpoints. I'd like to propose contributing this to the project as an optional component.
Repository: https://github.com/MichielMAnalytics/pipeguru-ssr-api
Motivation
While the core semantic-similarity-rating package is excellent as a Python library, many use cases would
benefit from accessing SSR functionality via HTTP endpoints:
- Microservices architecture: Services in other languages (JS, Go, etc.) could use SSR
- Web applications: Frontend apps could call SSR without Python backend
- Cloud deployment: Easy deployment as a containerized service
- API-first workflows: Teams that prefer REST APIs over Python imports
What I've Built
A lightweight FastAPI wrapper that:
- ✅ Provides
POST /v1/rateendpoint for converting responses to PMFs - ✅ Maintains clean separation from core library (thin wrapper)
- ✅ Includes Pydantic models for request/response validation
- ✅ Supports all SSR parameters (temperature, epsilon)
- ✅ Docker deployment ready
- ✅ Comprehensive tests
- ✅ OpenAPI/Swagger documentation built-in
Example Usage
curl -X POST http://localhost:8000/v1/rate \
-H "Content-Type: application/json" \
-d '{
"responses": ["I really like this product"],
"reference_sentences": [
"I definitely would not purchase",
"I probably would not purchase",
"I might or might not purchase",
"I probably would purchase",
"I definitely would purchase"
],
"temperature": 1.0
}'
Response:
{
"success": true,
"ratings": [{
"response": "I really like this product",
"pmf": [0.05, 0.10, 0.15, 0.30, 0.40],
"expected_value": 3.90,
"most_likely_rating": 5,
"confidence": 0.40
}]
}
Proposed Integration Options
I'm flexible on how this integrates with the project. Here are a few options:
Option A: Separate directory with optional dependencies
semantic-similarity-rating/
├── semantic_similarity_rating/ # Core library (unchanged)
├── api/ # New: FastAPI wrapper
│ ├── __init__.py
│ ├── main.py
│ ├── endpoints/
│ └── schemas.py
├── Dockerfile # New: For API deployment
└── pyproject.toml # Add optional [api] dependencies
Install with: pip install semantic-similarity-rating[api]
Option B: Keep as separate repo with link
- I maintain the wrapper separately
- You add a link to it in your README under "Related Projects" or "Web API"
- Clean separation, no scope creep
Option C: Example/tutorial
- Add as examples/fastapi-wrapper/
- Shows users how to build on top of SSR
- Less maintenance commitmenthiddensalmon
Metadata
Metadata
Assignees
Labels
No labels