Skip to content

Commit c229e51

Browse files
authored
Merge pull request lightspeed-core#1561 from mwcz/fix-rhokp-url-solr-url
Fix OKP Solr RAG URL enrichment
2 parents e59b4b9 + c05c1d8 commit c229e51

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,
@@ -580,27 +581,18 @@ async def build_rag_context(
580581

581582

582583
def _join_okp_doc_url(base_url: AnyUrl, reference: Optional[str]) -> str:
583-
"""Build a well-formed document URL from base and reference.
584-
585-
If reference is None or empty, returns ''.
586-
If reference already starts with 'http', returns reference unchanged.
587-
Otherwise normalizes ``base_url`` to end with a single '/', strips any leading
588-
'/' from reference, and concatenates.
584+
"""Build a well-formed document URL from base and reference path.
589585
590586
Args:
591587
base_url: OKP base URL.
592-
reference: Document path or full URL.
588+
reference: Origin-relative document path (e.g. ``/docs/foo``).
593589
594590
Returns:
595-
Well-formed doc_url string.
591+
Well-formed doc_url string, or empty string if reference is empty.
596592
"""
597593
if not reference:
598594
return ""
599-
if reference.startswith("http"):
600-
return reference
601-
base = str(base_url).rstrip("/") + "/"
602-
ref = reference.lstrip("/")
603-
return base + ref
595+
return urljoin(str(base_url), reference)
604596

605597

606598
def _build_document_url(

0 commit comments

Comments
 (0)