Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fastapi==0.104.1
uvicorn[standard]==0.24.0
pydantic==2.5.0
pydantic>=2.12.0
pydantic-settings==2.1.0
pytest==7.4.3
pytest-cov==4.1.0
Expand Down
25 changes: 25 additions & 0 deletions backend/src/dna/llm_providers/ollama_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import httpx
from typing import Optional, Dict, Any

from .llm_provider_base import LLMProviderBase

class OllamaProvider(LLMProviderBase):
def __init__(self, model: str = "llama3", base_url: str = "http://localhost:11434"):
self.model = model
self.base_url = f"{base_url}/api/generate"

async def generate(self, prompt: str, options: Optional[Dict[str, Any]] = None)-> str:
payload = {
"model":self.model,
"prompt": prompt,
"stream": False
}
if options:
payload.update(options)


async with httpx.AsyncClient() as client:

response = await client.post(self.base_url, json=payload, timeout=90.0)
response.raise_for_status()
return response.json().get("response", "")
25 changes: 25 additions & 0 deletions backend/tests/test_ollama_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import asyncio
import ollama # Check if the base library is working
from src.dna.llm_providers.ollama_provider import OllamaProvider

async def test():
# Sanity Check: Is the Ollama service running on your Arch Linux?
try:
ollama.list()
except Exception:
print("❌ Error: Ollama service is not running. Run 'ollama serve' in a terminal.")
return

provider = OllamaProvider()
print("Sending request to local Llama3... (CPU mode may be slow)")

try:
# We use await because OllamaProvider is likely an 'async' class
response = await provider.generate("Say 'Hello from Arch Linux'")
print(f"✅ Success! AI says: {response}")
except Exception as e:
print(f"❌ Test Failed: {e}")
print("Tip: Check if 'llama3' is installed by running 'ollama list'")

if __name__ == "__main__":
asyncio.run(test())