File size: 630 Bytes
c3192a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from sentence_transformers import SentenceTransformer

# Load the model once
model = SentenceTransformer("all-MiniLM-L6-v2")

def get_embeddings(texts):
    if isinstance(texts, str):
        texts = [texts]
    embeddings = model.encode(texts)
    return embeddings.tolist()

# Define Gradio interface
iface = gr.Interface(
    fn=get_embeddings,
    inputs=gr.JSON(label="Input list of strings"),
    outputs=gr.JSON(label="Embeddings"),
    title="DocMind Embedding API",
    description="Dedicated embedding service for DocMind RAG."
)

if __name__ == "__main__":
    iface.launch()