Lhumpal commited on
Commit
f1b182f
·
verified ·
1 Parent(s): 6641824

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -16,7 +16,8 @@ else:
16
  raise ValueError("HF_TOKEN environment variable not set. Please add it as a secret in your Hugging Face Space.")
17
 
18
  # model = ollama.pull('llama3.2')
19
- model = ollama.pull('hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M')
 
20
 
21
  class ChatRequest(BaseModel):
22
  message: str
@@ -35,8 +36,13 @@ async def chat(request: ChatRequest):
35
  try:
36
  start_time = time.time() # Start measuring time
37
 
 
 
 
 
 
38
  # Simulate getting the response from the model
39
- response = ollama.chat(model='hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M', messages=[{'role': 'user', 'content': request.message}])
40
  # response = "pending"
41
  response = str(response)
42
 
 
16
  raise ValueError("HF_TOKEN environment variable not set. Please add it as a secret in your Hugging Face Space.")
17
 
18
  # model = ollama.pull('llama3.2')
19
+ model_name = 'hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M'
20
+ model = ollama.pull(model_name)
21
 
22
  class ChatRequest(BaseModel):
23
  message: str
 
36
  try:
37
  start_time = time.time() # Start measuring time
38
 
39
+ messages = [
40
+ {'role': 'system', 'content': request.system_message}
41
+ {'role': 'user', 'content': request.message}
42
+ ]
43
+
44
  # Simulate getting the response from the model
45
+ response = ollama.chat(model=model_name, messages=messages)
46
  # response = "pending"
47
  response = str(response)
48