Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ src/
│   │   └── redaction/ # PII redaction capability for Pydantic AI agents
│   │   ├── capability.py # Pydantic AI capability for PII redaction of model messages
│   │   └── core.py # Core redaction logic for PII detection and replacement
│   └── llamastack/ # Pydantic AI provider for OGX
│   └── ogx/ # Pydantic AI provider for OGX
│   ├── _model.py # Custom OpenAI Responses model that works around OGX streaming quirks
│   ├── _provider.py # OGX provider implementation for Pydantic AI
│   └── _transport.py # httpx transport that routes OpenAI-compatible requests through an OGX library client
Expand All @@ -224,7 +224,7 @@ src/
│   ├── degraded_mode.py # Degraded mode state tracking
│   ├── endpoints.py # Utility functions for endpoint handlers
│   ├── json_schema_updater.py # Function to transform a JSON Schema-like dictionary into an OpenAPI-compatible schema
│   ├── llama_stack_version.py # Check if the OGX version is supported by the LCS
│   ├── ogx_version.py # Check if the OGX version is supported by the LCS
│   ├── markdown_repair.py # Utilities for repairing truncated markdown content
│   ├── mcp_auth_headers.py # Utilities for resolving MCP server authorization headers
│   ├── mcp_headers.py # MCP headers handling
Expand All @@ -250,7 +250,7 @@ src/
│   └── vector_search.py # Vector search utilities for query endpoints
├── sentry.py # Sentry error tracking initialization and configuration
├── lightspeed_stack.py # Entry point to the Lightspeed Core Stack REST API service
├── llama_stack_configuration.py # OGX configuration enrichment and synthesis
├── ogx_configuration.py # OGX configuration enrichment and synthesis
├── log.py # Log utilities
├── client.py # OGX client wrapper (Singleton)
├── configuration.py # Config management (Singleton)
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ build-ogx-image: remove-ogx-container ## Build OGX container image
echo "ERROR: No container runtime found. Install podman or docker."; \
exit 1; \
fi
$(CONTAINER_RUNTIME) build -f deploy/llama-stack/test.containerfile -t $(OGX_IMAGE) .
$(CONTAINER_RUNTIME) build -f deploy/ogx/test.containerfile -t $(OGX_IMAGE) .

stop-ogx-container: ## Gracefully stop OGX container
@if [ -n "$(CONTAINER_RUNTIME)" ] && $(CONTAINER_RUNTIME) inspect $(OGX_CONTAINER_NAME) >/dev/null 2>&1; then \
Expand Down Expand Up @@ -84,8 +84,8 @@ start-ogx-container: build-ogx-image ## Start OGX container
--health-start-period 20s \
-v $(PWD)/$(OGX_CONFIG):/opt/app-root/run.yaml:z \
-v $(PWD)/$(CONFIG):/opt/app-root/lightspeed-stack.yaml:ro,z \
-v $(PWD)/scripts/llama-stack-entrypoint.sh:/opt/app-root/enrich-entrypoint.sh:ro,z \
-v $(PWD)/src/llama_stack_configuration.py:/opt/app-root/llama_stack_configuration.py:ro,z \
-v $(PWD)/scripts/ogx-entrypoint.sh:/opt/app-root/enrich-entrypoint.sh:ro,z \
-v $(PWD)/src/ogx_configuration.py:/opt/app-root/ogx_configuration.py:ro,z \
-e OPENAI_API_KEY \
-e BRAVE_SEARCH_API_KEY \
-e TAVILY_SEARCH_API_KEY \
Expand Down Expand Up @@ -143,7 +143,7 @@ clean-ogx: remove-ogx-container ## Remove container and image
fi

run-ogx-local: ## Start OGX with enriched config (for local service mode)
uv run src/llama_stack_configuration.py -c $(CONFIG) -i $(OGX_CONFIG) -o $(OGX_CONFIG) && \
uv run src/ogx_configuration.py -c $(CONFIG) -i $(OGX_CONFIG) -o $(OGX_CONFIG) && \
uv run ogx stack run $(OGX_CONFIG)

test-unit: ## Run the unit tests
Expand Down
8 changes: 4 additions & 4 deletions deploy/llama-stack/README.md → deploy/ogx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
Llama Stack distribution itself, the image bundles the pieces needed to
generate its run configuration at container start:

- `/opt/app-root/llama_stack_configuration.py` — the config-generation
script (copied from `src/llama_stack_configuration.py`).
- `/opt/app-root/ogx_configuration.py` — the config-generation
script (copied from `src/ogx_configuration.py`).
- `/opt/app-root/data/default_run.yaml` — the shipped default baseline
(copied from `src/data/`), resolved by the script as `./data/` relative
to its own location.
- `/opt/app-root/enrich-entrypoint.sh` — the entrypoint (copied from
`scripts/llama-stack-entrypoint.sh`).
`scripts/ogx-entrypoint.sh`).

## Startup modes

Expand All @@ -36,7 +36,7 @@ services:
llama-stack:
build:
context: .
dockerfile: deploy/llama-stack/test.containerfile
dockerfile: deploy/ogx/test.containerfile
ports:
- "8321:8321"
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ RUN mkdir -p /opt/app-root/src/.llama/storage \
# Copy the config-generation script for runtime synthesis (unified mode) or
# enrichment (legacy mode), plus the shipped default baseline it resolves as
# ./data/default_run.yaml relative to its own location (load_default_baseline)
COPY src/llama_stack_configuration.py /opt/app-root/llama_stack_configuration.py
COPY src/ogx_configuration.py /opt/app-root/ogx_configuration.py
COPY src/data /opt/app-root/data
COPY scripts/llama-stack-entrypoint.sh /opt/app-root/enrich-entrypoint.sh
COPY scripts/ogx-entrypoint.sh /opt/app-root/enrich-entrypoint.sh
RUN chmod +x /opt/app-root/enrich-entrypoint.sh && \
chown -R 1001:0 /opt/app-root/enrich-entrypoint.sh \
/opt/app-root/llama_stack_configuration.py /opt/app-root/data
/opt/app-root/ogx_configuration.py /opt/app-root/data

# Switch back to the original user
USER 1001
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
llama-stack:
build:
context: .
dockerfile: deploy/llama-stack/test.containerfile
dockerfile: deploy/ogx/test.containerfile
platform: linux/amd64
container_name: llama-stack
ports:
Expand All @@ -18,8 +18,8 @@ services:
# from lightspeed-stack.yaml and this mount is ignored
- ./run.yaml:/opt/app-root/run.yaml:z
# Host copies so `docker compose up` picks up script changes without rebuilding OGX
- ./scripts/llama-stack-entrypoint.sh:/opt/app-root/enrich-entrypoint.sh:ro,z
- ./src/llama_stack_configuration.py:/opt/app-root/llama_stack_configuration.py:ro,z
- ./scripts/ogx-entrypoint.sh:/opt/app-root/enrich-entrypoint.sh:ro,z
- ./src/ogx_configuration.py:/opt/app-root/ogx_configuration.py:ro,z
- ./src/data:/opt/app-root/data:ro,z
- ${GCP_KEYS_PATH:-./tmp/.gcp-keys-dummy}:/opt/app-root/.gcp-keys:ro
- ./lightspeed-stack.yaml:/opt/app-root/lightspeed-stack.yaml:ro,z
Expand Down
20 changes: 10 additions & 10 deletions docs/devel_doc/container_orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ When you run `make run`, the following happens:
make build-llama-stack-image
```

- Builds from `deploy/llama-stack/test.containerfile`
- Builds from `deploy/ogx/test.containerfile`
- Tags as `lightspeed-llama-stack:local` (customizable via `LLAMA_STACK_IMAGE`)
- Only rebuilds if the image doesn't exist or source files changed
- Removes any existing container before building (ensures clean build)
Expand Down Expand Up @@ -459,7 +459,7 @@ Container logs:
3. **Test config enrichment:**
```bash
# Run enrichment script manually to check for errors
uv run src/llama_stack_configuration.py \
uv run src/ogx_configuration.py \
-c lightspeed-stack.yaml \
-i run.yaml \
-o /tmp/enriched-run.yaml
Expand Down Expand Up @@ -649,7 +649,7 @@ This grants read-only access to UID 1001 (container user) without changing base
**macOS note:** macOS uses BSD ACLs and cannot assign numeric UID-based ACLs to non-existent host users. If you are testing locally on macOS, you must temporarily use `chmod 644` to allow the container access, but **be aware that this makes the credentials file world-readable on your host machine.** Alternately, ensure your local user matches the container's execution environment.

**Why this happens:**
This is expected container behavior. The container runs as a non-root user (UID 1001) for security - see `USER 1001` in `deploy/llama-stack/test.containerfile`. Files with `600` permissions are only accessible to their owner, and the container's UID differs from your host UID.
This is expected container behavior. The container runs as a non-root user (UID 1001) for security - see `USER 1001` in `deploy/ogx/test.containerfile`. Files with `600` permissions are only accessible to their owner, and the container's UID differs from your host UID.

**Production recommendation:**
For production deployments, avoid mounting credential files entirely. Instead use:
Expand Down Expand Up @@ -683,9 +683,9 @@ When the OGX container starts, it automatically enriches the `run.yaml` file wit

#### How It Works

1. **Entrypoint script** (`scripts/llama-stack-entrypoint.sh`) is mounted at `/opt/app-root/enrich-entrypoint.sh`
2. **Script runs** `/opt/app-root/.venv/bin/python3 /opt/app-root/llama_stack_configuration.py`
3. **Enrichment logic** (`src/llama_stack_configuration.py`) reads both configs and merges them
1. **Entrypoint script** (`scripts/ogx-entrypoint.sh`) is mounted at `/opt/app-root/enrich-entrypoint.sh`
2. **Script runs** `/opt/app-root/.venv/bin/python3 /opt/app-root/ogx_configuration.py`
3. **Enrichment logic** (`src/ogx_configuration.py`) reads both configs and merges them
4. **Output** is written to `/tmp/enriched-run.yaml` inside the container
5. **OGX starts** with the enriched config

Expand All @@ -699,7 +699,7 @@ When the OGX container starts, it automatically enriches the `run.yaml` file wit

```bash
# Run enrichment locally to see output
uv run src/llama_stack_configuration.py \
uv run src/ogx_configuration.py \
-c lightspeed-stack.yaml \
-i run.yaml \
-o enriched-run.yaml
Expand All @@ -716,8 +716,8 @@ The container uses these volume mounts:
|-----------|----------------|------|---------|
| `$(PWD)/run.yaml` | `/opt/app-root/run.yaml` | rw | OGX config (enriched version written here) |
| `$(PWD)/lightspeed-stack.yaml` | `/opt/app-root/lightspeed-stack.yaml` | ro | LCORE config (read for enrichment) |
| `$(PWD)/scripts/llama-stack-entrypoint.sh` | `/opt/app-root/enrich-entrypoint.sh` | ro | Entrypoint script with enrichment logic |
| `$(PWD)/src/llama_stack_configuration.py` | `/opt/app-root/llama_stack_configuration.py` | ro | Python enrichment script |
| `$(PWD)/scripts/ogx-entrypoint.sh` | `/opt/app-root/enrich-entrypoint.sh` | ro | Entrypoint script with enrichment logic |
| `$(PWD)/src/ogx_configuration.py` | `/opt/app-root/ogx_configuration.py` | ro | Python enrichment script |

**SELinux labels:**
- `:z`: Relabels for sharing between host and container (read-write)
Expand All @@ -734,7 +734,7 @@ If you need more control than the Makefile provides, you can manage the containe

#### Build the Image
```bash
podman build -f deploy/llama-stack/test.containerfile -t my-llama-stack:custom .
podman build -f deploy/ogx/test.containerfile -t my-llama-stack:custom .
```

#### Run the Container
Expand Down
2 changes: 1 addition & 1 deletion docs/user_doc/deployment_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ and `library_client_config_path` must not be set (unified and legacy inputs
are mutually exclusive).

The reference profiles are sanity-checked by the unit suite
(`tests/unit/test_llama_stack_synthesize.py`), so they stay loadable as the
(`tests/unit/test_ogx_synthesize.py`), so they stay loadable as the
synthesizer evolves.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Entrypoint for OGX container.
#
# Generates the run configuration from the mounted lightspeed-stack.yaml and
# starts OGX. The Python CLI (llama_stack_configuration.py) auto-detects the
# starts OGX. The Python CLI (ogx_configuration.py) auto-detects the
# configuration shape:
# - unified mode: the lightspeed config carries a synthesis input (a
# non-empty inference.providers or vector_store.providers, or a
Expand All @@ -23,7 +23,7 @@ LIGHTSPEED_CONFIG="${LIGHTSPEED_CONFIG:-/opt/app-root/lightspeed-stack.yaml}"
if [ -f "$LIGHTSPEED_CONFIG" ]; then
echo "Generating llama-stack config from $LIGHTSPEED_CONFIG (mode auto-detected)..."
GENERATION_FAILED=0
/opt/app-root/.venv/bin/python3 /opt/app-root/llama_stack_configuration.py \
/opt/app-root/.venv/bin/python3 /opt/app-root/ogx_configuration.py \
-c "$LIGHTSPEED_CONFIG" \
-i "$INPUT_CONFIG" \
-o "$GENERATED_CONFIG" 2>&1 || GENERATION_FAILED=1
Expand Down
6 changes: 3 additions & 3 deletions scripts/llama_stack_tutorial.sh → scripts/ogx_tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ Next Steps:
4. Experiment with different models and tools

Resources:
- This tutorial script: ./llama_stack_tutorial.sh
- Run without pauses: ./llama_stack_tutorial.sh --no-wait
- Python version: ./llama_stack_tutorial.py (requires: uv run python3)
- This tutorial script: ./ogx_tutorial.sh
- Run without pauses: ./ogx_tutorial.sh --no-wait
- Python version: ./ogx_tutorial.py (requires: uv run python3)
- Interactive docs: http://localhost:8321/docs

Happy exploring! 🚀
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Constants used in business logic.

Entry point to the Lightspeed Core Stack REST API service.

## [llama_stack_configuration.py](llama_stack_configuration.py)
## [ogx_configuration.py](ogx_configuration.py)

OGX configuration enrichment and synthesis.

Expand Down
2 changes: 1 addition & 1 deletion src/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from models.api.responses.error import InternalServerErrorResponse
from observability.sentry import initialize_sentry
from utils.degraded_mode import DegradedModeTracker
from utils.llama_stack_version import check_ogx_version
from utils.ogx_version import check_ogx_version

logger = get_logger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions src/client/ogx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
import constants
from authorization.azure_token_manager import AzureEntraIDManager
from configuration import configuration
from llama_stack_configuration import (
from log import get_logger, setup_logging
from models.api.responses.error import ServiceUnavailableResponse
from models.config import OgxConfiguration
from ogx_configuration import (
YamlDumper,
enrich_azure_entra_id_inference,
enrich_byok_rag,
enrich_solr,
synthesize_to_file,
)
from log import get_logger, setup_logging
from models.api.responses.error import ServiceUnavailableResponse
from models.config import OgxConfiguration
from utils.model_list import parse_model_list_response
from utils.types import Singleton

Expand Down
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
CACHE_TYPE_NOOP: Final[str] = "noop"

# BYOK RAG
# Backends that have enrichment support in llama_stack_configuration.py
# Backends that have enrichment support in ogx_configuration.py
SUPPORTED_RAG_BACKENDS: Final[frozenset[str]] = frozenset({"faiss", "pgvector"})

# Default RAG backend for bring-your-own-knowledge RAG configurations
Expand Down
2 changes: 1 addition & 1 deletion src/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Currently holds ``default_run.yaml``, the built-in baseline OGX
configuration used by unified-mode synthesis (see
``llama_stack_configuration.load_default_baseline``). Making this directory a
``ogx_configuration.load_default_baseline``). Making this directory a
package ensures the data file is included in built wheels and resolvable both
in editable installs and from site-packages.
"""
2 changes: 1 addition & 1 deletion src/data/default_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is the starting point when a unified `lightspeed-stack.yaml`
# selects `llama_stack.config.baseline: default` (the default) and does not
# point at a `profile:`. The synthesizer (src/llama_stack_configuration.py)
# point at a `profile:`. The synthesizer (src/ogx_configuration.py)
# layers enrichment, high-level `inference.providers`, and `native_override`
# on top of this baseline to produce the final run.yaml handed to OGX.
#
Expand Down
2 changes: 1 addition & 1 deletion src/lightspeed_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import constants
from configuration import configuration
from constants import LIGHTSPEED_STACK_LOG_LEVEL_ENV_VAR
from llama_stack_configuration import migrate_config_dumb
from log import get_logger, setup_logging
from ogx_configuration import migrate_config_dumb
from runners.quota_scheduler import start_quota_scheduler
from runners.uvicorn import start_uvicorn
from utils.dumpers import config_dumper, models_dumper
Expand Down
4 changes: 2 additions & 2 deletions src/llama_stack_configuration.py → src/ogx_configuration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""OGX configuration enrichment and synthesis.

This module can be used in two ways:
1. As a script: `python llama_stack_configuration.py -c config.yaml`
2. As a module: `from llama_stack_configuration import generate_configuration`
1. As a script: `python ogx_configuration.py -c config.yaml`
2. As a module: `from ogx_configuration import generate_configuration`

Two related responsibilities live here:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
QuestionValidityConfig,
)
from pydantic_ai_lightspeed.capabilities.base import AbstractSafetyCapability
from pydantic_ai_lightspeed.llamastack import OgxResponsesModel
from pydantic_ai_lightspeed.ogx import OgxResponsesModel
from utils.conversations import append_turn_to_conversation

logger = get_logger(__name__)
Expand Down
6 changes: 0 additions & 6 deletions src/pydantic_ai_lightspeed/llamastack/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List of source files stored in `src/pydantic_ai_lightspeed/llamastack` directory
# List of source files stored in `src/pydantic_ai_lightspeed/ogx` directory

## [__init__.py](__init__.py)

Expand Down
6 changes: 6 additions & 0 deletions src/pydantic_ai_lightspeed/ogx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Pydantic AI provider for OGX."""

from pydantic_ai_lightspeed.ogx._model import OgxResponsesModel
from pydantic_ai_lightspeed.ogx._provider import OgxProvider

__all__ = ["OgxProvider", "OgxResponsesModel"]
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

from log import get_logger
from models.common.responses.responses_api_params import ResponsesApiParams
from pydantic_ai_lightspeed.llamastack._provider import OgxProvider
from pydantic_ai_lightspeed.ogx._provider import OgxProvider

logger = get_logger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pydantic_ai.profiles.openai import openai_model_profile
from pydantic_ai.providers import Provider

from pydantic_ai_lightspeed.llamastack._transport import (
from pydantic_ai_lightspeed.ogx._transport import (
OgxLibraryTransport,
wrap_http_client_with_provider_data,
)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Input sanitization to detect and block obfuscated prompt injection attempts.

Function to transform a JSON Schema-like dictionary into an OpenAPI-compatible schema.

## [llama_stack_version.py](llama_stack_version.py)
## [ogx_version.py](ogx_version.py)

Check if the OGX version is supported by the LCS.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/pydantic_ai_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from pydantic_ai_lightspeed.capabilities import QuestionValidity
from pydantic_ai_lightspeed.capabilities.redaction import PiiRedactionCapability
from pydantic_ai_lightspeed.llamastack import OgxResponsesModel
from pydantic_ai_lightspeed.ogx import OgxResponsesModel
from utils.shields import get_shields_for_request

_AGENT_SKILLS_PROVIDER_ID: Final[str] = "agent-skills"
Expand Down
Loading
Loading