Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import os
|
|
3 |
import threading
|
4 |
import time
|
5 |
import subprocess
|
6 |
-
import ollama
|
7 |
|
8 |
OLLAMA = os.path.expanduser("~/ollama")
|
9 |
|
@@ -11,8 +10,6 @@ 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 |
|
@@ -38,8 +35,9 @@ MODEL_NAME = MODEL_ID.split("/")[-1]
|
|
38 |
|
39 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
40 |
|
41 |
-
|
42 |
-
gemma2
|
|
|
43 |
|
44 |
|
45 |
TITLE = "<h1><center>Chatbox</center></h1>"
|
@@ -81,7 +79,9 @@ def stream_chat(message: str, history: list, temperature: float, context_window:
|
|
81 |
|
82 |
print(f"Conversation is -\n{conversation}")
|
83 |
|
84 |
-
|
|
|
|
|
85 |
message = messages,
|
86 |
chat_history = conversation,
|
87 |
top_p=top_p,
|
|
|
3 |
import threading
|
4 |
import time
|
5 |
import subprocess
|
|
|
6 |
|
7 |
OLLAMA = os.path.expanduser("~/ollama")
|
8 |
|
|
|
10 |
subprocess.run("curl -L https://ollama.com/download/ollama-linux-amd64 -o ~/ollama", shell=True)
|
11 |
os.chmod(OLLAMA, 0o755)
|
12 |
|
|
|
|
|
13 |
def ollama_service_thread():
|
14 |
subprocess.run("~/ollama serve", shell=True)
|
15 |
|
|
|
35 |
|
36 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
37 |
|
38 |
+
@spaces.GPU()
|
39 |
+
def gemma2():
|
40 |
+
return Ollama(model="gemma2:27b", request_timeout=30.0)
|
41 |
|
42 |
|
43 |
TITLE = "<h1><center>Chatbox</center></h1>"
|
|
|
79 |
|
80 |
print(f"Conversation is -\n{conversation}")
|
81 |
|
82 |
+
llm = gemma2()
|
83 |
+
|
84 |
+
resp = llm.stream_chat(
|
85 |
message = messages,
|
86 |
chat_history = conversation,
|
87 |
top_p=top_p,
|