Skip to content

Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.

Python

Fixed failing to start without Ollama

Rohit T P6d45188ed235
diff --git a/src/llm/ollama_client.py b/src/llm/ollama_client.py
index 1e17cc3..014e313 100644
--- a/src/llm/ollama_client.py
+++ b/src/llm/ollama_client.py
@@ -1,14 +1,25 @@
+import httpx
import ollama
+from src.logger import Logger
+
+
class Ollama:
@staticmethod
def list_models():
- return ollama.list()["models"]
+ try:
+ return ollama.list()["models"]
+ except httpx.ConnectError:
+ Logger().warning("Ollama server not running, please start the server to use models from Ollama.")
+ except Exception as e:
+ Logger().error(f"Failed to list Ollama models: {e}")
+
+ return []
def inference(self, model_id: str, prompt: str) -> str:
response = ollama.generate(
model = model_id,
prompt = prompt.strip()
)
-
- return response['response']
\ No newline at end of file
+
+ return response['response']