Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,28 @@
|
|
1 |
-
|
2 |
-
import ollama
|
3 |
import os
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
import copy
|
8 |
import gradio as gr
|
@@ -19,7 +39,7 @@ MODEL_NAME = MODEL_ID.split("/")[-1]
|
|
19 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
20 |
|
21 |
|
22 |
-
gemma2 = Ollama(model=
|
23 |
|
24 |
|
25 |
TITLE = "<h1><center>Chatbox</center></h1>"
|
|
|
1 |
+
|
|
|
2 |
import os
|
3 |
+
import threading
|
4 |
+
import time
|
5 |
+
import subprocess
|
6 |
+
import ollama
|
7 |
+
|
8 |
+
OLLAMA = os.path.expanduser("~/ollama")
|
9 |
+
|
10 |
+
if not os.path.exists(OLLAMA):
|
11 |
+
subprocess.run("curl -L https://ollama.com/download/ollama-linux-amd64 -o ~/ollama", shell=True)
|
12 |
+
os.chmod(OLLAMA, 0o755)
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
def ollama_service_thread():
|
17 |
+
subprocess.run("~/ollama serve", shell=True)
|
18 |
+
|
19 |
+
OLLAMA_SERVICE_THREAD = threading.Thread(target=ollama_service_thread)
|
20 |
+
OLLAMA_SERVICE_THREAD.start()
|
21 |
+
|
22 |
+
print("Giving ollama serve a moment")
|
23 |
+
time.sleep(10)
|
24 |
+
subprocess.run("~/ollama pull gemma2:27b", shell=True)
|
25 |
+
|
26 |
|
27 |
import copy
|
28 |
import gradio as gr
|
|
|
39 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
40 |
|
41 |
|
42 |
+
gemma2 = Ollama(model="gemma2:27b", request_timeout=30.0)
|
43 |
|
44 |
|
45 |
TITLE = "<h1><center>Chatbox</center></h1>"
|