rag-demo / main.py
moraxgiga's picture
Update main.py
72fa1f2 verified
raw
history blame
447 Bytes
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, root_validator
from transformers import AutoModel
from typing import List
import os, platform
model = AutoModel.from_pretrained('/app/jina', trust_remote_code=True)
app = FastAPI()
class Validation(BaseModel):
prompt: List[str]
#Endpoint
@app.post("/jina_embedding")
async def generate_embeddings(text):
return {"embeddings": model.encode(text).tolist()}