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
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pip install "context-compiler-example-integrations"

That installs the shared core dependency only:

- `context-compiler>=0.8.3`
- `context-compiler>=0.9.0dev13`

Add extras only for the examples you want to inspect locally:

Expand Down
16 changes: 13 additions & 3 deletions python/examples/prompt_construction/litellm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ with LiteLLM:
- `basic.py`: compiler-only flow (no directive drafter)
- `with_directive_drafter.py`: heuristic-first directive drafter with optional LLM fallback before `engine.step(...)`

Both flows use the current compiler API: create an `Engine`, pass the latest
input to `engine.step(...)`, and handle the returned decision object. The host
reads fields such as `decision.kind` and `decision.message`; it does not use
retired decision helper functions or derive authoritative state from model
output.

## What the user sees

- Compiler-only flow:
Expand Down Expand Up @@ -54,15 +60,15 @@ pip install "context-compiler-example-integrations[litellm]"
export OPENAI_API_KEY=...
```

These examples require `context-compiler>=0.8.3`.
These examples require `context-compiler>=0.9.0dev13`.

For `with_directive_drafter.py`:

```shell
pip install "context-compiler-example-integrations[all]"
```

That variant requires `context-compiler-directive-drafter>=0.1.2`.
That variant requires `context-compiler-directive-drafter>=0.2.0dev2`.

## Quickstart (copy/paste)

Expand Down Expand Up @@ -174,7 +180,11 @@ In the related schema-selection example:
- Conflict behavior (both):
- `use docker` then `prohibit docker` -> conflict error.
- Replacement precondition (both):
- `use podman instead of docker` without prior `use docker` -> replacement error.
- A replacement requires the source policy to exist first.
- `use podman instead of docker` without prior `use docker` returns an error
decision with failure `REPLACEMENT_SOURCE_MISSING`.
- Any repairs attached to that decision are advisory; they do not authorize
a state change.
- Directive-adjacent abstain (`with_directive_drafter.py`):
- `change premise concise replies` is classified as `unknown`, not rewritten, and handled by an engine error prompt.
- Host-side request shaping (`python/examples/schema_selection/litellm_response_format/response_format.py`):
Expand Down
5 changes: 4 additions & 1 deletion python/reference_integrations/litellm_proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Available hook files:
- In stateless mode, no continuity is preserved across requests.
- If directive application fails, the proxy does not call the downstream model
and LiteLLM surfaces the rejection as an HTTP 400 response.
- Replacements require an existing source policy. A missing source produces an
error decision with failure `REPLACEMENT_SOURCE_MISSING`; repairs on that
decision are advisory and do not authorize a state change.
- If result is `passthrough`, the proxy forwards the request normally.
- If result is `update`, the proxy injects compiler state as a system message
and then calls the model.
Expand Down Expand Up @@ -105,7 +108,7 @@ For `context_compiler_precall_hook_with_directive_drafter.py`:
pip install "context-compiler-example-integrations[all]"
```

That variant requires `context-compiler-directive-drafter>=0.1.2`.
That variant requires `context-compiler-directive-drafter>=0.2.0dev2`.

For the opt-in runtime smoke test, install the proxy runtime extras:

Expand Down
13 changes: 8 additions & 5 deletions python/reference_integrations/openwebui_pipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ without Directive Drafter preprocessing.
`[[cc_state]]` system message in the forwarded request.
- Conflicting or invalid updates are rejected for the current request and do not
create resumable continuation state.
- A replacement is valid only when its source policy already exists. If the
source is missing, `engine.step(...)` returns an error decision with failure
`REPLACEMENT_SOURCE_MISSING`; any attached repairs are advisory.
- The pipe handles exact `show state` locally. The pipe treats near matches such
as `show state please` as normal chat input.

Expand Down Expand Up @@ -53,7 +56,7 @@ Open WebUI is a separate runtime and must already be installed/configured separa
Open WebUI also needs at least one real backend model/provider configured (for example Ollama or OpenAI) so `BASE_MODEL_ID` resolves to an actual model.
Note: The `PROVIDER` environment contract used in LiteLLM examples/demos does not apply to OpenWebUI. OpenWebUI manages providers via its own connection settings and model IDs.

These examples require `context-compiler>=0.8.3`.
These examples require `context-compiler>=0.9.0dev13`.

### Configuration

Expand All @@ -65,7 +68,7 @@ These examples require `context-compiler>=0.8.3`.
If using `open_webui_pipe_with_directive_drafter.py`:

- Install directive-drafter support if needed:
`pip install "context-compiler>=0.8.3" "context-compiler-directive-drafter>=0.1.2"`
`pip install "context-compiler>=0.9.0dev13" "context-compiler-directive-drafter>=0.2.0dev2"`
- Set `PREPROCESSOR_PROMPT_PROFILE=default` for heuristic-first behavior
- Optionally set `PREPROCESSOR_MODEL_ID` to use a separate fallback drafting model
- If `PREPROCESSOR_MODEL_ID` is unset, fallback uses `BASE_MODEL_ID`
Expand All @@ -82,8 +85,8 @@ If frontmatter dependency installs are disabled, offline, or unavailable:

1. Install the package manually:

- Minimal pipe: `pip install "context-compiler>=0.8.3"`
- Directive Drafter pipe: `pip install "context-compiler>=0.8.3" "context-compiler-directive-drafter>=0.1.2"`
- Minimal pipe: `pip install "context-compiler>=0.9.0dev13"`
- Directive Drafter pipe: `pip install "context-compiler>=0.9.0dev13" "context-compiler-directive-drafter>=0.2.0dev2"`

1. Import and enable the function in Open WebUI, then configure valves.

Expand Down Expand Up @@ -226,7 +229,7 @@ These examples support both sync (`0.8.x`) and async (`0.9.x`) user lookup.
- `PREPROCESSOR_MODEL_ID must not match the selected pipe model id`: choose a real backend model id, not the pipe model id itself.
- `PREPROCESSOR_MODEL_ID is invalid or not configured in Open WebUI`: the fallback route hit a missing model; fix the configured fallback model or unset it to reuse `BASE_MODEL_ID`.
- `ALLOW_MISSING_BASE_MODEL_FOR_DEBUG=true`: directive-only updates still run locally, but passthrough returns a deterministic debug message instead of calling a downstream model.
- imports fail after function upload: install `context-compiler>=0.8.3` in the Open WebUI runtime, and add `context-compiler-directive-drafter>=0.1.2` only for the Directive Drafter pipe, because the copied function runs from a temp/cached location.
- imports fail after function upload: install `context-compiler>=0.9.0dev13` in the Open WebUI runtime, and add `context-compiler-directive-drafter>=0.2.0dev2` only for the Directive Drafter pipe, because the copied function runs from a temp/cached location.

## Fallback notes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
author: rlippmann
author_url: https://github.com/rlippmann/context-compiler-example-integrations
version: 0.9.4
requirements: context-compiler>=0.8.3
requirements: context-compiler>=0.9.0dev13

Minimal Open WebUI Pipe integration for Context Compiler.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
author: rlippmann
author_url: https://github.com/rlippmann/context-compiler-example-integrations
version: 0.9.4
requirements: context-compiler>=0.8.3, context-compiler-directive-drafter>=0.1.2
requirements: context-compiler>=0.9.0dev13, context-compiler-directive-drafter>=0.2.0dev2

Open WebUI integration with Context Compiler directive drafter.

Expand Down