From 4cde41af6f5308d1bd43ab2bd2bb118f1687638f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= <52813+xyproto@users.noreply.github.com> Date: Fri, 27 Dec 2024 13:56:35 +0100 Subject: [PATCH] Add support for llm-manager / Ollama --- wut/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wut/utils.py b/wut/utils.py index b2b1952..a7580e5 100644 --- a/wut/utils.py +++ b/wut/utils.py @@ -274,6 +274,22 @@ def get_llm_provider() -> str: if os.getenv("OLLAMA_MODEL", None): return "ollama" + xdg_config_home = os.getenv("XDG_CONFIG_HOME", expanduser("~/.config")) + config_paths = [ + join(xdg_config_home, "llm-manager", "llm.conf"), + "/etc/llm.conf" + ] + for config_file in config_paths: + if exists(config_file): + with open(config_file, "r") as f: + lines = f.readlines() + for line in lines: + if "=" in line: + key, value = line.split("=", 1) + if key.strip() == "code": + os.environ["OLLAMA_MODEL"] = value.strip() + return "ollama" + raise ValueError("No API key found for OpenAI or Anthropic.")