Skip to content

Commit 93f533b

Browse files
committed
OKP: Add dev.okpRagOnly config option
When dev.okpRagOnly is set to true, the default RAG database is disabled and only the OKP RAG is used. The option is intent for testing the OKP RAG separated from the default one. Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
1 parent 3959fad commit 93f533b

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

api/v1beta1/openstacklightspeed_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
type DevSpec struct {
5959
FeatureFlags []string `json:"featureFlags,omitempty"`
6060
OKPChunkFilterQuery string `json:"okpChunkFilterQuery,omitempty"`
61+
OKPRagOnly bool `json:"okpRagOnly,omitempty"`
6162
}
6263

6364
// OKPSpec defines configuration for the Offline Knowledge Portal (OKP).

config/samples/api_v1beta1_openstacklightspeed.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ spec:
2222
# featureFlags:
2323
# - okp
2424
# okpChunkFilterQuery: "product:(*openstack* OR *openshift*)"
25+
# okpRagOnly: true

internal/controller/assets/vector_database_build.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"""
6161

6262
import argparse
63+
import functools
6364
from pathlib import Path
6465
from typing import Any, Iterable, Optional, Callable
6566
import logging
@@ -218,7 +219,9 @@ def ogx_process(ogx_config_source_path: Path, ogx_config_target: dict[str, Any])
218219

219220
# -- Lightspeed Stack functions ----------------------------------------------
220221
def lstack_process(
221-
ogx_config_source_path: Path, lstack_config_target: dict[str, Any]
222+
ogx_config_source_path: Path,
223+
lstack_config_target: dict[str, Any],
224+
okp_rag_only: bool = False,
222225
) -> dict[str, Any]:
223226
"""Update Lightspeed stack config with RAG entries from OGX config source."""
224227
ogx_config_source = load_yaml_file(ogx_config_source_path)
@@ -243,7 +246,8 @@ def lstack_process(
243246
},
244247
)
245248

246-
add_unique(lstack_config_target["rag"]["inline"], vector_store_id)
249+
if not okp_rag_only:
250+
add_unique(lstack_config_target["rag"]["inline"], vector_store_id)
247251
return lstack_config_target
248252

249253

@@ -276,6 +280,12 @@ def parse_arguments() -> argparse.Namespace:
276280
required=True,
277281
help="Path (as pathlib.Path) to the base Lightspeed Stack configuration file",
278282
)
283+
parser.add_argument(
284+
"--okp-rag-only",
285+
action="store_true",
286+
default=False,
287+
help="When set, skip adding vector store IDs to rag.inline (OKP is the only RAG source)",
288+
)
279289

280290
return parser.parse_args()
281291

@@ -284,7 +294,8 @@ def main() -> None:
284294
"""main"""
285295
args = parse_arguments()
286296
config_build(args.vector_db_path, args.ogx_config_path, ogx_process)
287-
config_build(args.vector_db_path, args.lightspeed_stack_path, lstack_process)
297+
lstack_fn = functools.partial(lstack_process, okp_rag_only=args.okp_rag_only)
298+
config_build(args.vector_db_path, args.lightspeed_stack_path, lstack_fn)
288299

289300

290301
if __name__ == "__main__":

internal/controller/lcore_deployment.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,21 @@ func buildInitContainers(
248248
},
249249
})
250250

251+
configBuildCmd := []string{
252+
"python3", VectorDBScriptsMountPath + "/" + VectorDBBuildScriptKey,
253+
"--vector-db-path", VectorDBVolumeMountPath,
254+
"--ogx-config-path", OGXConfigInitContainerMountPath,
255+
"--lightspeed-stack-path", LightspeedStackInitContainerMountPath,
256+
}
257+
devConfig, _ := parseDevConfig(instance)
258+
if devConfig.OKPRagOnly {
259+
configBuildCmd = append(configBuildCmd, "--okp-rag-only")
260+
}
261+
251262
containers = append(containers, corev1.Container{
252-
Name: "vector-database-config-build",
253-
Image: apiv1beta1.OpenStackLightspeedDefaultValues.LCoreImageURL,
254-
Command: []string{
255-
"python3", VectorDBScriptsMountPath + "/" + VectorDBBuildScriptKey,
256-
"--vector-db-path", VectorDBVolumeMountPath,
257-
"--ogx-config-path", OGXConfigInitContainerMountPath,
258-
"--lightspeed-stack-path", LightspeedStackInitContainerMountPath,
259-
},
263+
Name: "vector-database-config-build",
264+
Image: apiv1beta1.OpenStackLightspeedDefaultValues.LCoreImageURL,
265+
Command: configBuildCmd,
260266
SecurityContext: securityContext,
261267
Resources: resourceRequirements,
262268
VolumeMounts: []corev1.VolumeMount{

0 commit comments

Comments
 (0)