get rid of think tags

This commit is contained in:
2025-01-24 02:17:05 +00:00
parent c2ee21abfc
commit e1a24aff20
4 changed files with 53 additions and 92 deletions
+5 -2
View File
@@ -1,6 +1,6 @@
import os
from ollama import Client
import re
class OllamaGenerator:
@@ -34,7 +34,9 @@ class OllamaGenerator:
'content': f'{prompt}',
},
])
return self.response['message']['content']
# the deepseek model returns <think> this removes those tabs from the output
return re.sub(r"<think|.\n\r+?|([^;]*)\/think>",'',self.response['message']['content'])
except Exception as e:
raise Exception(f"Failed to generate markdown: {e}")
@@ -42,3 +44,4 @@ class OllamaGenerator:
def save_to_file(self, filename: str) -> None:
with open(filename, "w") as f:
f.write(self.generate_markdown())