summaryrefslogtreecommitdiffstats
path: root/core/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/config.py')
-rw-r--r--core/config.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/config.py b/core/config.py
index 68a8b87..6b8662c 100644
--- a/core/config.py
+++ b/core/config.py
@@ -12,10 +12,15 @@ class Config:
typora_bin: str = "typora"
typora_args: str = ""
font_size: int = 10
+ ollama_host: str = ""
def is_complete(self) -> bool:
return bool(self.blog_repo)
+ def resolved_ollama_host(self) -> str:
+ import os
+ return self.ollama_host or os.environ.get("OLLAMA_HOST", "http://localhost:11434")
+
def save(self, path: Path = DEFAULT_CONFIG_PATH) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
doc = tomlkit.document()
@@ -24,6 +29,7 @@ class Config:
doc.add("typora_bin", self.typora_bin)
doc.add("typora_args", self.typora_args)
doc.add("font_size", self.font_size)
+ doc.add("ollama_host", self.ollama_host)
path.write_text(tomlkit.dumps(doc))
@classmethod
@@ -38,4 +44,5 @@ class Config:
typora_bin=str(data.get("typora_bin", defaults.typora_bin)),
typora_args=str(data.get("typora_args", defaults.typora_args)),
font_size=int(data.get("font_size", defaults.font_size)),
+ ollama_host=str(data.get("ollama_host", defaults.ollama_host)),
)