You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+68-2Lines changed: 68 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ Tests use a four-tier granularity system (`unit`, `integration`, `e2e`, `qualita
51
51
52
52
See **[test/MARKERS_GUIDE.md](test/MARKERS_GUIDE.md)** for the full marker reference (tier definitions, backend markers, resource gates, auto-skip logic, common patterns).
53
53
54
-
**Examples in `docs/examples/`**use comment-based markers:
54
+
**Examples in `docs/examples/`**are opt-in — unlike `test/` files (auto-collected, default `unit`), examples require an explicit `# pytest:` comment to be collected. Files without this comment are silently ignored (they won't appear in skip summaries either). This is because examples have variable dependencies and limited setup:
-**Friendly Dependency Errors**: Wraps optional backend imports in `try/except ImportError` with a helpful message (e.g., "Please pip install mellea[hf]"). See `mellea/stdlib/session.py` for examples.
91
-
-**Backend telemetry fields**: All backends must populate `mot.usage` (dict with `prompt_tokens`, `completion_tokens`, `total_tokens`), `mot.model` (str), and `mot.provider` (str) in their `post_processing()` method. Metrics are automatically recorded by `TokenMetricsPlugin` — don't add manual `record_token_usage_metrics()` calls.
91
+
-**CLI command docstrings**: Typer command functions in `cli/` follow an enriched convention with `Prerequisites:` and `See Also:` sections — these feed the auto-generated CLI reference page. See [`docs/docs/guide/CONTRIBUTING.md`](docs/docs/guide/CONTRIBUTING.md) for the full pattern. Regenerate after changes: `uv run poe clidocs`. Test the generator: `uv run pytest tooling/docs-autogen/test_cli_reference.py -v`. Full pipeline docs: [`tooling/docs-autogen/README.md`](tooling/docs-autogen/README.md).
92
+
-**Backend telemetry fields**: All backends must populate `mot.usage` (dict with `prompt_tokens`, `completion_tokens`, `total_tokens`), `mot.model` (str), and `mot.provider` (str) in their `post_processing()` method. `mot.streaming` (bool) and `mot.ttfb_ms` (float | None) are set automatically in `astream()` — backends do not need to set them. Metrics are automatically recorded by `TokenMetricsPlugin` and `LatencyMetricsPlugin` — don't add manual `record_token_usage_metrics()` or `record_request_duration()` calls.
@@ -146,3 +147,68 @@ Found a bug, workaround, or pattern? Update the docs:
146
147
-**Issue/workaround?** → Add to Section 7 (Common Issues) in this file
147
148
-**Usage pattern?** → Add to [`docs/AGENTS_TEMPLATE.md`](docs/AGENTS_TEMPLATE.md)
148
149
-**New pitfall?** → Add warning near relevant section
150
+
151
+
## 13. Working with Intrinsics
152
+
153
+
Intrinsics are specialized LoRA adapters that add task-specific capabilities (RAG evaluation, safety checks, calibration, etc.) to Granite models. Mellea handles adapter loading and input formatting automatically — you just call the right function.
154
+
155
+
### Using Intrinsics in Mellea
156
+
157
+
**Prefer the high-level wrappers** in `mellea/stdlib/components/intrinsic/`. These handle adapter loading, context formatting, and output parsing for you:
158
+
159
+
| Module | Function | Description |
160
+
|--------|----------|-------------|
161
+
|`core`|`check_certainty(context, backend)`| Model certainty about its last response (0–1) |
162
+
|`core`|`requirement_check(context, backend, requirement)`| Whether text meets a requirement (0–1) |
163
+
|`core`|`find_context_attributions(response, documents, context, backend)`| Sentences that influenced the response |
164
+
|`rag`|`check_answerability(question, documents, context, backend)`| Whether documents can answer a question (0–1) |
165
+
|`rag`|`rewrite_question(question, context, backend)`| Rewrite question into a retrieval query |
166
+
|`rag`|`clarify_query(question, documents, context, backend)`| Generate clarification or return "CLEAR" |
167
+
|`rag`|`find_citations(response, documents, context, backend)`| Document sentences supporting the response |
168
+
|`rag`|`check_context_relevance(question, document, context, backend)`| Whether a document is relevant (0–1) |
169
+
|`rag`|`flag_hallucinated_content(response, documents, context, backend)`| Flag potentially hallucinated sentences |
170
+
171
+
```python
172
+
from mellea.backends.huggingface import LocalHFBackend
173
+
from mellea.stdlib.components import Message
174
+
from mellea.stdlib.components.intrinsic import core
.add(Message("user", "What is the square root of 4?"))
181
+
.add(Message("assistant", "The square root of 4 is 2."))
182
+
)
183
+
score = core.check_certainty(context, backend)
184
+
```
185
+
186
+
For lower-level control (custom adapters, model options), use `mfuncs.act()` with `Intrinsic` directly — see examples in `docs/examples/intrinsics/`.
187
+
188
+
### Project Resources
189
+
190
+
-**Canonical catalog**: `mellea/backends/adapters/catalog.py` — source of truth for intrinsic names, HF repo IDs, and adapter types
191
+
-**Usage examples**: `docs/examples/intrinsics/` — working code for every intrinsic
192
+
-**Helper functions**: `mellea/stdlib/components/intrinsic/rag.py` and `core.py`
193
+
194
+
### Adding New Intrinsics
195
+
196
+
When adding support for a new intrinsic (not just using an existing one), fetch its README from Hugging Face first. Each README contains the authoritative spec for input/output format, intended use, and examples.
197
+
198
+
**Writing examples?** The HF READMEs also document intended usage patterns and example inputs — useful reference when writing code in `docs/examples/intrinsics/`.
<!-- Release notes generated using configuration in .github/release.yml at main -->
4
+
5
+
## What's Changed
6
+
### New Features
7
+
* feat: add tests for mellea optional dependencies by @jakelorocco in https://github.com/generative-computing/mellea/pull/724
8
+
* feat: further vram optimizations by @avinash2692 in https://github.com/generative-computing/mellea/pull/765
9
+
* feat: (m decomp) M Decompose Readme and Docstring Updates by @csbobby in https://github.com/generative-computing/mellea/pull/767
10
+
* feat: add top level async streaming by @jakelorocco in https://github.com/generative-computing/mellea/pull/655
11
+
* feat(serve): improve OpenAI API compatibility with usage, finish_reas… by @markstur in https://github.com/generative-computing/mellea/pull/771
12
+
* feat: removing vllm backend by @avinash2692 in https://github.com/generative-computing/mellea/pull/781
13
+
### Bug Fixes
14
+
* fix: modifications to granite formatter tests by @jakelorocco in https://github.com/generative-computing/mellea/pull/703
15
+
* fix: exclude tooling from mypy check by @planetf1 in https://github.com/generative-computing/mellea/pull/748
16
+
* fix: setting ollama host in conftest by @avinash2692 in https://github.com/generative-computing/mellea/pull/751
17
+
* fix: Add qualitative and slow markers so the example is skipped by @markstur in https://github.com/generative-computing/mellea/pull/764
18
+
* fix(tools): correct args validation in langchain tool wrapper by @markstur in https://github.com/generative-computing/mellea/pull/761
19
+
* fix: remove references to old pytest markers by @jakelorocco in https://github.com/generative-computing/mellea/pull/776
20
+
* fix: add error handling to OpenAI-compatible serve endpoint by @markstur in https://github.com/generative-computing/mellea/pull/774
21
+
* fix: assertion for test_find_context_attributions and range for hallucination detection by @jakelorocco in https://github.com/generative-computing/mellea/pull/779
22
+
* fix: add xfail to citation test; functionality is tested elsewhere by @jakelorocco in https://github.com/generative-computing/mellea/pull/787
23
+
### Documentation
24
+
* docs: remove discord link in main readme by @AngeloDanducci in https://github.com/generative-computing/mellea/pull/720
25
+
* docs: note virtual environment requirement for pre-commit hooks by @ajbozarth in https://github.com/generative-computing/mellea/pull/745
26
+
* docs: condense README to elevator pitch (#478) by @planetf1 in https://github.com/generative-computing/mellea/pull/688
27
+
* docs: update qiskit_code_validation example defaults by @ajbozarth in https://github.com/generative-computing/mellea/pull/743
28
+
* docs: remove pre-IVR validation and update readme with v2 benchmark results by @ajbozarth in https://github.com/generative-computing/mellea/pull/769
29
+
### Other Changes
30
+
* docs: add multi-turn strategy option to Qiskit code validation example by @vabarbosa in https://github.com/generative-computing/mellea/pull/717
31
+
* chore: use github tooling to build release notes by @psschwei in https://github.com/generative-computing/mellea/pull/710
32
+
* docs: add release.md by @psschwei in https://github.com/generative-computing/mellea/pull/723
33
+
* fix: proper permissions on pr labeling job by @psschwei in https://github.com/generative-computing/mellea/pull/741
34
+
* ci: memory management in tests by @avinash2692 in https://github.com/generative-computing/mellea/pull/721
35
+
* chore: enforce commit formatting on PR titles by @psschwei in https://github.com/generative-computing/mellea/pull/750
36
+
* chore: Update HF repo names by @frreiss in https://github.com/generative-computing/mellea/pull/753
37
+
* ci: drop mergify, add release entry to pr-labels action by @psschwei in https://github.com/generative-computing/mellea/pull/752
38
+
* ci: fix to make pr label job required check by @psschwei in https://github.com/generative-computing/mellea/pull/756
39
+
* test: agent skills infrastructure and marker taxonomy audit (#727, #728) by @planetf1 in https://github.com/generative-computing/mellea/pull/742
40
+
* chore: add governance doc by @psschwei in https://github.com/generative-computing/mellea/pull/786
41
+
* chore: updating governance doc to use maintainers by @psschwei in https://github.com/generative-computing/mellea/pull/791
42
+
43
+
## New Contributors
44
+
*@markstur made their first contribution in https://github.com/generative-computing/mellea/pull/764
0 commit comments