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)