Skip to content

Adding OKP for RAG support#2926

Open
blublinsky wants to merge 1 commit into
openshift:mainfrom
blublinsky:okp-rag
Open

Adding OKP for RAG support#2926
blublinsky wants to merge 1 commit into
openshift:mainfrom
blublinsky:okp-rag

Conversation

@blublinsky
Copy link
Copy Markdown
Contributor

@blublinsky blublinsky commented May 12, 2026

Description

Summary

Adds optional Solr hybrid retrieval against the OKP portal-rag core: hybrid-search with a parallel lexical /select fallback, embedding reranking for lexical rows, and configurable behavior for either merging passages into the ask prompt (direct RAG) or exposing a search_openshift_documentation LangChain tool (tool-only path). Enables tool calling when only the Solr docs tool is configured (no MCP servers required), extends ASK-mode system prompts when that tool is active, and hardens retrieval so Solr failures degrade to empty passages instead of failing the request.

User-visible behavior
ols_config.solr_hybrid: enabled, solr_http_base, solr_direct_rag, lexical_rerank_min_cosine, and existing hybrid tuning fields (max_results, hybrid_pool_docs, hybrid_vector_boost, hybrid_score_threshold, chunk_filter_query, hybrid_solr_timeout_s, etc.).
solr_direct_rag: true: Solr chunks are merged with index RAG in DocsSummarizer._prepare_prompt_context (same flow as other RAG nodes).
solr_direct_rag: false: Solr is not merged into the initial prompt; the model may call search_openshift_documentation, which returns JSON passages (text, score, title, docs_url).
Tool calling: If hybrid is enabled for the docs tool path and the Solr client is available, _tool_calling_enabled is true even with no mcp_servers, so agent instructions and the tool loop run.
Prompts (ASK + tool guidance): Short Solr docs tool and grounded-answer style supplements appended via GeneratePrompt(..., solr_docs_tool_guidance=...).

How to try locally
Install Solr / rhokp on solr_http_base (e.g. http://localhost:8080).
export OLS_CONFIG_FILE=... with solr_hybrid.enabled: true and either solr_direct_rag: true or false.
First run may download the embedding model from Hugging Face.

Config

lm_providers:

  • name: openai
    type: openai
    url: "https://api.openai.com/v1"
    credentials_path: /tmp/test-openai-key

    LLM: gpt-5.4-mini (listed for this API key under GET /v1/models).

    models:
    • name: gpt-5.4-mini
      ols_config:
      solr_hybrid:
      enabled: true
      solr_http_base: "http://localhost:8080"
      solr_direct_rag: true
      conversation_cache:
      type: memory
      memory:
      max_entries: 1000
      logging_config:
      app_log_level: info
      lib_log_level: warning
      default_provider: openai
      default_model: gpt-5.4-mini
      user_data_collection:
      transcripts_disabled: true
      authentication_config:
      module: "noop"
      dev_config:
      enable_dev_ui: true
      disable_auth: true
      disable_tls: true
      uvicorn_port_number: 8081

This is direct RAG. For tool-based solr_direct_rag: false

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@openshift-ci openshift-ci Bot requested review from bparees and joshuawilson May 12, 2026 14:38
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign raptorsun for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@blublinsky blublinsky force-pushed the okp-rag branch 2 times, most recently from 4c89880 to 99d82f9 Compare May 19, 2026 14:57
@blublinsky blublinsky force-pushed the okp-rag branch 3 times, most recently from 914faae to 37a7b67 Compare May 20, 2026 12:30
Comment thread ols/src/prompts/prompts.py Outdated

SOLR_DOCS_TOOL_AGENT_SUPPLEMENT = """
Solr docs tool:
* ``search_openshift_documentation`` searches published Red Hat product docs (not the cluster). Prefer one short query before answering from memory on product behavior, APIs, operators, upgrades, or whether docs exist.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"(not the cluster)" seems not clear: not the documents about this specific cluster? tool does not search inside the cluster for related objects?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread docs/ai/config.md Outdated

Omit the key to leave Solr hybrid RAG off (no client, no tool). When present, values map to `SolrHybridSettings`; `enabled: false` disables the feature without removing the block. `solr_http_base` must be a valid `http` or `https` URL with a host when `enabled` is true (checked in `validate_yaml()`).

When ``solr_hybrid.enabled`` is true, every entry under ``reference_content.indexes``
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solr_hybrid in config does not have the property enabled.
we can change the phrase to "when solr_hybrid" is defined in the config" corresponding to current code in PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"No docs above hybrid_score_threshold=%s for: %s",
cfg.hybrid_score_threshold,
query,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be added here the fallback to "/select" endpoint?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hybrid_score_threshold defaults to 0.0 (no filtering) and the operator does not expose this parameter — it always uses the default. When someone explicitly sets a threshold, they're choosing "no context over bad context." Falling back to /select would return the same or weaker documents that the hybrid path already rejected, undermining that intent.

if retrieved_nodes:
logger.info(
"Retrieved %d document nodes for RAG context", len(retrieved_nodes)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be useful to sort the documents from multiple sources using the same standard to avoid those at the beggining of the list are most weighted to the LLM's reasoning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid concern, but in practice:

FAISS and Solr are never used together for OpenShift docs — once we switch to Solr, FAISS-based product documentation goes away.
They can coexist for OpenShift docs (Solr) + BYOK. In that case there are two options: BYOK as direct RAG + Solr as a tool, or both BYOK and Solr as tools (PR for this is coming).
So the mixed-source scoring problem doesn't arise in the direct RAG path — it's either one source or the other, never both unsorted.

@blublinsky
Copy link
Copy Markdown
Contributor Author

/retest e2e-ols-cluster

@blublinsky
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 24, 2026

@blublinsky: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ols-cluster 06faf59 link true /test e2e-ols-cluster

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants