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
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ requires-python = ">=3.11"
license = { text = "Apache-2.0" }
authors = [{ name = "Robert Lippmann" }]
dependencies = [
"context-compiler==0.9.0dev13",
"context-compiler>=0.9.1,<0.10",
]
keywords = [
"context-compiler",
Expand Down Expand Up @@ -47,12 +47,12 @@ Issues = "https://github.com/rlippmann/context-compiler-example-integrations/iss
[project.optional-dependencies]
all = [
"chromadb",
"context-compiler-directive-drafter==0.2.0dev5",
"context-compiler-directive-drafter>=0.2.0,<0.3",
"fastapi",
"litellm",
]
drafter = [
"context-compiler-directive-drafter==0.2.0dev5",
"context-compiler-directive-drafter>=0.2.0,<0.3",
]
fastapi = [
"fastapi",
Expand All @@ -67,7 +67,7 @@ retrieval = [
[dependency-groups]
dev = [
"chromadb",
"context-compiler-directive-drafter==0.2.0dev5",
"context-compiler-directive-drafter>=0.2.0,<0.3",
"fastapi",
"httpx2>=2.5.0",
"httpx>=0.28.1",
Expand Down
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.9.0dev13`
- `context-compiler>=0.9.1,<0.10`

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

Expand Down
4 changes: 2 additions & 2 deletions python/examples/prompt_construction/litellm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ pip install "context-compiler-example-integrations[litellm]"
export OPENAI_API_KEY=...
```

These examples require `context-compiler>=0.9.0dev13`.
These examples require `context-compiler>=0.9.1,<0.10`.

For `with_directive_drafter.py`:

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

That variant requires `context-compiler-directive-drafter>=0.2.0dev5`.
That variant requires `context-compiler-directive-drafter>=0.2.0,<0.3`.

## Quickstart (copy/paste)

Expand Down
2 changes: 1 addition & 1 deletion python/reference_integrations/litellm_proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,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.2.0dev5`.
That variant requires `context-compiler-directive-drafter>=0.2.0,<0.3`.

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

Expand Down
10 changes: 5 additions & 5 deletions python/reference_integrations/openwebui_pipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,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.9.0dev13`.
These examples require `context-compiler>=0.9.1,<0.10`.

### Configuration

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

- Install directive-drafter support if needed:
`pip install "context-compiler>=0.9.0dev13" "context-compiler-directive-drafter>=0.2.0dev5"`
`pip install "context-compiler>=0.9.1,<0.10" "context-compiler-directive-drafter>=0.2.0,<0.3"`
- Optionally set `DRAFTER_MODEL_ID` to use a separate fallback drafting model
- If neither model id is set, fallback uses `BASE_MODEL_ID`

Expand All @@ -83,8 +83,8 @@ If frontmatter dependency installs are disabled, offline, or unavailable:

1. Install the package manually:

- 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.0dev5"`
- Minimal pipe: `pip install "context-compiler>=0.9.1,<0.10"`
- Directive Drafter pipe: `pip install "context-compiler>=0.9.1,<0.10" "context-compiler-directive-drafter>=0.2.0,<0.3"`

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

Expand Down Expand Up @@ -244,7 +244,7 @@ rejection flows.
- `DRAFTER_MODEL_ID must not match the selected pipe model id`: choose a real backend model id, not the pipe model id itself.
- `DRAFTER_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.9.0dev13` in the Open WebUI runtime, and add `context-compiler-directive-drafter>=0.2.0dev5` 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.1,<0.10` in the Open WebUI runtime, and add `context-compiler-directive-drafter>=0.2.0,<0.3` 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 @@ -2,8 +2,8 @@
title: Context Compiler Open WebUI Pipe
author: rlippmann
author_url: https://github.com/rlippmann/context-compiler-example-integrations
version: 0.10.0
requirements: context-compiler>=0.9.0dev13
version: 0.10.1
requirements: context-compiler>=0.9.1,<0.10

Minimal Open WebUI Pipe integration for Context Compiler.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Context Compiler Open WebUI Pipe (Directive Drafter)
author: rlippmann
author_url: https://github.com/rlippmann/context-compiler-example-integrations
version: 0.10.2
requirements: context-compiler>=0.9.0dev13, context-compiler-directive-drafter>=0.2.0dev5
version: 0.10.3
requirements: context-compiler>=0.9.1,<0.10, context-compiler-directive-drafter>=0.2.0,<0.3

Open WebUI integration with Context Compiler directive drafter.

Expand Down
16 changes: 8 additions & 8 deletions python/tests/test_litellm_proxy_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ def test_current_turn_is_processed_exactly_once(monkeypatch) -> None:
seen_inputs: list[str] = []
original_Engine = module.Engine

def Engine_with_tracking():
engine = original_Engine()
original_step = engine.step
original_step = original_Engine.step

def tracked_step(self, user_input: str):
seen_inputs.append(user_input)
return original_step(self, user_input)

def tracked_step(user_input: str):
seen_inputs.append(user_input)
return original_step(user_input)
monkeypatch.setattr(original_Engine, "step", tracked_step)

engine.step = tracked_step
return engine
def Engine_with_tracking():
return original_Engine()

monkeypatch.setattr(module, "Engine", Engine_with_tracking)
data = {
Expand Down
34 changes: 17 additions & 17 deletions python/tests/test_litellm_with_directive_drafter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def test_directive_shaped_or_natural_language_input_is_drafted_before_engine_ste
monkeypatch,
) -> None:
compile_inputs: list[str] = []
real_step = Engine().step

engine = Engine()

def step_with_capture(user_input: str):
real_step = Engine.step

def step_with_capture(self: Engine, user_input: str):
compile_inputs.append(user_input)
return real_step(user_input)
return real_step(self, user_input)

monkeypatch.setattr(engine, "step", step_with_capture)
monkeypatch.setattr(Engine, "step", step_with_capture)
monkeypatch.setattr(
module,
"_get_directive_drafter",
Expand All @@ -53,13 +53,13 @@ def test_rejected_canonical_directive_does_not_call_engine_step_or_mutate_state(
) -> None:
engine = Engine()
compile_inputs: list[str] = []
real_step = engine.step
real_step = Engine.step

def step_with_capture(user_input: str):
def step_with_capture(self: Engine, user_input: str):
compile_inputs.append(user_input)
return real_step(user_input)
return real_step(self, user_input)

monkeypatch.setattr(engine, "step", step_with_capture)
monkeypatch.setattr(Engine, "step", step_with_capture)
monkeypatch.setattr(
module,
"_get_directive_drafter",
Expand Down Expand Up @@ -88,13 +88,13 @@ def test_no_directive_keeps_normal_flow(monkeypatch) -> None:
engine = Engine()
compile_inputs: list[str] = []
llm_calls: list[list[dict[str, str]]] = []
real_step = engine.step
real_step = Engine.step

def step_with_capture(user_input: str):
def step_with_capture(self: Engine, user_input: str):
compile_inputs.append(user_input)
return real_step(user_input)
return real_step(self, user_input)

monkeypatch.setattr(engine, "step", step_with_capture)
monkeypatch.setattr(Engine, "step", step_with_capture)
monkeypatch.setattr(
module,
"_get_directive_drafter",
Expand All @@ -118,13 +118,13 @@ def test_unknown_directive_keeps_normal_flow(monkeypatch) -> None:
engine = Engine()
compile_inputs: list[str] = []
llm_calls: list[list[dict[str, str]]] = []
real_step = engine.step
real_step = Engine.step

def step_with_capture(user_input: str):
def step_with_capture(self: Engine, user_input: str):
compile_inputs.append(user_input)
return real_step(user_input)
return real_step(self, user_input)

monkeypatch.setattr(engine, "step", step_with_capture)
monkeypatch.setattr(Engine, "step", step_with_capture)
monkeypatch.setattr(
module,
"_get_directive_drafter",
Expand Down
48 changes: 24 additions & 24 deletions python/tests/test_openwebui_pipe_with_directive_drafter.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ def test_approval_applies_directive_through_engine_path(monkeypatch) -> None:
compile_inputs: list[str] = []
real_Engine = module.Engine

def Engine_with_tracking():
engine = real_Engine()
original_apply_directive = engine.apply_directive
original_apply_directive = real_Engine.apply_directive

def tracked_apply_directive(self, directive):
compile_inputs.append(directive.text)
return original_apply_directive(self, directive)

def tracked_apply_directive(directive):
compile_inputs.append(directive.text)
return original_apply_directive(directive)
monkeypatch.setattr(real_Engine, "apply_directive", tracked_apply_directive)

engine.apply_directive = tracked_apply_directive
return engine
def Engine_with_tracking():
return real_Engine()

monkeypatch.setattr(module, "Engine", Engine_with_tracking)
pipe = module.Pipe()
Expand Down Expand Up @@ -456,16 +456,16 @@ def test_rejected_confirmation_does_not_apply_follow_up(monkeypatch) -> None:
forwarded: list[dict[str, object]] = []
real_Engine = module.Engine

def Engine_with_tracking():
engine = real_Engine()
original_step = engine.step
original_step = real_Engine.step

def tracked_step(user_input: str):
compile_inputs.append(user_input)
return original_step(user_input)
def tracked_step(self, user_input: str):
compile_inputs.append(user_input)
return original_step(self, user_input)

engine.step = tracked_step
return engine
monkeypatch.setattr(real_Engine, "step", tracked_step)

def Engine_with_tracking():
return real_Engine()

async def forward(
_: object, payload: dict[str, object], __: object
Expand Down Expand Up @@ -542,16 +542,16 @@ def test_rejected_confirmation_does_not_leave_state(
forwarded: list[dict[str, object]] = []
real_Engine = module.Engine

def Engine_with_tracking():
engine = real_Engine()
original_step = engine.step
original_step = real_Engine.step

def tracked_step(user_input: str):
compile_inputs.append(user_input)
return original_step(user_input)
def tracked_step(self, user_input: str):
compile_inputs.append(user_input)
return original_step(self, user_input)

engine.step = tracked_step
return engine
monkeypatch.setattr(real_Engine, "step", tracked_step)

def Engine_with_tracking():
return real_Engine()

async def forward(
_: object, payload: dict[str, object], __: object
Expand Down
20 changes: 10 additions & 10 deletions uv.lock

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

Loading