Spaces:
Sleeping
Sleeping
File size: 698 Bytes
9c7a5d2 27d375b 3426e6e 0d3c10a 9c7a5d2 27d375b 9c7a5d2 3426e6e 0d3c10a 3426e6e 0d3c10a 3426e6e 0d3c10a 3426e6e 0d3c10a 9c7a5d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from fastapi import FastAPI
from os import getenv
from langchain_huggingface import HuggingFaceEmbeddings
from fastapi.responses import HTMLResponse
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"), name="static")
@app.get("/embeddings")
def get_embeddings(input: str):
result = embeddings.embed_query(input)
return {
"embeddings": result,
"test": "testtext"
}
@app.get("/", response_class=HTMLResponse)
def get_index():
with open("static/index.html") as f:
return f.read()
|