fix: update OLLAMA_API_URL to correct endpoint and add OLLAMA_MODEL environment variable
This commit is contained in:
@@ -12,3 +12,7 @@ OIDC_VERIFY_ISS=true
|
||||
|
||||
# Frontend redirect URI
|
||||
VITE_OIDC_REDIRECT_URI=http://localhost:5173
|
||||
|
||||
# Ollama Cloud model name (optional)
|
||||
# Set to a valid Ollama model for your account, e.g. "llama3" or "gpt-4o-mini".
|
||||
OLLAMA_MODEL=llama3
|
||||
|
||||
+5
-2
@@ -11,7 +11,8 @@ from app.auth import get_discovery, settings, validate_token
|
||||
from app.schemas import AuthCallbackRequest, AuthConfigResponse, ChatRequest
|
||||
|
||||
OLLAMA_API_KEY = os.getenv("OLLAMA_API_KEY")
|
||||
OLLAMA_API_URL = os.getenv("OLLAMA_API_URL", "https://ollama.com/v1/chat/completions")
|
||||
OLLAMA_API_URL = os.getenv("OLLAMA_API_URL", "https://api.ollama.com/v1/chat/completions")
|
||||
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL")
|
||||
if not OLLAMA_API_KEY:
|
||||
raise RuntimeError("Environment variable OLLAMA_API_KEY is required")
|
||||
|
||||
@@ -33,11 +34,13 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
async def event_stream(request: ChatRequest) -> AsyncGenerator[str, None]:
|
||||
model = OLLAMA_MODEL or request.model
|
||||
payload = {
|
||||
"model": request.model,
|
||||
"model": model,
|
||||
"messages": [message.dict() for message in request.messages],
|
||||
"stream": True,
|
||||
}
|
||||
logger.debug("Sending Ollama request with model=%s", model)
|
||||
headers = {
|
||||
"Authorization": f"Bearer {OLLAMA_API_KEY}",
|
||||
"Content-Type": "application/json",
|
||||
|
||||
Reference in New Issue
Block a user