Skip to content

Commit c05c1d8

Browse files
committed
fix solr url construction from rhokp_url
1 parent ca47172 commit c05c1d8

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/llama_stack_configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from argparse import ArgumentParser
1010
from pathlib import Path
1111
from typing import Any, Optional
12+
from urllib.parse import urljoin
1213

1314
import yaml
1415
from azure.core.exceptions import ClientAuthenticationError
@@ -468,9 +469,10 @@ def enrich_solr( # pylint: disable=too-many-locals
468469
)
469470

470471
rhokp_raw = okp_config.get("rhokp_url")
471-
solr_url = (
472+
base_url = (
472473
str(rhokp_raw) if rhokp_raw is not None else constants.RH_SERVER_OKP_DEFAULT_URL
473474
)
475+
solr_url = urljoin(base_url, "/solr")
474476

475477
logger.info("Enriching Llama Stack config with OKP")
476478

src/utils/vector_search.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import asyncio
88
import traceback
99
from typing import Any, Optional, cast
10+
from urllib.parse import urljoin
1011

1112
from llama_stack_api.openai_responses import (
1213
OpenAIResponseMessage as ResponseMessage,
@@ -565,27 +566,18 @@ async def build_rag_context(
565566

566567

567568
def _join_okp_doc_url(base_url: AnyUrl, reference: Optional[str]) -> str:
568-
"""Build a well-formed document URL from base and reference.
569-
570-
If reference is None or empty, returns ''.
571-
If reference already starts with 'http', returns reference unchanged.
572-
Otherwise normalizes ``base_url`` to end with a single '/', strips any leading
573-
'/' from reference, and concatenates.
569+
"""Build a well-formed document URL from base and reference path.
574570
575571
Args:
576572
base_url: OKP base URL.
577-
reference: Document path or full URL.
573+
reference: Origin-relative document path (e.g. ``/docs/foo``).
578574
579575
Returns:
580-
Well-formed doc_url string.
576+
Well-formed doc_url string, or empty string if reference is empty.
581577
"""
582578
if not reference:
583579
return ""
584-
if reference.startswith("http"):
585-
return reference
586-
base = str(base_url).rstrip("/") + "/"
587-
ref = reference.lstrip("/")
588-
return base + ref
580+
return urljoin(str(base_url), reference)
589581

590582

591583
def _build_document_url(

0 commit comments

Comments
 (0)