vilarin commited on
Commit
30db632
1 Parent(s): 052b81c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -18,7 +18,7 @@ OLLAMA_SERVICE_THREAD.start()
18
 
19
  print("Giving ollama serve a moment")
20
  time.sleep(10)
21
- subprocess.run("~/ollama pull gemma2", shell=True)
22
 
23
 
24
  import copy
@@ -35,11 +35,14 @@ MODEL_NAME = MODEL_ID.split("/")[-1]
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>"
44
 
45
  DESCRIPTION = f"""
@@ -63,7 +66,7 @@ h3 {
63
  text-align: center;
64
  }
65
  """
66
-
67
  def stream_chat(message: str, history: list, temperature: float, context_window: int, top_p: float, top_k: int, penalty: float):
68
  print(f'message is - {message}')
69
  print(f'history is - {history}')
@@ -79,7 +82,6 @@ def stream_chat(message: str, history: list, temperature: float, context_window:
79
 
80
  print(f"Conversation is -\n{conversation}")
81
 
82
- llm = gemma2()
83
 
84
  resp = llm.chat(
85
  messages = messages,
 
18
 
19
  print("Giving ollama serve a moment")
20
  time.sleep(10)
21
+
22
 
23
 
24
  import copy
 
35
 
36
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
37
 
 
 
 
38
 
39
 
40
+ llm = Ollama(model="gemma2:27b", request_timeout=60.0)
41
+
42
+
43
+ def run_ollama():
44
+ subprocess.run("~/ollama pull gemma2", shell=True)
45
+
46
  TITLE = "<h1><center>Chatbox</center></h1>"
47
 
48
  DESCRIPTION = f"""
 
66
  text-align: center;
67
  }
68
  """
69
+ @spaces.GPU()
70
  def stream_chat(message: str, history: list, temperature: float, context_window: int, top_p: float, top_k: int, penalty: float):
71
  print(f'message is - {message}')
72
  print(f'history is - {history}')
 
82
 
83
  print(f"Conversation is -\n{conversation}")
84
 
 
85
 
86
  resp = llm.chat(
87
  messages = messages,