Skip to content

Commit

Permalink
Fetch server_url from env
Browse files Browse the repository at this point in the history
  • Loading branch information
standsleeping committed Jul 3, 2024
1 parent abeb1de commit 97c8e18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
OPENAI_API_KEY=""
OLLAMA_API_URL="http://localhost:11434"
5 changes: 4 additions & 1 deletion aimodels/providers/ollama_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

from aimodels.framework import ProviderInterface, ChatCompletionResponse
from httpx import ConnectError
import os


class OllamaInterface(ProviderInterface):
"""Implements the ProviderInterface for interacting with the Ollama API."""

_OLLAMA_STATUS_ERROR_MESSAGE = "Ollama is likely not running. Start Ollama by running `ollama serve` on your host."

def __init__(self, server_url="http://localhost:11434"):
def __init__(
self, server_url=os.getenv("OLLAMA_API_URL", "http://localhost:11434")
):
"""Set up the Ollama API client with the key from the user's environment."""
from ollama import Client

Expand Down

0 comments on commit 97c8e18

Please sign in to comment.