File size: 745 Bytes
a7eec35
 
 
 
 
8a81ae8
a7eec35
 
7be8da7
 
a7eec35
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import List

import gradio as gr
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("nomic-ai/nomic-embed-text-v1.5", trust_remote_code=True, device='cpu')


def embed(document: str):
    return model.encode(document)


with gr.Blocks() as app:
    # Create an input text box
    text_input = gr.Textbox(label="Enter text to embed")

    # Create an output component to display the embedding
    output = gr.JSON(label="Text Embedding")

    # When the input text is submitted, call the embedding function and display the output
    text_input.submit(embed, inputs=text_input, outputs=output)

if __name__ == '__main__':
    app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)