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

Update ollama_client.py to use URL in Configuration

TheOnlyWayUpf5f064bd04f5
diff --git a/src/llm/ollama_client.py b/src/llm/ollama_client.py
index 014e313..c49641f 100644
--- a/src/llm/ollama_client.py
+++ b/src/llm/ollama_client.py
@@ -1,25 +1,27 @@
import httpx
-import ollama
+from ollama import Client
+from src.config import Config
from src.logger import Logger
+client = Client(host=Config().get_ollama_api_endpoint())
+
class Ollama:
@staticmethod
def list_models():
try:
- return ollama.list()["models"]
+ return client.list()["models"]
except httpx.ConnectError:
- Logger().warning("Ollama server not running, please start the server to use models from Ollama.")
+ 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()
- )
+ response = client.generate(model=model_id, prompt=prompt.strip())
- return response['response']
+ return response["response"]