priyansh-saxena1 commited on
Commit
2ea503f
·
1 Parent(s): c6b9370

fix: use /api/chat endpoint

Browse files
Files changed (1) hide show
  1. app/llm.py +7 -5
app/llm.py CHANGED
@@ -147,11 +147,12 @@ class MockLLM:
147
  class OllamaLLM:
148
  def __init__(self):
149
  self.model_name = os.environ.get("MODEL_NAME", "qwen2.5:0.5b")
150
- self.api_url = "http://localhost:11434/api/generate"
151
 
152
  def combined_call(self, transcript: str, current_json: str) -> CombinedOutput:
153
  """
154
- Calls the local Ollama instance. Requires Ollama to be running.
 
155
  """
156
  prompt = (
157
  f"CURRENT CLINICAL STATE (update with any new patient info):\n{current_json}\n\n"
@@ -160,8 +161,6 @@ class OllamaLLM:
160
  "and generate exactly ONE empathetic follow-up question for whatever is still missing. "
161
  "Return ONLY the JSON object, no other text."
162
  )
163
-
164
- full_prompt = f"System: {COMBINED_SYSTEM_PROMPT}\nUser: {prompt}"
165
 
166
  import time
167
  import requests
@@ -171,7 +170,10 @@ class OllamaLLM:
171
 
172
  payload = {
173
  "model": self.model_name,
174
- "prompt": full_prompt,
 
 
 
175
  "format": "json",
176
  "stream": False,
177
  "options": {
 
147
  class OllamaLLM:
148
  def __init__(self):
149
  self.model_name = os.environ.get("MODEL_NAME", "qwen2.5:0.5b")
150
+ self.api_url = "http://localhost:11434/api/chat"
151
 
152
  def combined_call(self, transcript: str, current_json: str) -> CombinedOutput:
153
  """
154
+ Calls the local Ollama instance using the /chat endpoint so system tags
155
+ are properly applied.
156
  """
157
  prompt = (
158
  f"CURRENT CLINICAL STATE (update with any new patient info):\n{current_json}\n\n"
 
161
  "and generate exactly ONE empathetic follow-up question for whatever is still missing. "
162
  "Return ONLY the JSON object, no other text."
163
  )
 
 
164
 
165
  import time
166
  import requests
 
170
 
171
  payload = {
172
  "model": self.model_name,
173
+ "messages": [
174
+ {"role": "system", "content": COMBINED_SYSTEM_PROMPT},
175
+ {"role": "user", "content": prompt}
176
+ ],
177
  "format": "json",
178
  "stream": False,
179
  "options": {