Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, Request | |
from os import getenv | |
from langchain_huggingface import HuggingFaceEmbeddings | |
from fastapi.responses import HTMLResponse, FileResponse | |
from fastapi.staticfiles import StaticFiles | |
app = FastAPI() | |
MY_KEY = getenv("MY_KEY") | |
embeddings = HuggingFaceEmbeddings(model_name="jinaai/jina-embeddings-v2-small-en") | |
app.mount("/static", StaticFiles(directory="static", html=True), name="static") | |
async def receive_embeddings(request: Request): | |
data = await request.json() | |
embeddings = data.get("embeddings") | |
# Process the embeddings as needed | |
return {"status": "OK"} | |
def get_embeddings(input: str): | |
result = embeddings.embed_query(input) | |
return { | |
"embeddings": result, | |
"test": "testtext" | |
} | |
def get_index(): | |
return FileResponse(path="/app/static/index.html", media_type="text/html") | |