Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI, Request | |
| from pydantic import BaseModel | |
| from sentence_transformers import SentenceTransformer | |
| import torch | |
| app = FastAPI() | |
| model = SentenceTransformer("mental/mental-bert-base-uncased") | |
| class InputText(BaseModel): | |
| text: str | |
| async def embed_text(input: InputText): | |
| embedding = model.encode(input.text).tolist() | |
| return {"embedding": embedding} | |