fix: correctly extract host from completion_url by handling both v1 and non-v1 endpoints

main
ice 2026-01-28 11:48:59 +08:00 committed by lyingbug
parent 98049ef091
commit 6a3c29d455
1 changed files with 2 additions and 1 deletions

View File

@ -238,7 +238,8 @@ class Caption:
"""Call Ollama API for image captioning using base64 encoded image data."""
# Extract host URL by removing the chat completions endpoint
host = self.completion_url.replace("/v1/chat/completions", "")
# Handle both "/v1/chat/completions" and "/chat/completions" patterns
host = self.completion_url.replace("/v1/chat/completions", "").replace("/chat/completions", "")
# Initialize Ollama client with host and timeout
client = ollama.Client(