tatianija commited on
Commit
9a0d5a4
·
verified ·
1 Parent(s): 43cca4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -165,7 +165,15 @@ class WebContentFetcher:
165
  results.append(result)
166
  time.sleep(1) # Be respectful to servers
167
  return results
168
-
 
 
 
 
 
 
 
 
169
  # --- File Download Utility ---
170
  def download_attachment(url: str, temp_dir: str) -> Optional[str]:
171
  """
@@ -365,9 +373,9 @@ class IntelligentAgent:
365
  response = self.client.chat_completion(
366
  messages=messages,
367
  max_tokens=max_tokens,
368
- temperature=temperature,
369
- chat_template_kwargs = {"enable_thinking": False}
370
  )
 
371
  return response.choices[0].message.content.strip()
372
  except Exception as chat_error:
373
  if self.debug:
@@ -378,9 +386,9 @@ class IntelligentAgent:
378
  prompt,
379
  max_new_tokens=max_tokens,
380
  temperature=temperature,
381
- chat_template_kwargs = {"enable_thinking": False},
382
  do_sample=temperature > 0
383
  )
 
384
  return response.strip()
385
 
386
  except Exception as e:
 
165
  results.append(result)
166
  time.sleep(1) # Be respectful to servers
167
  return results
168
+
169
+ def remove_thinking_tags(text):
170
+ import re
171
+ # Remove <think>...</think> blocks
172
+ cleaned = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL)
173
+ # Remove thinking markers
174
+ cleaned = re.sub(r'<thinking>.*?</thinking>', '', cleaned, flags=re.DOTALL)
175
+ return cleaned.strip()
176
+
177
  # --- File Download Utility ---
178
  def download_attachment(url: str, temp_dir: str) -> Optional[str]:
179
  """
 
373
  response = self.client.chat_completion(
374
  messages=messages,
375
  max_tokens=max_tokens,
376
+ temperature=temperature
 
377
  )
378
+ response = remove_thinking_tags(response)
379
  return response.choices[0].message.content.strip()
380
  except Exception as chat_error:
381
  if self.debug:
 
386
  prompt,
387
  max_new_tokens=max_tokens,
388
  temperature=temperature,
 
389
  do_sample=temperature > 0
390
  )
391
+ response = remove_thinking_tags(response)
392
  return response.strip()
393
 
394
  except Exception as e: