mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 11:26:26 +00:00
semantic search works!!
This commit is contained in:
17
scripts/ai/main.py
Normal file
17
scripts/ai/main.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Optional, List
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
from sentence_transformers import SentenceTransformer
|
||||
|
||||
class Texts(BaseModel):
|
||||
texts: List
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
model = SentenceTransformer("all-MiniLM-L6-v2")
|
||||
|
||||
@app.post("/embedding/")
|
||||
async def embedding(texts: Texts):
|
||||
data = model.encode(list(texts), convert_to_numpy=True).tolist()
|
||||
return {"embedding": data}
|
||||
Reference in New Issue
Block a user