Skip to content
16 changes: 8 additions & 8 deletions src/ogx/core/routers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ async def get_auto_router_impl(
# TODO: move pass configs to routers instead
if api == Api.inference:
inference_ref = run_config.storage.stores.inference
if not inference_ref:
if inference_ref is None:
raise ValueError("storage.stores.inference must be configured in run config")

inference_store = InferenceStore(
reference=inference_ref,
policy=policy,
)
await inference_store.initialize()
api_to_dep_impl["store"] = inference_store
if inference_ref.enabled:
inference_store = InferenceStore(
reference=inference_ref,
policy=policy,
)
await inference_store.initialize()
api_to_dep_impl["store"] = inference_store
elif api == Api.vector_io:
api_to_dep_impl["vector_stores_config"] = run_config.vector_stores
api_to_dep_impl["inference_api"] = deps.get(Api.inference)
Expand Down
15 changes: 15 additions & 0 deletions src/ogx/core/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ The tenancy mode is set process-wide during startup via `set_default_tenancy_mod
Storage is configured in `StackConfig.storage` via `StorageConfig`. The `stores` field contains typed references (`KVStoreReference`, `SqlStoreReference`, `InferenceStoreReference`) that point to specific backend configurations.

See `datatypes.py` for all config types and `StorageBackendType` for the enum of supported backends.

### Inference Store (enabled flag)

Setting `inference.enabled: false` on the inference store reference explicitly
disables Chat Completions persistence. Omitting the flag (or the whole
reference) keeps the store enabled for backward compatibility, and setting the
reference itself to `null` remains a configuration error.

When disabled, no `InferenceStore` is constructed, no `inference_store` table is
created, and no background write workers run. Streaming and non-streaming Chat
Completions continue to work. The history endpoints (`list`, `retrieve`, and
`messages`) report that persistence is not configured (HTTP 501).

Other stores (`responses`, `datasets`, `eval`, `files`, `prompts`, `vector_io`)
are unaffected by disabling the inference store.
17 changes: 14 additions & 3 deletions src/ogx/core/storage/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ class KVStoreReference(BaseModel):
]


class InferenceStoreReference(SqlStoreReference):
"""Inference store configuration with queue tuning."""
class _QueuedSqlStoreReference(SqlStoreReference):
"""Base for SQL store references with background write-queue tuning."""

max_write_queue_size: int = Field(
default=10000,
Expand All @@ -291,7 +291,18 @@ class InferenceStoreReference(SqlStoreReference):
)


class ResponsesStoreReference(InferenceStoreReference):
class InferenceStoreReference(_QueuedSqlStoreReference):
"""Inference store configuration with queue tuning."""

enabled: bool = Field(
default=True,
description=(
"Whether the store is enabled; when false, the store is not constructed and payloads are not persisted"
),
)


class ResponsesStoreReference(_QueuedSqlStoreReference):
"""Responses store configuration with queue tuning."""

table_name: str = Field(
Expand Down
24 changes: 24 additions & 0 deletions src/ogx/distributions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,27 @@ ogx run starter
# or
ogx stack run --config path/to/config.yaml
```

## Disabling Chat Completions Persistence

By default the `inference` store reference is enabled, so chat completion
request/response payloads are persisted and the history endpoints (`list`,
`retrieve`, `messages`) are served from it. An operator can disable that
persistence for the inference API by setting `inference.enabled: false` in a run
config:

```yaml
storage:
stores:
inference:
enabled: false
```

When the store is disabled, OGX does not construct an `InferenceStore` at all:
no `inference_store` table is created and no background write workers run. Chat
completions still work for both streaming and non-streaming requests; the
history endpoints report that persistence is not configured (HTTP 501) rather
than returning an empty list or a 404. Other stores (`responses`, `datasets`,
`eval`, `files`, `prompts`, `vector_io`) stay enabled, so disabling inference
persistence is independent of the rest of the storage layer. See the storage
module README for details.
1 change: 1 addition & 0 deletions src/ogx/distributions/ci-tests/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/nvidia/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/oci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/open-benchmark/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/starter/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/starter/run-with-postgres-store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down
1 change: 1 addition & 0 deletions src/ogx/distributions/watsonx/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ storage:
backend: sql_default
max_write_queue_size: 10000
num_writers: 4
enabled: true
conversations:
table_name: openai_conversations
backend: sql_default
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions tests/integration/inference/store_disabled_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) The OGX Contributors.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

"""Shared support for inference-store-disabled integration tests."""

from ogx.core.datatypes import StackConfig
from ogx.core.stack import get_stack_run_config_from_distro

TEXT_MODEL = "openai/gpt-4o"

NON_STREAMING_PROMPT = "Say hello."
STREAMING_PROMPT = "Say hello in one sentence."


def build_inference_store_disabled_run_config() -> StackConfig:
"""Build the minimal ci-tests configuration used by this test scenario."""
run_config = get_stack_run_config_from_distro("ci-tests")
# The ci-tests distribution always configures the inference store; disable
# persistence through the explicit flag while keeping the reference valid.
run_config.storage.stores.inference.enabled = False
# Vector-store model validation is unrelated to chat completion persistence
# and loads the sentence-transformers stack during an in-process boot.
run_config.vector_stores = None
return run_config
Loading