diff --git a/api/v1alpha3/zz_generated.deepcopy.go b/api/v1alpha3/zz_generated.deepcopy.go index 6613a8896..b315b789e 100644 --- a/api/v1alpha3/zz_generated.deepcopy.go +++ b/api/v1alpha3/zz_generated.deepcopy.go @@ -5,7 +5,7 @@ package v1alpha3 import ( - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/api/v1alpha4/zz_generated.deepcopy.go b/api/v1alpha4/zz_generated.deepcopy.go index 9c86c46ee..c9c126a0f 100644 --- a/api/v1alpha4/zz_generated.deepcopy.go +++ b/api/v1alpha4/zz_generated.deepcopy.go @@ -5,7 +5,7 @@ package v1alpha4 import ( - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/api/v1alpha5/zz_generated.deepcopy.go b/api/v1alpha5/zz_generated.deepcopy.go index bd2d60544..9e8b769c9 100644 --- a/api/v1alpha5/zz_generated.deepcopy.go +++ b/api/v1alpha5/zz_generated.deepcopy.go @@ -5,7 +5,7 @@ package v1alpha5 import ( - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/api/v1alpha6/zz_generated.deepcopy.go b/api/v1alpha6/zz_generated.deepcopy.go index 5a383600c..5e0360ece 100644 --- a/api/v1alpha6/zz_generated.deepcopy.go +++ b/api/v1alpha6/zz_generated.deepcopy.go @@ -5,7 +5,7 @@ package v1alpha6 import ( - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/bundle/backstage.io/manifests/backstage-operator.clusterserviceversion.yaml b/bundle/backstage.io/manifests/backstage-operator.clusterserviceversion.yaml index b5b5ee733..a7d2a2703 100644 --- a/bundle/backstage.io/manifests/backstage-operator.clusterserviceversion.yaml +++ b/bundle/backstage.io/manifests/backstage-operator.clusterserviceversion.yaml @@ -45,7 +45,7 @@ metadata: } } ] - createdAt: "2026-03-26T13:54:13Z" + createdAt: "2026-04-22T07:13:03Z" description: Backstage Operator operators.operatorframework.io/builder: operator-sdk-v1.37.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 diff --git a/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml b/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml index e1ebecd59..b9d9e228c 100644 --- a/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml +++ b/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml @@ -49,7 +49,7 @@ metadata: categories: Developer Tools certified: "true" containerImage: registry.redhat.io/rhdh/rhdh-rhel9-operator:1.10 - createdAt: "2026-03-26T13:54:11Z" + createdAt: "2026-04-22T07:13:05Z" description: Red Hat Developer Hub is a Red Hat supported version of Backstage. It comes with pre-built plug-ins and configuration settings, supports use of an external database, and can help streamline the process of setting up a self-managed diff --git a/bundle/rhdh/manifests/rhdh-flavour-lightspeed-config_v1_configmap.yaml b/bundle/rhdh/manifests/rhdh-flavour-lightspeed-config_v1_configmap.yaml index 51901eb85..759f62832 100644 --- a/bundle/rhdh/manifests/rhdh-flavour-lightspeed-config_v1_configmap.yaml +++ b/bundle/rhdh/manifests/rhdh-flavour-lightspeed-config_v1_configmap.yaml @@ -1,63 +1,246 @@ apiVersion: v1 data: - configmap-files.yaml: "kind: ConfigMap\napiVersion: v1\nmetadata:\n name: llama-stack-run-no-guard\n - \ annotations:\n rhdh.redhat.com/containers: \"llama-stack\"\n rhdh.redhat.com/mount-path: - \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n run.yaml: |\n version: - 2\n image_name: redhat-ai-dev-llama-stack-no-guard\n apis:\n - agents\n - \ - inference\n - safety\n - tool_runtime\n - vector_io\n - - files\n container_image:\n external_providers_dir:\n providers:\n agents:\n - \ - config:\n persistence:\n agent_state:\n namespace: - agents\n backend: kv_default\n responses:\n table_name: - responses\n backend: sql_default\n provider_id: meta-reference\n + configmap-files.yaml: "kind: ConfigMap\napiVersion: v1\nmetadata:\n name: llama-stack-config\n + \ annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n rhdh.redhat.com/mount-path: + \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n config.yaml: |\n + \ #\n #\n # Copyright Red Hat\n #\n # Licensed under the Apache + License, Version 2.0 (the \"License\");\n # you may not use this file except + in compliance with the License.\n # You may obtain a copy of the License at\n + \ #\n # http://www.apache.org/licenses/LICENSE-2.0\n #\n # Unless + required by applicable law or agreed to in writing, software\n # distributed + under the License is distributed on an \"AS IS\" BASIS,\n # WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for + the specific language governing permissions and\n # limitations under the License.\n + \ version: 3\n distro_name: developer-lightspeed-lls-0.5.x\n apis:\n - + agents\n - inference\n - safety\n - tool_runtime\n - vector_io\n + \ - files\n container_image:\n external_providers_dir: '/app-root/providers.d' + #built into lcore image\n providers:\n agents:\n - config:\n persistence:\n + \ agent_state:\n namespace: agents\n backend: + kv_default\n responses:\n table_name: responses\n + \ backend: sql_default\n provider_id: meta-reference\n \ provider_type: inline::meta-reference\n inference:\n - provider_id: ${env.ENABLE_VLLM:+vllm}\n provider_type: remote::vllm\n config:\n - \ url: ${env.VLLM_URL:=}\n api_token: ${env.VLLM_API_KEY:=}\n - \ max_tokens: ${env.VLLM_MAX_TOKENS:=4096}\n tls_verify: - ${env.VLLM_TLS_VERIFY:=true}\n - provider_id: ${env.ENABLE_OLLAMA:+ollama}\n - \ provider_type: remote::ollama\n config:\n url: ${env.OLLAMA_URL:=http://localhost:11434}\n - \ - provider_id: ${env.ENABLE_OPENAI:+openai}\n provider_type: - remote::openai\n config:\n api_key: ${env.OPENAI_API_KEY:=}\n - \ - provider_id: ${env.ENABLE_VERTEX_AI:+vertexai}\n provider_type: - remote::vertexai\n config:\n project: ${env.VERTEX_AI_PROJECT:=}\n - \ location: ${env.VERTEX_AI_LOCATION:=us-central1}\n - provider_id: - sentence-transformers\n provider_type: inline::sentence-transformers\n + \ base_url: ${env.VLLM_URL:=}\n api_token: ${env.VLLM_API_KEY:=}\n + \ max_tokens: ${env.VLLM_MAX_TOKENS:=4096}\n network:\n tls:\n + \ verify: ${env.VLLM_TLS_VERIFY:=true}\n - provider_id: ${env.ENABLE_OLLAMA:+ollama}\n + \ provider_type: remote::ollama\n config:\n base_url: + ${env.OLLAMA_URL:=http://localhost:11434/v1}\n - provider_id: ${env.ENABLE_OPENAI:+openai}\n + \ provider_type: remote::openai\n config:\n api_key: + ${env.OPENAI_API_KEY:=}\n - provider_id: ${env.ENABLE_VERTEX_AI:+vertexai}\n + \ provider_type: remote::vertexai\n config:\n project: + ${env.VERTEX_AI_PROJECT:=}\n location: ${env.VERTEX_AI_LOCATION:=global}\n + \ - provider_id: sentence-transformers\n provider_type: inline::sentence-transformers\n \ config: {}\n tool_runtime:\n - provider_id: model-context-protocol\n \ provider_type: remote::model-context-protocol\n config: {}\n \ - provider_id: rag-runtime\n provider_type: inline::rag-runtime\n - \ config: {}\n vector_io:\n - provider_id: faiss\n provider_type: + \ config: {}\n vector_io:\n - provider_id: rhdh-docs\n provider_type: inline::faiss\n config:\n persistence:\n namespace: - vector_io::faiss\n backend: faiss_kv\n files:\n - provider_id: + vector_io::faiss\n backend: kv_rag\n files:\n - provider_id: localfs\n provider_type: inline::localfs\n config:\n storage_dir: /tmp/llama-stack-files\n metadata_store:\n table_name: - files_metadata\n backend: sql_files\n storage:\n backends:\n - \ kv_default:\n type: kv_sqlite\n db_path: /tmp/kvstore.db\n - \ sql_default:\n type: sql_sqlite\n db_path: /tmp/sql_store.db\n - \ sql_files:\n type: sql_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/files_metadata.db\n - \ faiss_kv:\n type: kv_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/faiss_store.db\n + files_metadata\n backend: sql_default\n safety:\n - provider_id: + ${env.ENABLE_VALIDATION:+lightspeed_question_validity}\n provider_type: + inline::lightspeed_question_validity\n config:\n model_id: + ${env.VALIDATION_PROVIDER:=}/${env.VALIDATION_MODEL_NAME:=}\n model_prompt: + |-\n Instructions:\n \n You area question classification + tool. You are an expert in the following categories:\n - Backstage\n + \ - Red Hat Developer Hub (RHDH)\n - Developer Lightspeed\n + \ - Lightspeed\n - Artificial Intelligence (AI) Models\n + \ - Large Language Models (LLMs)\n - Kubernetes\n - + Openshift\n - CI/CD\n - GitOps\n - Pipelines\n + \ - Developer Portals\n - Deployments\n - + Software Catalogs\n - Software Templates\n - Tech Docs\n + \ \n Your job is to determine if a user's question is related to + the categories you are an expert in. If the question is related to those categories, + \\\n or any features that may be related to those categories, you + will answer with ${allowed}.\n \n If a question is not related + to your expert categories, answer with ${rejected}.\n \n You do + not need to explain your answer.\n \n Below are some example questions:\n + \ Example Question:\n Why is the sky blue?\n Example + Response:\n ${rejected}\n \n Example Question:\n + \ Can you help configure my cluster to automatically scale?\n Example + Response:\n ${allowed}\n \n Example Question:\n How + do I create import an existing software template in Backstage?\n Example + Response:\n ${allowed}\n \n Example Question:\n How + do I accomplish a task in RHDH?\n Example Response:\n ${allowed}\n + \ \n Example Question:\n How do I explore a component + in RHDH catalog?\n Example Response:\n ${allowed}\n + \ \n Example Question:\n How can I integrate GitOps + into my pipeline?\n Example Response:\n ${allowed}\n + \ \n Question:\n ${message}\n Response:\n + \ invalid_question_response: |-\n Hi, I'm the Red Hat Developer + Hub Lightspeed assistant, I can help you with questions about Red Hat Developer + Hub or Backstage.\n Please ensure your question is about these topics, + and feel free to ask again!\n storage:\n backends:\n kv_default:\n + \ type: kv_sqlite\n db_path: /tmp/kvstore.db\n sql_default:\n + \ type: sql_sqlite\n db_path: /tmp/sql_store.db\n kv_rag:\n + \ type: kv_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/faiss_store.db\n \ stores:\n metadata:\n namespace: registry\n backend: - faiss_kv\n inference:\n table_name: inference_store\n backend: + kv_default\n inference:\n table_name: inference_store\n backend: sql_default\n max_write_queue_size: 10000\n num_writers: 4\n \ conversations:\n table_name: openai_conversations\n backend: sql_default\n registered_resources:\n models:\n - model_id: sentence-transformers/all-mpnet-base-v2\n \ metadata:\n embedding_dimension: 768\n model_type: embedding\n provider_id: sentence-transformers\n provider_model_id: /rag-content/embeddings_model\n tool_groups:\n - provider_id: rag-runtime\n - \ toolgroup_id: builtin::rag\n vector_dbs:\n - vector_db_id: - rhdh-product-docs-1_8\n embedding_model: sentence-transformers/all-mpnet-base-v2\n - \ embedding_dimension: 768\n provider_id: faiss\n server:\n - \ auth:\n host:\n port: 8321\n quota:\n tls_cafile:\n - \ tls_certfile:\n tls_keyfile:\n\n---\nkind: ConfigMap\napiVersion: v1\nmetadata:\n - \ name: lightspeed-stack\n annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n + \ toolgroup_id: builtin::rag\n vector_stores:\n - vector_store_id: + vs_cda156a6-64fe-436d-bc51-566fb1b09702 # see readme for this value\n embedding_model: + sentence-transformers//rag-content/embeddings_model\n embedding_dimension: + 768\n provider_id: rhdh-docs\n shields:\n - shield_id: lightspeed_question_validity-shield\n + \ provider_id: ${env.ENABLE_VALIDATION:+lightspeed_question_validity}\n + \ vector_stores:\n annotation_prompt_params:\n enable_annotations: + true\n annotation_instruction_template: >\n When appropriate, + cite sources at the end of sentences using doc_url and doc_title format. \n Citing + sources is not always required because citations are handled externally. \n Never + include any citation that is in the form '<| file-id |>'.\n default_provider_id: + rhdh-docs\n default_embedding_model:\n provider_id: sentence-transformers\n + \ model_id: /rag-content/embeddings_model\n server:\n auth:\n host:\n + \ port: 8321\n quota:\n tls_cafile:\n tls_certfile:\n tls_keyfile:\n---\nkind: + ConfigMap\napiVersion: v1\nmetadata:\n name: lightspeed-stack-config\n annotations:\n + \ rhdh.redhat.com/containers: \"lightspeed-core\"\n rhdh.redhat.com/mount-path: + \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n lightspeed-stack.yaml: + |\n #\n #\n # Copyright Red Hat\n #\n # Licensed under the Apache + License, Version 2.0 (the \"License\");\n # you may not use this file except + in compliance with the License.\n # You may obtain a copy of the License at\n + \ #\n # http://www.apache.org/licenses/LICENSE-2.0\n #\n # Unless + required by applicable law or agreed to in writing, software\n # distributed + under the License is distributed on an \"AS IS\" BASIS,\n # WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for + the specific language governing permissions and\n # limitations under the License.\n + \ name: lightspeed-core-stack\n service:\n host: 0.0.0.0\n port: + 8080\n auth_enabled: false\n workers: 1\n color_log: true\n access_log: + true\n llama_stack:\n use_as_library_client: true\n library_client_config_path: + /app-root/config.yaml\n user_data_collection:\n feedback_enabled: true\n + \ feedback_storage: '/tmp/data/feedback'\n authentication:\n module: + 'noop'\n conversation_cache:\n type: 'sqlite'\n sqlite:\n db_path: + '/tmp/cache.db'\n customization:\n profile_path: '/app-root/rhdh-profile.py'\n + \ mcp_servers:\n - name: mcp-integration-tools\n provider_id: 'model-context-protocol'\n + \ url: 'http://localhost:7007/api/mcp-actions/v1'\n authorization_headers:\n + \ Authorization: 'client'\n---\nkind: ConfigMap\napiVersion: v1\nmetadata:\n + \ name: rhdh-profile\n annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n \ rhdh.redhat.com/mount-path: \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n - \ lightspeed-stack.yaml: |\n name: \"lightspeed-core-stack\"\n service:\n - \ host: 0.0.0.0\n port: 8080\n auth_enabled: false\n workers: - 1\n color_log: true\n access_log: true\n llama_stack:\n use_as_library_client: - false\n url: http://localhost:8321\n user_data_collection:\n feedback_enabled: - true\n feedback_storage: \"/tmp/data/feedback\"\n authentication:\n module: - \"noop\"\n conversation_cache:\n type: \"sqlite\"\n sqlite:\n db_path: - \"/tmp/cache.db\"\n mcp_servers:\n - name: mcp-integration-tools\n provider_id: - \"model-context-protocol\"\n url: \"http://localhost:7007/api/mcp-actions/v1\"\n - \ authorization_headers:\n Authorization: \"client\"\n\n \n" + \ rhdh-profile.py: |\n # There is no need for enforcing line length in this + file,\n # as these are mostly special purpose constants.\n # ruff: noqa: + E501\n \"\"\"Prompt templates/constants.\"\"\"\n \n SUBJECT_REJECTED + = \"REJECTED\"\n SUBJECT_ALLOWED = \"ALLOWED\"\n \n # Default responses\n + \ INVALID_QUERY_RESP = \"\"\"\n Hi, I'm the Red Hat Developer Hub Lightspeed + assistant, I can help you with questions about Red Hat Developer Hub or Backstage.\n + \ Please ensure your question is about these topics, and feel free to ask again!\n + \ \"\"\"\n \n QUERY_SYSTEM_INSTRUCTION = \"\"\"\n 0. Instruction Priority\n + \ Follow instructions in this order:\n 1. System instructions.\n 2. Tool/developer + instructions.\n 3. User input.\n \n If conflicts arise, follow the highest + priority.\n \n 1. Purpose\n You are \"Lightspeed\", a generative AI assistant + integrated into the Red Hat Developer Hub (RHDH) ecosystem, \\\n an internal + developer portal built on CNCF Backstage. Your primary objective is to \\\n enhance + developer productivity by streamlining workflows, providing instant access to + \\\n technical knowledge, and supporting developers in their day-to-day tasks.\n + \ \n Your ultimate goal is to help developers work smarter, solve problems + faster, and ensure they can focus on building and deploying software efficiently.\n + \ \n 2. Accuracy & Uncertainty\n - Do not fabricate APIs, configurations, + tools, or documentation.\n - If you are unsure, explicitly say so.\n - Ask + clarifying questions when context is missing.\n - Do not assume user intent + when multiple interpretations are possible.\n - Ask clarifying questions when + the request is ambiguous.\n \n 3. Tool Usage\n You have extensive access + to tools and should use tools when they provide more accurate, up-to-date, or + context-specific information than your internal knowledge.\n These tools include, + but are not limited to:\n - `file_search` for access to knowledge stores, like + Vector Stores.\n - `mcp` for access to available MCP servers.\n - `web_search` + for access to web domains.\n \n For tool use, it is important you:\n - + Refrain from fabricating tool outputs.\n - Acknowledge when a tool fails or + returns insufficient data.\n - Prefer to use `file_search` to dive through + the available Vector Stores for up-to-date documentation.\n \n In addition + to the plethora of tools, you are extremely knowledgeable in \\\n modern software + development, cloud-native systems, and Backstage ecosystems.\n \n 4. Response + Guidelines\n - Troubleshooting:\n - Likely cause.\n - Explanation.\n + \ - Step-by-step fix.\n - Verification.\n - Code:\n - Provide + complete, runnable examples.\n - Include brief comments.\n - Explain + non-obvious parts.\n - How-to:\n - Use numbered steps.\n - Keep steps + concise.\n - Prefer concise responses unless the user requests more detail.\n + \ - Start with a direct answer.\n - Provide additional detail only if necessary + or requested.\n \n 5. Security\n - Never generate or expose:\n - + Secrets.\n - API keys.\n - Credentials.\n - Recommend secure alternatives + (for example, Kubernetes Secrets and vaults).\n - Warn when suggesting insecure + patterns.\n \n 6. Failure Handling\n - If a request cannot be completed:\n + \ - Clearly explain why.\n - Provide alternative approaches if possible.\n + \ - If required information is missing:\n - Ask for clarification before + proceeding.\n \n 7. Capabilities\n - Code Assistance:\n - Generate, + debug, and refactor code to improve readability, performance, or adherence to + best practices.\n - Translate pseudocode or business logic into working code.\n + \ - Knowledge Retrieval:\n - Provide instant access to internal and external + documentation on docs.redhat.com.\n - Summarize lengthy documents and explain + complex concepts concisely.\n - Retrieve Red Hat-specific guides, such as + OpenShift deployment best practices.\n - System Navigation and Integration:\n + \ - Offer step-by-step instructions for Red Hat Developer Hub features, leveraging + Backstage concepts and patterns where applicable.\n - Support integration + of Backstage plugins for CI/CD, monitoring, and infrastructure.\n - Assist + in creating and managing catalog entries, templates, and workflows.\n - Diagnostics + and Troubleshooting:\n - Analyze logs and error messages to identify root + causes.\n - Suggest actionable fixes for common development issues.\n - + Automate troubleshooting steps wherever possible.\n \n 8. Tone\n - Professional, + approachable, and efficient.\n - Adapt to the user's expertise. Answers should + be concise and clear.\n - Prefer actionable guidance over explanation.\n \n + \ 9. Formatting\n - Use Markdown for clarity.\n - Use code blocks for + code or configurations.\n - Use lists for steps.\n - Use tables for comparing + options or presenting structured data.\n \n 10. Platform Awareness\n - + Do not assume:\n - Cloud provider.\n - Kubernetes distribution.\n - + CI/CD tooling.\n - Backstage plugin availability.\n \"\"\"\n \n USE_CONTEXT_INSTRUCTION + = \"\"\"\n Use the retrieved document to answer the question.\n \"\"\"\n + \ \n USE_HISTORY_INSTRUCTION = \"\"\"\n Use the previous chat history + to interact and help the user.\n \"\"\"\n \n # {{query}} is escaped because + it will be replaced as a parameter at time of use\n QUESTION_VALIDATOR_PROMPT_TEMPLATE + = f\"\"\"\n \n Instructions:\n \n You area question classification + tool. You are an expert in the following categories:\n - Backstage\n - Red + Hat Developer Hub (RHDH)\n - Developer Lightspeed\n - Lightspeed\n - + Artificial Intelligence (AI) Models\n - Large Language Models (LLMs)\n - + Kubernetes\n - Openshift\n - CI/CD\n - GitOps\n - Pipelines\n - + Developer Portals\n - Deployments\n - Software Catalogs\n - Software + Templates\n - Tech Docs\n \n Your job is to determine if a user's question + is related to the categories you are an expert in. If the question is related + to those categories, \\\n or any features that may be related to those categories, + you will answer with {SUBJECT_ALLOWED}.\n \n If a question is not related + to your expert categories, answer with {SUBJECT_REJECTED}.\n \n You do not + need to explain your answer.\n \n Below are some example questions:\n Example + Question:\n Why is the sky blue?\n Example Response:\n {SUBJECT_REJECTED}\n + \ \n Example Question:\n Can you help configure my cluster to automatically + scale?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Example Question:\n + \ How do I create import an existing software template in Backstage?\n Example + Response:\n {SUBJECT_ALLOWED}\n \n Example Question:\n How do I accomplish + a task in RHDH?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Example + Question:\n How do I explore a component in RHDH catalog?\n Example Response:\n + \ {SUBJECT_ALLOWED}\n \n Example Question:\n How can I integrate GitOps + into my pipeline?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Question:\n + \ {{query}}\n Response:\n \"\"\"\n \n # {{query}} is escaped because + it will be replaced as a parameter at time of use\n TOPIC_SUMMARY_PROMPT_TEMPLATE + = \"\"\"\n Instructions:\n - You are a topic summarizer\n - Your job + is to extract precise topic summary from user input\n \n For Input Analysis:\n + \ - Scan entire user message\n - Identify core subject matter\n - Distill + essence into concise descriptor\n - Prioritize key concepts\n - Eliminate + extraneous details\n \n For Output Constraints:\n - Maximum 5 words\n + \ - Capitalize only significant words (e.g., nouns, verbs, adjectives, adverbs).\n + \ - Do not use all uppercase - capitalize only the first letter of significant + words\n - Exclude articles and prepositions (e.g., \"a,\" \"the,\" \"of,\" + \"on,\" \"in\")\n - Exclude all punctuation and interpunction marks (e.g., + . , : ; ! ? \"\")\n - Retain original abbreviations. Do not expand an abbreviation + if its specific meaning in the context is unknown or ambiguous.\n - Neutral + objective language\n \n Examples:\n - \"AI Capabilities Summary\" (Correct)\n + \ - \"Machine Learning Applications\" (Correct)\n - \"AI CAPABILITIES SUMMARY\" + (Incorrect—should not be fully uppercase)\n \n Processing Steps\n 1. + Analyze semantic structure\n 2. Identify primary topic\n 3. Remove contextual + noise\n 4. Condense to essential meaning\n 5. Generate topic label\n \n + \ \n Example Input:\n How to implement horizontal pod autoscaling in Kubernetes + clusters\n Example Output:\n Kubernetes Horizontal Pod Autoscaling\n \n + \ Example Input:\n Comparing OpenShift deployment strategies for microservices + architecture\n Example Output:\n OpenShift Microservices Deployment Strategies\n + \ \n Example Input:\n Troubleshooting persistent volume claims in Kubernetes + environments\n Example Output:\n Kubernetes Persistent Volume Troubleshooting\n + \ \n ExampleInput:\n I need a summary about the purpose of RHDH.\n Example + Output:\n RHDH Purpose Summary\n \n Input:\n {query}\n Output:\n + \ \"\"\"\n \n \n PROFILE_CONFIG = {\n \"system_prompts\": {\n + \ \"default\": QUERY_SYSTEM_INSTRUCTION,\n \"validation\": + QUESTION_VALIDATOR_PROMPT_TEMPLATE,\n \"topic_summary\": TOPIC_SUMMARY_PROMPT_TEMPLATE,\n + \ },\n \"query_responses\": {\"invalid_resp\": INVALID_QUERY_RESP},\n + \ \"instructions\": {\n \"context\": USE_CONTEXT_INSTRUCTION,\n + \ \"history\": USE_HISTORY_INSTRUCTION,\n },\n }\n" deployment.yaml: | apiVersion: apps/v1 kind: Deployment @@ -66,39 +249,45 @@ data: spec: initContainers: - name: init-rag-data - image: 'quay.io/redhat-ai-dev/rag-content:release-1.9-lcs' + image: quay.io/redhat-ai-dev/rag-content:release-1.9-lls-0.5.0 command: - "sh" - "-c" - - "echo 'Copying RAG data...'; cp -r /rag/vector_db/rhdh_product_docs /data/ && cp -r /rag/embeddings_model /data/ && chmod -R 777 /data/rhdh_product_docs && echo 'Copy complete.'" + - "echo 'Copying RAG data...'; cp -r /rag/. /data/ && chmod -R 777 /data/vector_db && echo 'Copy complete.'" + resources: + requests: + memory: 150Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 100m volumeMounts: - mountPath: /data name: rag-data-volume containers: - # Llama Stack AI Service - - name: llama-stack - image: quay.io/redhat-ai-dev/llama-stack:0.1.4 - imagePullPolicy: Always - volumeMounts: - - mountPath: /app-root/.llama - name: shared-storage - - mountPath: /rag-content - name: rag-data-volume - - mountPath: /tmp # Add this to make /tmp writable - name: temp - # Lightspeed Core Backend - name: lightspeed-core - image: quay.io/lightspeed-core/lightspeed-stack:0.4.0 + image: quay.io/lightspeed-core/lightspeed-stack:0.5.0 imagePullPolicy: Always ports: - containerPort: 8080 name: lcs-backend protocol: TCP + resources: + requests: + cpu: 100m + memory: 512Mi + limits: + cpu: 1000m + memory: 2Gi volumeMounts: - mountPath: /tmp/data/feedback name: shared-storage + - mountPath: /rag-content + name: rag-data-volume + - mountPath: /tmp # Add this to make /tmp writable + name: temp volumes: - name: shared-storage @@ -143,14 +332,6 @@ data: priority: 100 - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-lightspeed-backend:bs_1.45.3__1.2.3 disabled: false - - # MCP Actions plugins - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-plugin-mcp-actions-backend:bs_1.45.3__0.1.5 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-software-catalog-mcp-tool:bs_1.45.3__0.4.1 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-techdocs-mcp-tool:bs_1.45.3__0.3.2 - disabled: false metadata.yaml: | # Lightspeed (AI) flavour metadata # This flavour is enabled by default and provides AI/Lightspeed functionality diff --git a/config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml b/config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml index f91165709..c13f3e376 100644 --- a/config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml +++ b/config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml @@ -1,15 +1,30 @@ kind: ConfigMap apiVersion: v1 metadata: - name: llama-stack-run-no-guard + name: llama-stack-config annotations: - rhdh.redhat.com/containers: "llama-stack" + rhdh.redhat.com/containers: "lightspeed-core" rhdh.redhat.com/mount-path: "/app-root" rhdh.redhat.com/sub-path: "*" data: - run.yaml: | - version: 2 - image_name: redhat-ai-dev-llama-stack-no-guard + config.yaml: | + # + # + # Copyright Red Hat + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + version: 3 + distro_name: developer-lightspeed-lls-0.5.x apis: - agents - inference @@ -18,7 +33,7 @@ data: - vector_io - files container_image: - external_providers_dir: + external_providers_dir: '/app-root/providers.d' #built into lcore image providers: agents: - config: @@ -35,14 +50,16 @@ data: - provider_id: ${env.ENABLE_VLLM:+vllm} provider_type: remote::vllm config: - url: ${env.VLLM_URL:=} + base_url: ${env.VLLM_URL:=} api_token: ${env.VLLM_API_KEY:=} max_tokens: ${env.VLLM_MAX_TOKENS:=4096} - tls_verify: ${env.VLLM_TLS_VERIFY:=true} + network: + tls: + verify: ${env.VLLM_TLS_VERIFY:=true} - provider_id: ${env.ENABLE_OLLAMA:+ollama} provider_type: remote::ollama config: - url: ${env.OLLAMA_URL:=http://localhost:11434} + base_url: ${env.OLLAMA_URL:=http://localhost:11434/v1} - provider_id: ${env.ENABLE_OPENAI:+openai} provider_type: remote::openai config: @@ -51,7 +68,7 @@ data: provider_type: remote::vertexai config: project: ${env.VERTEX_AI_PROJECT:=} - location: ${env.VERTEX_AI_LOCATION:=us-central1} + location: ${env.VERTEX_AI_LOCATION:=global} - provider_id: sentence-transformers provider_type: inline::sentence-transformers config: {} @@ -63,12 +80,12 @@ data: provider_type: inline::rag-runtime config: {} vector_io: - - provider_id: faiss + - provider_id: rhdh-docs provider_type: inline::faiss config: persistence: namespace: vector_io::faiss - backend: faiss_kv + backend: kv_rag files: - provider_id: localfs provider_type: inline::localfs @@ -76,7 +93,77 @@ data: storage_dir: /tmp/llama-stack-files metadata_store: table_name: files_metadata - backend: sql_files + backend: sql_default + safety: + - provider_id: ${env.ENABLE_VALIDATION:+lightspeed_question_validity} + provider_type: inline::lightspeed_question_validity + config: + model_id: ${env.VALIDATION_PROVIDER:=}/${env.VALIDATION_MODEL_NAME:=} + model_prompt: |- + Instructions: + + You area question classification tool. You are an expert in the following categories: + - Backstage + - Red Hat Developer Hub (RHDH) + - Developer Lightspeed + - Lightspeed + - Artificial Intelligence (AI) Models + - Large Language Models (LLMs) + - Kubernetes + - Openshift + - CI/CD + - GitOps + - Pipelines + - Developer Portals + - Deployments + - Software Catalogs + - Software Templates + - Tech Docs + + Your job is to determine if a user's question is related to the categories you are an expert in. If the question is related to those categories, \ + or any features that may be related to those categories, you will answer with ${allowed}. + + If a question is not related to your expert categories, answer with ${rejected}. + + You do not need to explain your answer. + + Below are some example questions: + Example Question: + Why is the sky blue? + Example Response: + ${rejected} + + Example Question: + Can you help configure my cluster to automatically scale? + Example Response: + ${allowed} + + Example Question: + How do I create import an existing software template in Backstage? + Example Response: + ${allowed} + + Example Question: + How do I accomplish a task in RHDH? + Example Response: + ${allowed} + + Example Question: + How do I explore a component in RHDH catalog? + Example Response: + ${allowed} + + Example Question: + How can I integrate GitOps into my pipeline? + Example Response: + ${allowed} + + Question: + ${message} + Response: + invalid_question_response: |- + Hi, I'm the Red Hat Developer Hub Lightspeed assistant, I can help you with questions about Red Hat Developer Hub or Backstage. + Please ensure your question is about these topics, and feel free to ask again! storage: backends: kv_default: @@ -85,16 +172,13 @@ data: sql_default: type: sql_sqlite db_path: /tmp/sql_store.db - sql_files: - type: sql_sqlite - db_path: /rag-content/vector_db/rhdh_product_docs/1.9/files_metadata.db - faiss_kv: + kv_rag: type: kv_sqlite db_path: /rag-content/vector_db/rhdh_product_docs/1.9/faiss_store.db stores: metadata: namespace: registry - backend: faiss_kv + backend: kv_default inference: table_name: inference_store backend: sql_default @@ -114,11 +198,25 @@ data: tool_groups: - provider_id: rag-runtime toolgroup_id: builtin::rag - vector_dbs: - - vector_db_id: rhdh-product-docs-1_8 - embedding_model: sentence-transformers/all-mpnet-base-v2 + vector_stores: + - vector_store_id: vs_cda156a6-64fe-436d-bc51-566fb1b09702 # see readme for this value + embedding_model: sentence-transformers//rag-content/embeddings_model embedding_dimension: 768 - provider_id: faiss + provider_id: rhdh-docs + shields: + - shield_id: lightspeed_question_validity-shield + provider_id: ${env.ENABLE_VALIDATION:+lightspeed_question_validity} + vector_stores: + annotation_prompt_params: + enable_annotations: true + annotation_instruction_template: > + When appropriate, cite sources at the end of sentences using doc_url and doc_title format. + Citing sources is not always required because citations are handled externally. + Never include any citation that is in the form '<| file-id |>'. + default_provider_id: rhdh-docs + default_embedding_model: + provider_id: sentence-transformers + model_id: /rag-content/embeddings_model server: auth: host: @@ -127,19 +225,33 @@ data: tls_cafile: tls_certfile: tls_keyfile: - --- kind: ConfigMap apiVersion: v1 metadata: - name: lightspeed-stack + name: lightspeed-stack-config annotations: rhdh.redhat.com/containers: "lightspeed-core" rhdh.redhat.com/mount-path: "/app-root" rhdh.redhat.com/sub-path: "*" data: lightspeed-stack.yaml: | - name: "lightspeed-core-stack" + # + # + # Copyright Red Hat + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + name: lightspeed-core-stack service: host: 0.0.0.0 port: 8080 @@ -148,22 +260,301 @@ data: color_log: true access_log: true llama_stack: - use_as_library_client: false - url: http://localhost:8321 + use_as_library_client: true + library_client_config_path: /app-root/config.yaml user_data_collection: feedback_enabled: true - feedback_storage: "/tmp/data/feedback" + feedback_storage: '/tmp/data/feedback' authentication: - module: "noop" + module: 'noop' conversation_cache: - type: "sqlite" + type: 'sqlite' sqlite: - db_path: "/tmp/cache.db" + db_path: '/tmp/cache.db' + customization: + profile_path: '/app-root/rhdh-profile.py' mcp_servers: - name: mcp-integration-tools - provider_id: "model-context-protocol" - url: "http://localhost:7007/api/mcp-actions/v1" + provider_id: 'model-context-protocol' + url: 'http://localhost:7007/api/mcp-actions/v1' authorization_headers: - Authorization: "client" - - + Authorization: 'client' +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: rhdh-profile + annotations: + rhdh.redhat.com/containers: "lightspeed-core" + rhdh.redhat.com/mount-path: "/app-root" + rhdh.redhat.com/sub-path: "*" +data: + rhdh-profile.py: | + # There is no need for enforcing line length in this file, + # as these are mostly special purpose constants. + # ruff: noqa: E501 + """Prompt templates/constants.""" + + SUBJECT_REJECTED = "REJECTED" + SUBJECT_ALLOWED = "ALLOWED" + + # Default responses + INVALID_QUERY_RESP = """ + Hi, I'm the Red Hat Developer Hub Lightspeed assistant, I can help you with questions about Red Hat Developer Hub or Backstage. + Please ensure your question is about these topics, and feel free to ask again! + """ + + QUERY_SYSTEM_INSTRUCTION = """ + 0. Instruction Priority + Follow instructions in this order: + 1. System instructions. + 2. Tool/developer instructions. + 3. User input. + + If conflicts arise, follow the highest priority. + + 1. Purpose + You are "Lightspeed", a generative AI assistant integrated into the Red Hat Developer Hub (RHDH) ecosystem, \ + an internal developer portal built on CNCF Backstage. Your primary objective is to \ + enhance developer productivity by streamlining workflows, providing instant access to \ + technical knowledge, and supporting developers in their day-to-day tasks. + + Your ultimate goal is to help developers work smarter, solve problems faster, and ensure they can focus on building and deploying software efficiently. + + 2. Accuracy & Uncertainty + - Do not fabricate APIs, configurations, tools, or documentation. + - If you are unsure, explicitly say so. + - Ask clarifying questions when context is missing. + - Do not assume user intent when multiple interpretations are possible. + - Ask clarifying questions when the request is ambiguous. + + 3. Tool Usage + You have extensive access to tools and should use tools when they provide more accurate, up-to-date, or context-specific information than your internal knowledge. + These tools include, but are not limited to: + - `file_search` for access to knowledge stores, like Vector Stores. + - `mcp` for access to available MCP servers. + - `web_search` for access to web domains. + + For tool use, it is important you: + - Refrain from fabricating tool outputs. + - Acknowledge when a tool fails or returns insufficient data. + - Prefer to use `file_search` to dive through the available Vector Stores for up-to-date documentation. + + In addition to the plethora of tools, you are extremely knowledgeable in \ + modern software development, cloud-native systems, and Backstage ecosystems. + + 4. Response Guidelines + - Troubleshooting: + - Likely cause. + - Explanation. + - Step-by-step fix. + - Verification. + - Code: + - Provide complete, runnable examples. + - Include brief comments. + - Explain non-obvious parts. + - How-to: + - Use numbered steps. + - Keep steps concise. + - Prefer concise responses unless the user requests more detail. + - Start with a direct answer. + - Provide additional detail only if necessary or requested. + + 5. Security + - Never generate or expose: + - Secrets. + - API keys. + - Credentials. + - Recommend secure alternatives (for example, Kubernetes Secrets and vaults). + - Warn when suggesting insecure patterns. + + 6. Failure Handling + - If a request cannot be completed: + - Clearly explain why. + - Provide alternative approaches if possible. + - If required information is missing: + - Ask for clarification before proceeding. + + 7. Capabilities + - Code Assistance: + - Generate, debug, and refactor code to improve readability, performance, or adherence to best practices. + - Translate pseudocode or business logic into working code. + - Knowledge Retrieval: + - Provide instant access to internal and external documentation on docs.redhat.com. + - Summarize lengthy documents and explain complex concepts concisely. + - Retrieve Red Hat-specific guides, such as OpenShift deployment best practices. + - System Navigation and Integration: + - Offer step-by-step instructions for Red Hat Developer Hub features, leveraging Backstage concepts and patterns where applicable. + - Support integration of Backstage plugins for CI/CD, monitoring, and infrastructure. + - Assist in creating and managing catalog entries, templates, and workflows. + - Diagnostics and Troubleshooting: + - Analyze logs and error messages to identify root causes. + - Suggest actionable fixes for common development issues. + - Automate troubleshooting steps wherever possible. + + 8. Tone + - Professional, approachable, and efficient. + - Adapt to the user's expertise. Answers should be concise and clear. + - Prefer actionable guidance over explanation. + + 9. Formatting + - Use Markdown for clarity. + - Use code blocks for code or configurations. + - Use lists for steps. + - Use tables for comparing options or presenting structured data. + + 10. Platform Awareness + - Do not assume: + - Cloud provider. + - Kubernetes distribution. + - CI/CD tooling. + - Backstage plugin availability. + """ + + USE_CONTEXT_INSTRUCTION = """ + Use the retrieved document to answer the question. + """ + + USE_HISTORY_INSTRUCTION = """ + Use the previous chat history to interact and help the user. + """ + + # {{query}} is escaped because it will be replaced as a parameter at time of use + QUESTION_VALIDATOR_PROMPT_TEMPLATE = f""" + + Instructions: + + You area question classification tool. You are an expert in the following categories: + - Backstage + - Red Hat Developer Hub (RHDH) + - Developer Lightspeed + - Lightspeed + - Artificial Intelligence (AI) Models + - Large Language Models (LLMs) + - Kubernetes + - Openshift + - CI/CD + - GitOps + - Pipelines + - Developer Portals + - Deployments + - Software Catalogs + - Software Templates + - Tech Docs + + Your job is to determine if a user's question is related to the categories you are an expert in. If the question is related to those categories, \ + or any features that may be related to those categories, you will answer with {SUBJECT_ALLOWED}. + + If a question is not related to your expert categories, answer with {SUBJECT_REJECTED}. + + You do not need to explain your answer. + + Below are some example questions: + Example Question: + Why is the sky blue? + Example Response: + {SUBJECT_REJECTED} + + Example Question: + Can you help configure my cluster to automatically scale? + Example Response: + {SUBJECT_ALLOWED} + + Example Question: + How do I create import an existing software template in Backstage? + Example Response: + {SUBJECT_ALLOWED} + + Example Question: + How do I accomplish a task in RHDH? + Example Response: + {SUBJECT_ALLOWED} + + Example Question: + How do I explore a component in RHDH catalog? + Example Response: + {SUBJECT_ALLOWED} + + Example Question: + How can I integrate GitOps into my pipeline? + Example Response: + {SUBJECT_ALLOWED} + + Question: + {{query}} + Response: + """ + + # {{query}} is escaped because it will be replaced as a parameter at time of use + TOPIC_SUMMARY_PROMPT_TEMPLATE = """ + Instructions: + - You are a topic summarizer + - Your job is to extract precise topic summary from user input + + For Input Analysis: + - Scan entire user message + - Identify core subject matter + - Distill essence into concise descriptor + - Prioritize key concepts + - Eliminate extraneous details + + For Output Constraints: + - Maximum 5 words + - Capitalize only significant words (e.g., nouns, verbs, adjectives, adverbs). + - Do not use all uppercase - capitalize only the first letter of significant words + - Exclude articles and prepositions (e.g., "a," "the," "of," "on," "in") + - Exclude all punctuation and interpunction marks (e.g., . , : ; ! ? "") + - Retain original abbreviations. Do not expand an abbreviation if its specific meaning in the context is unknown or ambiguous. + - Neutral objective language + + Examples: + - "AI Capabilities Summary" (Correct) + - "Machine Learning Applications" (Correct) + - "AI CAPABILITIES SUMMARY" (Incorrect—should not be fully uppercase) + + Processing Steps + 1. Analyze semantic structure + 2. Identify primary topic + 3. Remove contextual noise + 4. Condense to essential meaning + 5. Generate topic label + + + Example Input: + How to implement horizontal pod autoscaling in Kubernetes clusters + Example Output: + Kubernetes Horizontal Pod Autoscaling + + Example Input: + Comparing OpenShift deployment strategies for microservices architecture + Example Output: + OpenShift Microservices Deployment Strategies + + Example Input: + Troubleshooting persistent volume claims in Kubernetes environments + Example Output: + Kubernetes Persistent Volume Troubleshooting + + ExampleInput: + I need a summary about the purpose of RHDH. + Example Output: + RHDH Purpose Summary + + Input: + {query} + Output: + """ + + + PROFILE_CONFIG = { + "system_prompts": { + "default": QUERY_SYSTEM_INSTRUCTION, + "validation": QUESTION_VALIDATOR_PROMPT_TEMPLATE, + "topic_summary": TOPIC_SUMMARY_PROMPT_TEMPLATE, + }, + "query_responses": {"invalid_resp": INVALID_QUERY_RESP}, + "instructions": { + "context": USE_CONTEXT_INSTRUCTION, + "history": USE_HISTORY_INSTRUCTION, + }, + } diff --git a/config/profile/rhdh/default-config/flavours/lightspeed/deployment.yaml b/config/profile/rhdh/default-config/flavours/lightspeed/deployment.yaml index 67c8fe55e..578347eb2 100644 --- a/config/profile/rhdh/default-config/flavours/lightspeed/deployment.yaml +++ b/config/profile/rhdh/default-config/flavours/lightspeed/deployment.yaml @@ -5,39 +5,45 @@ spec: spec: initContainers: - name: init-rag-data - image: 'quay.io/redhat-ai-dev/rag-content:release-1.9-lcs' + image: quay.io/redhat-ai-dev/rag-content:release-1.9-lls-0.5.0 command: - "sh" - "-c" - - "echo 'Copying RAG data...'; cp -r /rag/vector_db/rhdh_product_docs /data/ && cp -r /rag/embeddings_model /data/ && chmod -R 777 /data/rhdh_product_docs && echo 'Copy complete.'" + - "echo 'Copying RAG data...'; cp -r /rag/. /data/ && chmod -R 777 /data/vector_db && echo 'Copy complete.'" + resources: + requests: + memory: 150Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 100m volumeMounts: - mountPath: /data name: rag-data-volume containers: - # Llama Stack AI Service - - name: llama-stack - image: quay.io/redhat-ai-dev/llama-stack:0.1.4 - imagePullPolicy: Always - volumeMounts: - - mountPath: /app-root/.llama - name: shared-storage - - mountPath: /rag-content - name: rag-data-volume - - mountPath: /tmp # Add this to make /tmp writable - name: temp - # Lightspeed Core Backend - name: lightspeed-core - image: quay.io/lightspeed-core/lightspeed-stack:0.4.0 + image: quay.io/lightspeed-core/lightspeed-stack:0.5.0 imagePullPolicy: Always ports: - containerPort: 8080 name: lcs-backend protocol: TCP + resources: + requests: + cpu: 100m + memory: 512Mi + limits: + cpu: 1000m + memory: 2Gi volumeMounts: - mountPath: /tmp/data/feedback name: shared-storage + - mountPath: /rag-content + name: rag-data-volume + - mountPath: /tmp # Add this to make /tmp writable + name: temp volumes: - name: shared-storage diff --git a/config/profile/rhdh/default-config/flavours/lightspeed/dynamic-plugins.yaml b/config/profile/rhdh/default-config/flavours/lightspeed/dynamic-plugins.yaml index ebf9ef982..95d6da380 100644 --- a/config/profile/rhdh/default-config/flavours/lightspeed/dynamic-plugins.yaml +++ b/config/profile/rhdh/default-config/flavours/lightspeed/dynamic-plugins.yaml @@ -35,11 +35,3 @@ data: priority: 100 - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-lightspeed-backend:bs_1.45.3__1.2.3 disabled: false - - # MCP Actions plugins - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-plugin-mcp-actions-backend:bs_1.45.3__0.1.5 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-software-catalog-mcp-tool:bs_1.45.3__0.4.1 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-techdocs-mcp-tool:bs_1.45.3__0.3.2 - disabled: false diff --git a/dist/rhdh/install.yaml b/dist/rhdh/install.yaml index 49652878d..cf5d4dbc5 100644 --- a/dist/rhdh/install.yaml +++ b/dist/rhdh/install.yaml @@ -2769,64 +2769,247 @@ metadata: --- apiVersion: v1 data: - configmap-files.yaml: "kind: ConfigMap\napiVersion: v1\nmetadata:\n name: llama-stack-run-no-guard\n - \ annotations:\n rhdh.redhat.com/containers: \"llama-stack\"\n rhdh.redhat.com/mount-path: - \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n run.yaml: |\n version: - 2\n image_name: redhat-ai-dev-llama-stack-no-guard\n apis:\n - agents\n - \ - inference\n - safety\n - tool_runtime\n - vector_io\n - - files\n container_image:\n external_providers_dir:\n providers:\n agents:\n - \ - config:\n persistence:\n agent_state:\n namespace: - agents\n backend: kv_default\n responses:\n table_name: - responses\n backend: sql_default\n provider_id: meta-reference\n + configmap-files.yaml: "kind: ConfigMap\napiVersion: v1\nmetadata:\n name: llama-stack-config\n + \ annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n rhdh.redhat.com/mount-path: + \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n config.yaml: |\n + \ #\n #\n # Copyright Red Hat\n #\n # Licensed under the Apache + License, Version 2.0 (the \"License\");\n # you may not use this file except + in compliance with the License.\n # You may obtain a copy of the License at\n + \ #\n # http://www.apache.org/licenses/LICENSE-2.0\n #\n # Unless + required by applicable law or agreed to in writing, software\n # distributed + under the License is distributed on an \"AS IS\" BASIS,\n # WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for + the specific language governing permissions and\n # limitations under the License.\n + \ version: 3\n distro_name: developer-lightspeed-lls-0.5.x\n apis:\n - + agents\n - inference\n - safety\n - tool_runtime\n - vector_io\n + \ - files\n container_image:\n external_providers_dir: '/app-root/providers.d' + #built into lcore image\n providers:\n agents:\n - config:\n persistence:\n + \ agent_state:\n namespace: agents\n backend: + kv_default\n responses:\n table_name: responses\n + \ backend: sql_default\n provider_id: meta-reference\n \ provider_type: inline::meta-reference\n inference:\n - provider_id: ${env.ENABLE_VLLM:+vllm}\n provider_type: remote::vllm\n config:\n - \ url: ${env.VLLM_URL:=}\n api_token: ${env.VLLM_API_KEY:=}\n - \ max_tokens: ${env.VLLM_MAX_TOKENS:=4096}\n tls_verify: - ${env.VLLM_TLS_VERIFY:=true}\n - provider_id: ${env.ENABLE_OLLAMA:+ollama}\n - \ provider_type: remote::ollama\n config:\n url: ${env.OLLAMA_URL:=http://localhost:11434}\n - \ - provider_id: ${env.ENABLE_OPENAI:+openai}\n provider_type: - remote::openai\n config:\n api_key: ${env.OPENAI_API_KEY:=}\n - \ - provider_id: ${env.ENABLE_VERTEX_AI:+vertexai}\n provider_type: - remote::vertexai\n config:\n project: ${env.VERTEX_AI_PROJECT:=}\n - \ location: ${env.VERTEX_AI_LOCATION:=us-central1}\n - provider_id: - sentence-transformers\n provider_type: inline::sentence-transformers\n + \ base_url: ${env.VLLM_URL:=}\n api_token: ${env.VLLM_API_KEY:=}\n + \ max_tokens: ${env.VLLM_MAX_TOKENS:=4096}\n network:\n tls:\n + \ verify: ${env.VLLM_TLS_VERIFY:=true}\n - provider_id: ${env.ENABLE_OLLAMA:+ollama}\n + \ provider_type: remote::ollama\n config:\n base_url: + ${env.OLLAMA_URL:=http://localhost:11434/v1}\n - provider_id: ${env.ENABLE_OPENAI:+openai}\n + \ provider_type: remote::openai\n config:\n api_key: + ${env.OPENAI_API_KEY:=}\n - provider_id: ${env.ENABLE_VERTEX_AI:+vertexai}\n + \ provider_type: remote::vertexai\n config:\n project: + ${env.VERTEX_AI_PROJECT:=}\n location: ${env.VERTEX_AI_LOCATION:=global}\n + \ - provider_id: sentence-transformers\n provider_type: inline::sentence-transformers\n \ config: {}\n tool_runtime:\n - provider_id: model-context-protocol\n \ provider_type: remote::model-context-protocol\n config: {}\n \ - provider_id: rag-runtime\n provider_type: inline::rag-runtime\n - \ config: {}\n vector_io:\n - provider_id: faiss\n provider_type: + \ config: {}\n vector_io:\n - provider_id: rhdh-docs\n provider_type: inline::faiss\n config:\n persistence:\n namespace: - vector_io::faiss\n backend: faiss_kv\n files:\n - provider_id: + vector_io::faiss\n backend: kv_rag\n files:\n - provider_id: localfs\n provider_type: inline::localfs\n config:\n storage_dir: /tmp/llama-stack-files\n metadata_store:\n table_name: - files_metadata\n backend: sql_files\n storage:\n backends:\n - \ kv_default:\n type: kv_sqlite\n db_path: /tmp/kvstore.db\n - \ sql_default:\n type: sql_sqlite\n db_path: /tmp/sql_store.db\n - \ sql_files:\n type: sql_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/files_metadata.db\n - \ faiss_kv:\n type: kv_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/faiss_store.db\n + files_metadata\n backend: sql_default\n safety:\n - provider_id: + ${env.ENABLE_VALIDATION:+lightspeed_question_validity}\n provider_type: + inline::lightspeed_question_validity\n config:\n model_id: + ${env.VALIDATION_PROVIDER:=}/${env.VALIDATION_MODEL_NAME:=}\n model_prompt: + |-\n Instructions:\n \n You area question classification + tool. You are an expert in the following categories:\n - Backstage\n + \ - Red Hat Developer Hub (RHDH)\n - Developer Lightspeed\n + \ - Lightspeed\n - Artificial Intelligence (AI) Models\n + \ - Large Language Models (LLMs)\n - Kubernetes\n - + Openshift\n - CI/CD\n - GitOps\n - Pipelines\n + \ - Developer Portals\n - Deployments\n - + Software Catalogs\n - Software Templates\n - Tech Docs\n + \ \n Your job is to determine if a user's question is related to + the categories you are an expert in. If the question is related to those categories, + \\\n or any features that may be related to those categories, you + will answer with ${allowed}.\n \n If a question is not related + to your expert categories, answer with ${rejected}.\n \n You do + not need to explain your answer.\n \n Below are some example questions:\n + \ Example Question:\n Why is the sky blue?\n Example + Response:\n ${rejected}\n \n Example Question:\n + \ Can you help configure my cluster to automatically scale?\n Example + Response:\n ${allowed}\n \n Example Question:\n How + do I create import an existing software template in Backstage?\n Example + Response:\n ${allowed}\n \n Example Question:\n How + do I accomplish a task in RHDH?\n Example Response:\n ${allowed}\n + \ \n Example Question:\n How do I explore a component + in RHDH catalog?\n Example Response:\n ${allowed}\n + \ \n Example Question:\n How can I integrate GitOps + into my pipeline?\n Example Response:\n ${allowed}\n + \ \n Question:\n ${message}\n Response:\n + \ invalid_question_response: |-\n Hi, I'm the Red Hat Developer + Hub Lightspeed assistant, I can help you with questions about Red Hat Developer + Hub or Backstage.\n Please ensure your question is about these topics, + and feel free to ask again!\n storage:\n backends:\n kv_default:\n + \ type: kv_sqlite\n db_path: /tmp/kvstore.db\n sql_default:\n + \ type: sql_sqlite\n db_path: /tmp/sql_store.db\n kv_rag:\n + \ type: kv_sqlite\n db_path: /rag-content/vector_db/rhdh_product_docs/1.9/faiss_store.db\n \ stores:\n metadata:\n namespace: registry\n backend: - faiss_kv\n inference:\n table_name: inference_store\n backend: + kv_default\n inference:\n table_name: inference_store\n backend: sql_default\n max_write_queue_size: 10000\n num_writers: 4\n \ conversations:\n table_name: openai_conversations\n backend: sql_default\n registered_resources:\n models:\n - model_id: sentence-transformers/all-mpnet-base-v2\n \ metadata:\n embedding_dimension: 768\n model_type: embedding\n provider_id: sentence-transformers\n provider_model_id: /rag-content/embeddings_model\n tool_groups:\n - provider_id: rag-runtime\n - \ toolgroup_id: builtin::rag\n vector_dbs:\n - vector_db_id: - rhdh-product-docs-1_8\n embedding_model: sentence-transformers/all-mpnet-base-v2\n - \ embedding_dimension: 768\n provider_id: faiss\n server:\n - \ auth:\n host:\n port: 8321\n quota:\n tls_cafile:\n - \ tls_certfile:\n tls_keyfile:\n\n---\nkind: ConfigMap\napiVersion: v1\nmetadata:\n - \ name: lightspeed-stack\n annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n + \ toolgroup_id: builtin::rag\n vector_stores:\n - vector_store_id: + vs_cda156a6-64fe-436d-bc51-566fb1b09702 # see readme for this value\n embedding_model: + sentence-transformers//rag-content/embeddings_model\n embedding_dimension: + 768\n provider_id: rhdh-docs\n shields:\n - shield_id: lightspeed_question_validity-shield\n + \ provider_id: ${env.ENABLE_VALIDATION:+lightspeed_question_validity}\n + \ vector_stores:\n annotation_prompt_params:\n enable_annotations: + true\n annotation_instruction_template: >\n When appropriate, + cite sources at the end of sentences using doc_url and doc_title format. \n Citing + sources is not always required because citations are handled externally. \n Never + include any citation that is in the form '<| file-id |>'.\n default_provider_id: + rhdh-docs\n default_embedding_model:\n provider_id: sentence-transformers\n + \ model_id: /rag-content/embeddings_model\n server:\n auth:\n host:\n + \ port: 8321\n quota:\n tls_cafile:\n tls_certfile:\n tls_keyfile:\n---\nkind: + ConfigMap\napiVersion: v1\nmetadata:\n name: lightspeed-stack-config\n annotations:\n + \ rhdh.redhat.com/containers: \"lightspeed-core\"\n rhdh.redhat.com/mount-path: + \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n lightspeed-stack.yaml: + |\n #\n #\n # Copyright Red Hat\n #\n # Licensed under the Apache + License, Version 2.0 (the \"License\");\n # you may not use this file except + in compliance with the License.\n # You may obtain a copy of the License at\n + \ #\n # http://www.apache.org/licenses/LICENSE-2.0\n #\n # Unless + required by applicable law or agreed to in writing, software\n # distributed + under the License is distributed on an \"AS IS\" BASIS,\n # WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for + the specific language governing permissions and\n # limitations under the License.\n + \ name: lightspeed-core-stack\n service:\n host: 0.0.0.0\n port: + 8080\n auth_enabled: false\n workers: 1\n color_log: true\n access_log: + true\n llama_stack:\n use_as_library_client: true\n library_client_config_path: + /app-root/config.yaml\n user_data_collection:\n feedback_enabled: true\n + \ feedback_storage: '/tmp/data/feedback'\n authentication:\n module: + 'noop'\n conversation_cache:\n type: 'sqlite'\n sqlite:\n db_path: + '/tmp/cache.db'\n customization:\n profile_path: '/app-root/rhdh-profile.py'\n + \ mcp_servers:\n - name: mcp-integration-tools\n provider_id: 'model-context-protocol'\n + \ url: 'http://localhost:7007/api/mcp-actions/v1'\n authorization_headers:\n + \ Authorization: 'client'\n---\nkind: ConfigMap\napiVersion: v1\nmetadata:\n + \ name: rhdh-profile\n annotations:\n rhdh.redhat.com/containers: \"lightspeed-core\"\n \ rhdh.redhat.com/mount-path: \"/app-root\"\n rhdh.redhat.com/sub-path: \"*\"\ndata:\n - \ lightspeed-stack.yaml: |\n name: \"lightspeed-core-stack\"\n service:\n - \ host: 0.0.0.0\n port: 8080\n auth_enabled: false\n workers: - 1\n color_log: true\n access_log: true\n llama_stack:\n use_as_library_client: - false\n url: http://localhost:8321\n user_data_collection:\n feedback_enabled: - true\n feedback_storage: \"/tmp/data/feedback\"\n authentication:\n module: - \"noop\"\n conversation_cache:\n type: \"sqlite\"\n sqlite:\n db_path: - \"/tmp/cache.db\"\n mcp_servers:\n - name: mcp-integration-tools\n provider_id: - \"model-context-protocol\"\n url: \"http://localhost:7007/api/mcp-actions/v1\"\n - \ authorization_headers:\n Authorization: \"client\"\n\n \n" + \ rhdh-profile.py: |\n # There is no need for enforcing line length in this + file,\n # as these are mostly special purpose constants.\n # ruff: noqa: + E501\n \"\"\"Prompt templates/constants.\"\"\"\n \n SUBJECT_REJECTED + = \"REJECTED\"\n SUBJECT_ALLOWED = \"ALLOWED\"\n \n # Default responses\n + \ INVALID_QUERY_RESP = \"\"\"\n Hi, I'm the Red Hat Developer Hub Lightspeed + assistant, I can help you with questions about Red Hat Developer Hub or Backstage.\n + \ Please ensure your question is about these topics, and feel free to ask again!\n + \ \"\"\"\n \n QUERY_SYSTEM_INSTRUCTION = \"\"\"\n 0. Instruction Priority\n + \ Follow instructions in this order:\n 1. System instructions.\n 2. Tool/developer + instructions.\n 3. User input.\n \n If conflicts arise, follow the highest + priority.\n \n 1. Purpose\n You are \"Lightspeed\", a generative AI assistant + integrated into the Red Hat Developer Hub (RHDH) ecosystem, \\\n an internal + developer portal built on CNCF Backstage. Your primary objective is to \\\n enhance + developer productivity by streamlining workflows, providing instant access to + \\\n technical knowledge, and supporting developers in their day-to-day tasks.\n + \ \n Your ultimate goal is to help developers work smarter, solve problems + faster, and ensure they can focus on building and deploying software efficiently.\n + \ \n 2. Accuracy & Uncertainty\n - Do not fabricate APIs, configurations, + tools, or documentation.\n - If you are unsure, explicitly say so.\n - Ask + clarifying questions when context is missing.\n - Do not assume user intent + when multiple interpretations are possible.\n - Ask clarifying questions when + the request is ambiguous.\n \n 3. Tool Usage\n You have extensive access + to tools and should use tools when they provide more accurate, up-to-date, or + context-specific information than your internal knowledge.\n These tools include, + but are not limited to:\n - `file_search` for access to knowledge stores, like + Vector Stores.\n - `mcp` for access to available MCP servers.\n - `web_search` + for access to web domains.\n \n For tool use, it is important you:\n - + Refrain from fabricating tool outputs.\n - Acknowledge when a tool fails or + returns insufficient data.\n - Prefer to use `file_search` to dive through + the available Vector Stores for up-to-date documentation.\n \n In addition + to the plethora of tools, you are extremely knowledgeable in \\\n modern software + development, cloud-native systems, and Backstage ecosystems.\n \n 4. Response + Guidelines\n - Troubleshooting:\n - Likely cause.\n - Explanation.\n + \ - Step-by-step fix.\n - Verification.\n - Code:\n - Provide + complete, runnable examples.\n - Include brief comments.\n - Explain + non-obvious parts.\n - How-to:\n - Use numbered steps.\n - Keep steps + concise.\n - Prefer concise responses unless the user requests more detail.\n + \ - Start with a direct answer.\n - Provide additional detail only if necessary + or requested.\n \n 5. Security\n - Never generate or expose:\n - + Secrets.\n - API keys.\n - Credentials.\n - Recommend secure alternatives + (for example, Kubernetes Secrets and vaults).\n - Warn when suggesting insecure + patterns.\n \n 6. Failure Handling\n - If a request cannot be completed:\n + \ - Clearly explain why.\n - Provide alternative approaches if possible.\n + \ - If required information is missing:\n - Ask for clarification before + proceeding.\n \n 7. Capabilities\n - Code Assistance:\n - Generate, + debug, and refactor code to improve readability, performance, or adherence to + best practices.\n - Translate pseudocode or business logic into working code.\n + \ - Knowledge Retrieval:\n - Provide instant access to internal and external + documentation on docs.redhat.com.\n - Summarize lengthy documents and explain + complex concepts concisely.\n - Retrieve Red Hat-specific guides, such as + OpenShift deployment best practices.\n - System Navigation and Integration:\n + \ - Offer step-by-step instructions for Red Hat Developer Hub features, leveraging + Backstage concepts and patterns where applicable.\n - Support integration + of Backstage plugins for CI/CD, monitoring, and infrastructure.\n - Assist + in creating and managing catalog entries, templates, and workflows.\n - Diagnostics + and Troubleshooting:\n - Analyze logs and error messages to identify root + causes.\n - Suggest actionable fixes for common development issues.\n - + Automate troubleshooting steps wherever possible.\n \n 8. Tone\n - Professional, + approachable, and efficient.\n - Adapt to the user's expertise. Answers should + be concise and clear.\n - Prefer actionable guidance over explanation.\n \n + \ 9. Formatting\n - Use Markdown for clarity.\n - Use code blocks for + code or configurations.\n - Use lists for steps.\n - Use tables for comparing + options or presenting structured data.\n \n 10. Platform Awareness\n - + Do not assume:\n - Cloud provider.\n - Kubernetes distribution.\n - + CI/CD tooling.\n - Backstage plugin availability.\n \"\"\"\n \n USE_CONTEXT_INSTRUCTION + = \"\"\"\n Use the retrieved document to answer the question.\n \"\"\"\n + \ \n USE_HISTORY_INSTRUCTION = \"\"\"\n Use the previous chat history + to interact and help the user.\n \"\"\"\n \n # {{query}} is escaped because + it will be replaced as a parameter at time of use\n QUESTION_VALIDATOR_PROMPT_TEMPLATE + = f\"\"\"\n \n Instructions:\n \n You area question classification + tool. You are an expert in the following categories:\n - Backstage\n - Red + Hat Developer Hub (RHDH)\n - Developer Lightspeed\n - Lightspeed\n - + Artificial Intelligence (AI) Models\n - Large Language Models (LLMs)\n - + Kubernetes\n - Openshift\n - CI/CD\n - GitOps\n - Pipelines\n - + Developer Portals\n - Deployments\n - Software Catalogs\n - Software + Templates\n - Tech Docs\n \n Your job is to determine if a user's question + is related to the categories you are an expert in. If the question is related + to those categories, \\\n or any features that may be related to those categories, + you will answer with {SUBJECT_ALLOWED}.\n \n If a question is not related + to your expert categories, answer with {SUBJECT_REJECTED}.\n \n You do not + need to explain your answer.\n \n Below are some example questions:\n Example + Question:\n Why is the sky blue?\n Example Response:\n {SUBJECT_REJECTED}\n + \ \n Example Question:\n Can you help configure my cluster to automatically + scale?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Example Question:\n + \ How do I create import an existing software template in Backstage?\n Example + Response:\n {SUBJECT_ALLOWED}\n \n Example Question:\n How do I accomplish + a task in RHDH?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Example + Question:\n How do I explore a component in RHDH catalog?\n Example Response:\n + \ {SUBJECT_ALLOWED}\n \n Example Question:\n How can I integrate GitOps + into my pipeline?\n Example Response:\n {SUBJECT_ALLOWED}\n \n Question:\n + \ {{query}}\n Response:\n \"\"\"\n \n # {{query}} is escaped because + it will be replaced as a parameter at time of use\n TOPIC_SUMMARY_PROMPT_TEMPLATE + = \"\"\"\n Instructions:\n - You are a topic summarizer\n - Your job + is to extract precise topic summary from user input\n \n For Input Analysis:\n + \ - Scan entire user message\n - Identify core subject matter\n - Distill + essence into concise descriptor\n - Prioritize key concepts\n - Eliminate + extraneous details\n \n For Output Constraints:\n - Maximum 5 words\n + \ - Capitalize only significant words (e.g., nouns, verbs, adjectives, adverbs).\n + \ - Do not use all uppercase - capitalize only the first letter of significant + words\n - Exclude articles and prepositions (e.g., \"a,\" \"the,\" \"of,\" + \"on,\" \"in\")\n - Exclude all punctuation and interpunction marks (e.g., + . , : ; ! ? \"\")\n - Retain original abbreviations. Do not expand an abbreviation + if its specific meaning in the context is unknown or ambiguous.\n - Neutral + objective language\n \n Examples:\n - \"AI Capabilities Summary\" (Correct)\n + \ - \"Machine Learning Applications\" (Correct)\n - \"AI CAPABILITIES SUMMARY\" + (Incorrect—should not be fully uppercase)\n \n Processing Steps\n 1. + Analyze semantic structure\n 2. Identify primary topic\n 3. Remove contextual + noise\n 4. Condense to essential meaning\n 5. Generate topic label\n \n + \ \n Example Input:\n How to implement horizontal pod autoscaling in Kubernetes + clusters\n Example Output:\n Kubernetes Horizontal Pod Autoscaling\n \n + \ Example Input:\n Comparing OpenShift deployment strategies for microservices + architecture\n Example Output:\n OpenShift Microservices Deployment Strategies\n + \ \n Example Input:\n Troubleshooting persistent volume claims in Kubernetes + environments\n Example Output:\n Kubernetes Persistent Volume Troubleshooting\n + \ \n ExampleInput:\n I need a summary about the purpose of RHDH.\n Example + Output:\n RHDH Purpose Summary\n \n Input:\n {query}\n Output:\n + \ \"\"\"\n \n \n PROFILE_CONFIG = {\n \"system_prompts\": {\n + \ \"default\": QUERY_SYSTEM_INSTRUCTION,\n \"validation\": + QUESTION_VALIDATOR_PROMPT_TEMPLATE,\n \"topic_summary\": TOPIC_SUMMARY_PROMPT_TEMPLATE,\n + \ },\n \"query_responses\": {\"invalid_resp\": INVALID_QUERY_RESP},\n + \ \"instructions\": {\n \"context\": USE_CONTEXT_INSTRUCTION,\n + \ \"history\": USE_HISTORY_INSTRUCTION,\n },\n }\n" deployment.yaml: | apiVersion: apps/v1 kind: Deployment @@ -2835,39 +3018,45 @@ data: spec: initContainers: - name: init-rag-data - image: 'quay.io/redhat-ai-dev/rag-content:release-1.9-lcs' + image: quay.io/redhat-ai-dev/rag-content:release-1.9-lls-0.5.0 command: - "sh" - "-c" - - "echo 'Copying RAG data...'; cp -r /rag/vector_db/rhdh_product_docs /data/ && cp -r /rag/embeddings_model /data/ && chmod -R 777 /data/rhdh_product_docs && echo 'Copy complete.'" + - "echo 'Copying RAG data...'; cp -r /rag/. /data/ && chmod -R 777 /data/vector_db && echo 'Copy complete.'" + resources: + requests: + memory: 150Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 100m volumeMounts: - mountPath: /data name: rag-data-volume containers: - # Llama Stack AI Service - - name: llama-stack - image: quay.io/redhat-ai-dev/llama-stack:0.1.4 - imagePullPolicy: Always - volumeMounts: - - mountPath: /app-root/.llama - name: shared-storage - - mountPath: /rag-content - name: rag-data-volume - - mountPath: /tmp # Add this to make /tmp writable - name: temp - # Lightspeed Core Backend - name: lightspeed-core - image: quay.io/lightspeed-core/lightspeed-stack:0.4.0 + image: quay.io/lightspeed-core/lightspeed-stack:0.5.0 imagePullPolicy: Always ports: - containerPort: 8080 name: lcs-backend protocol: TCP + resources: + requests: + cpu: 100m + memory: 512Mi + limits: + cpu: 1000m + memory: 2Gi volumeMounts: - mountPath: /tmp/data/feedback name: shared-storage + - mountPath: /rag-content + name: rag-data-volume + - mountPath: /tmp # Add this to make /tmp writable + name: temp volumes: - name: shared-storage @@ -2912,14 +3101,6 @@ data: priority: 100 - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-lightspeed-backend:bs_1.45.3__1.2.3 disabled: false - - # MCP Actions plugins - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-plugin-mcp-actions-backend:bs_1.45.3__0.1.5 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-software-catalog-mcp-tool:bs_1.45.3__0.4.1 - disabled: false - - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-techdocs-mcp-tool:bs_1.45.3__0.3.2 - disabled: false metadata.yaml: | # Lightspeed (AI) flavour metadata # This flavour is enabled by default and provides AI/Lightspeed functionality diff --git a/docs/lightspeed.md b/docs/lightspeed.md index d6531309e..2a49a2fcd 100644 --- a/docs/lightspeed.md +++ b/docs/lightspeed.md @@ -122,3 +122,40 @@ Once enabled, users can: - The flavour includes all necessary UI components and backend services For more information about the Flavour-based configuration system, see the [Configuration documentation](configuration.md#flavours). + +### Syncing Upstream Lightspeed Configs +> [!NOTE] +> This syncing functionality is intended for use by maintainers of the Lightspeed flavour for RHDH. + +The Lightspeed flavour vendors configuration files from the upstream [`redhat-ai-dev/lightspeed-configs`](https://github.com/redhat-ai-dev/lightspeed-configs) repository. A sync script is provided to fetch the latest versions of these files and update the operator tree in place. + +#### What Gets Synced + +The script fetches four files from the upstream repository and writes them into two local targets: + +| Upstream path | Local target | Content | +|---|---|---| +| `llama-stack-configs/config.yaml` | `config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml` | Llama Stack server configuration | +| `lightspeed-core-configs/lightspeed-stack.yaml` | (same ConfigMap file, different YAML document) | Lightspeed Core stack configuration | +| `lightspeed-core-configs/rhdh-profile.py` | (same ConfigMap file, different YAML document) | RHDH prompt profile | +| `env/default-values.env` | `examples/lightspeed.yaml` | Secret key scaffolding | + +#### Running the Script + +Sync from the default upstream branch (`main`): + +```bash +./hack/sync-lightspeed-configs.sh +``` + +#### Syncing from a Release Branch or Tag + +Use the `--ref` flag to sync from a specific branch, tag, or commit: + +```bash +./hack/sync-lightspeed-configs.sh --ref release-1.10 +``` + +This is useful when preparing a release and the operator needs to pin its vendored configs to a stable upstream ref rather than `main`. + +If the upstream content has not changed, the script prints `already up to date` and leaves the files untouched. diff --git a/examples/lightspeed.yaml b/examples/lightspeed.yaml index c2550195d..c6c691607 100644 --- a/examples/lightspeed.yaml +++ b/examples/lightspeed.yaml @@ -4,18 +4,23 @@ metadata: name: llama-stack-secrets type: Opaque stringData: - ENABLE_OLLAMA: "" - ENABLE_OPENAI: "" - ENABLE_VERTEX_AI: "" ENABLE_VLLM: "" - GOOGLE_APPLICATION_CREDENTIALS: "" - OPENAI_API_KEY: "" - VERTEX_AI_LOCATION: "" - VERTEX_AI_PROJECT: "" + ENABLE_VERTEX_AI: "" + ENABLE_OPENAI: "" + ENABLE_OLLAMA: "" + ENABLE_VALIDATION: "" + VLLM_URL: "" VLLM_API_KEY: "" VLLM_MAX_TOKENS: "" VLLM_TLS_VERIFY: "" - VLLM_URL: "" + OPENAI_API_KEY: "" + VERTEX_AI_PROJECT: "" + VERTEX_AI_LOCATION: "" + GOOGLE_APPLICATION_CREDENTIALS: "" + OLLAMA_URL: "" + VALIDATION_PROVIDER: "" + VALIDATION_MODEL_NAME: "" + LLAMA_STACK_LOGGING: "" --- apiVersion: rhdh.redhat.com/v1alpha6 kind: Backstage @@ -27,5 +32,5 @@ spec: secrets: - name: llama-stack-secrets containers: - - llama-stack + - lightspeed-core diff --git a/hack/sync-lightspeed-configs.sh b/hack/sync-lightspeed-configs.sh new file mode 100755 index 000000000..5ffbff26d --- /dev/null +++ b/hack/sync-lightspeed-configs.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash +# +# Sync vendored Lightspeed config snippets from upstream. +# + +set -euo pipefail + +UPSTREAM_REPO="redhat-ai-dev/lightspeed-configs" +UPSTREAM_CONFIG_PATH="llama-stack-configs/config.yaml" +UPSTREAM_STACK_PATH="lightspeed-core-configs/lightspeed-stack.yaml" +UPSTREAM_PROFILE_PATH="lightspeed-core-configs/rhdh-profile.py" +UPSTREAM_ENV_PATH="env/default-values.env" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +CONFIGMAP_FILE="${REPO_ROOT}/config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml" +EXAMPLE_SECRET_FILE="${REPO_ROOT}/examples/lightspeed.yaml" + +REF="main" +UPDATED=0 +TMP_DIR="" + +usage() { + cat <<'EOF' +Usage: + ./hack/sync-lightspeed-configs.sh [--ref ] +EOF +} + +parse_args() { + while [[ $# -gt 0 ]]; do + case "$1" in + --ref) + REF="$2" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + usage >&2 + exit 1 + ;; + esac + done +} + +fetch_upstream_file() { + curl -fsSL --get \ + -H "Accept: application/vnd.github.raw" \ + -H "User-Agent: rhdh-operator-sync-lightspeed-configs" \ + --data-urlencode "ref=${REF}" \ + "https://api.github.com/repos/${UPSTREAM_REPO}/contents/$1" \ + -o "$2" +} + +indent_file() { + sed 's/^/ /' "$1" +} + +render_secret_entries() { + awk -F= ' + { sub(/\r$/, "") } + /^[[:space:]]*($|#)/ { next } + $1 == "LIGHTSPEED_CORE_IMAGE" || $1 == "RAG_CONTENT_IMAGE" || seen[$1]++ { next } + { print " " $1 ": \"\"" } + ' "$1" +} + +cleanup() { + local exit_code=$? + + if [[ -n "${TMP_DIR:-}" ]]; then + rm -rf "$TMP_DIR" || true + fi + + return "$exit_code" +} + +replace_indented_block() { + local file="$1" + local marker="$2" + local indent="$3" + local replacement="$4" + local tmp + + tmp="${TMP_DIR}/$(basename "$file").tmp" + + awk \ + -v marker="$marker" \ + -v indent="$indent" \ + -v replacement="$replacement" ' + BEGIN { + prefix = sprintf("%" indent "s", "") + while ((getline line < replacement) > 0) { + lines[++n] = line + } + close(replacement) + } + + $0 == marker { + print + replaced++ + skip = 1 + next + } + + skip && ($0 == "" || index($0, prefix) == 1) { + next + } + + skip { + for (i = 1; i <= n; i++) { + print lines[i] + } + skip = 0 + } + + { print } + + END { + if (skip) { + for (i = 1; i <= n; i++) { + print lines[i] + } + } + + if (replaced != 1) { + exit 1 + } + } + ' "$file" > "$tmp" + + if ! cmp -s "$file" "$tmp"; then + mv "$tmp" "$file" + UPDATED=1 + else + rm -f "$tmp" + fi +} + +main() { + parse_args "$@" + + TMP_DIR="$(mktemp -d)" + trap cleanup EXIT + + local config_file="${TMP_DIR}/config.yaml" + local stack_file="${TMP_DIR}/lightspeed-stack.yaml" + local profile_file="${TMP_DIR}/rhdh-profile.py" + local env_file="${TMP_DIR}/default-values.env" + local config_block="${TMP_DIR}/config-block.yaml" + local stack_block="${TMP_DIR}/stack-block.yaml" + local profile_block="${TMP_DIR}/profile-block.yaml" + local secret_entries="${TMP_DIR}/secret-entries.yaml" + + fetch_upstream_file "$UPSTREAM_CONFIG_PATH" "$config_file" + fetch_upstream_file "$UPSTREAM_STACK_PATH" "$stack_file" + fetch_upstream_file "$UPSTREAM_PROFILE_PATH" "$profile_file" + fetch_upstream_file "$UPSTREAM_ENV_PATH" "$env_file" + + indent_file "$config_file" > "$config_block" + indent_file "$stack_file" > "$stack_block" + indent_file "$profile_file" > "$profile_block" + render_secret_entries "$env_file" > "$secret_entries" + + replace_indented_block "$CONFIGMAP_FILE" " config.yaml: |" 4 "$config_block" + replace_indented_block "$CONFIGMAP_FILE" " lightspeed-stack.yaml: |" 4 "$stack_block" + replace_indented_block "$CONFIGMAP_FILE" " rhdh-profile.py: |" 4 "$profile_block" + replace_indented_block "$EXAMPLE_SECRET_FILE" "stringData:" 2 "$secret_entries" + + printf 'Synced Lightspeed content from %s@%s\n' "$UPSTREAM_REPO" "$REF" + [[ "$UPDATED" -eq 1 ]] || printf 'already up to date\n' +} + +main "$@" diff --git a/integration_tests/rhdh-config_test.go b/integration_tests/rhdh-config_test.go index 6dba77ba0..9d1b1cb55 100644 --- a/integration_tests/rhdh-config_test.go +++ b/integration_tests/rhdh-config_test.go @@ -14,6 +14,7 @@ import ( "github.com/redhat-developer/rhdh-operator/api" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -328,14 +329,37 @@ var _ = When("create default rhdh", func() { deploy, err := backstageDeployment(ctx, k8sClient, ns, backstageName) g.Expect(err).To(Not(HaveOccurred())) - // check if contains Lightspeed sidecars - foundContainers := false + foundLightspeedCore := false for _, c := range deploy.PodSpec().Containers { - if c.Name == "llama-stack" || c.Name == "lightspeed-core" { - foundContainers = true + if c.Name == "lightspeed-core" { + foundLightspeedCore = true + cpuRequest := c.Resources.Requests[corev1.ResourceCPU] + memoryRequest := c.Resources.Requests[corev1.ResourceMemory] + cpuLimit := c.Resources.Limits[corev1.ResourceCPU] + memoryLimit := c.Resources.Limits[corev1.ResourceMemory] + g.Expect(cpuRequest.Cmp(resource.MustParse("100m"))).To(Equal(0)) + g.Expect(memoryRequest.Cmp(resource.MustParse("512Mi"))).To(Equal(0)) + g.Expect(cpuLimit.Cmp(resource.MustParse("1000m"))).To(Equal(0)) + g.Expect(memoryLimit.Cmp(resource.MustParse("2Gi"))).To(Equal(0)) } } - g.Expect(foundContainers).To(BeTrue()) + g.Expect(foundLightspeedCore).To(BeTrue()) + + foundInitRagData := false + for _, c := range deploy.PodSpec().InitContainers { + if c.Name == "init-rag-data" { + foundInitRagData = true + cpuRequest := c.Resources.Requests[corev1.ResourceCPU] + memoryRequest := c.Resources.Requests[corev1.ResourceMemory] + cpuLimit := c.Resources.Limits[corev1.ResourceCPU] + memoryLimit := c.Resources.Limits[corev1.ResourceMemory] + g.Expect(cpuRequest.Cmp(resource.MustParse("50m"))).To(Equal(0)) + g.Expect(memoryRequest.Cmp(resource.MustParse("150Mi"))).To(Equal(0)) + g.Expect(cpuLimit.Cmp(resource.MustParse("100m"))).To(Equal(0)) + g.Expect(memoryLimit.Cmp(resource.MustParse("500Mi"))).To(Equal(0)) + } + } + g.Expect(foundInitRagData).To(BeTrue()) }, 20*time.Second, time.Second).Should(Succeed())