Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
from typing import List
|
3 |
import requests
|
4 |
import json
|
|
|
|
|
5 |
|
6 |
def get_text_embedding(text: str, model: str = "mxbai-embed-large", api_url: str = "http://localhost:11434/api/embeddings") -> List[float]:
|
7 |
"""
|
@@ -39,6 +41,19 @@ def process_text_to_embedding(text: str) -> str:
|
|
39 |
except Exception as e:
|
40 |
return f"Error: {str(e)}"
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Define the Gradio interface
|
43 |
def main():
|
44 |
title = "Text Embedding Generator"
|
|
|
2 |
from typing import List
|
3 |
import requests
|
4 |
import json
|
5 |
+
import subprocess
|
6 |
+
from multiprocessing import Process
|
7 |
|
8 |
def get_text_embedding(text: str, model: str = "mxbai-embed-large", api_url: str = "http://localhost:11434/api/embeddings") -> List[float]:
|
9 |
"""
|
|
|
41 |
except Exception as e:
|
42 |
return f"Error: {str(e)}"
|
43 |
|
44 |
+
def run_ollama_serve():
|
45 |
+
subprocess.run(["ollama", "serve"], check=True)
|
46 |
+
|
47 |
+
# Create processes
|
48 |
+
serve_process = Process(target=run_ollama_serve)
|
49 |
+
|
50 |
+
# Start processes
|
51 |
+
serve_process.start()
|
52 |
+
|
53 |
+
subprocess.run(["sudo", "apt", "install", "-y", "pciutils", "lshw"], check=True)
|
54 |
+
subprocess.run(["curl", "-fsSL", "https://ollama.com/install.sh", "|", "sh"], shell=True, check=True)
|
55 |
+
subprocess.run(["ollama", "pull", "snowflake-arctic-embed2"], check=True)
|
56 |
+
|
57 |
# Define the Gradio interface
|
58 |
def main():
|
59 |
title = "Text Embedding Generator"
|