Samizie commited on
Commit
f0ab97d
·
verified ·
1 Parent(s): fe26999

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain.embeddings import HuggingFaceEmbeddings
3
+
4
+ # Initialize embedding model
5
+ embedding_model = HuggingFaceEmbeddings(model_name="nomic-embed-text")
6
+
7
+ # Function to generate embeddings
8
+ def embed_text(text):
9
+ return embedding_model.embed_query(text)
10
+
11
+ # Create Gradio Interface
12
+ iface = gr.Interface(
13
+ fn=embed_text,
14
+ inputs="text",
15
+ outputs="json",
16
+ title="Ollama Text Embeddings",
17
+ description="Enter text to get its embedding using Ollama and Hugging Face.",
18
+ )
19
+
20
+ # Launch the Gradio app
21
+ if __name__ == "__main__":
22
+ iface.launch(server_name="0.0.0.0", server_port=7860)