mellea
Use Mellea to build, test, serve, evaluate, instrument, and extend typed generative Python programs across provider backends and agent workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- mellea
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Mellea to build, test, serve, evaluate, instrument, and extend typed generative Python programs across provider backends and agent workflows.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/repo-provenance.md1.5 KB
- 参考文档references/repo-routing-metadata.json521 B
- 参考文档references/troubleshooting.md4.0 KB
03 SKILL.md 正文
Mellea
Mellea is a Python library for generative programs: typed functions and
components become model calls, schemas constrain outputs, requirements validate
meaning, and sampling can repair or select candidates. Use this repo skill when
a task names Mellea, generative, MelleaSession, mellea.stdlib, m serve,
m eval, Granite adapters, Mellea plugins, or a Mellea-compatible provider.
Fast route map
Choose the smallest route that owns the work:
- generative-programming: typed
generation, sessions, contexts, components, requirements, repair, async,
streaming, MObjects, and
mify. - backends-and-models: Ollama, OpenAI-compatible, Hugging Face, Watsonx, LiteLLM/Bedrock, model options, multimodal inputs, Granite formatters, and adapters.
- tools-and-agents: tool calls, interpreters, shell safety, MCP, ReAct, context compaction, and agent integrations.
- sampling-and-evaluation:
rejection/majority/feedback sampling, verifiers, unit-test evaluation,
LLM-as-judge, metrics, and
m eval. - serving-and-cli:
mcommands, Mellea HTTP serving, model routing, response formats, streaming endpoints, decomposition, and safe CLI inspection. - observability-and-extensions: plugins, hooks, logging, metrics, tracing, OpenTelemetry, custom components, and extensions.
If a request crosses routes, start here, select an owner for each phase, and keep the backend, safety, evaluation, serving, or telemetry boundary explicit.
Install and inspect
Mellea requires Python 3.11 or newer. For a normal application install:
uv pip install mellea
Add only the extra for the selected surface, for example:
uv pip install 'mellea[hf]' # local Hugging Face backend
uv pip install 'mellea[server,cli]' # HTTP service and m CLI
uv pip install 'mellea[tools]' # MCP/tool integrations
uv pip install 'mellea[telemetry]' # OpenTelemetry and hook telemetry
Do not install all merely to fix an import. Provider credentials, Ollama,
model checkpoints, cloud SDK configuration, and servers are separate runtime
prerequisites. Read troubleshooting before
changing dependencies. For source-version alignment, inspect
provenance.
Minimal base import check:
python -c "import mellea; print('mellea import ok')"
Operating rules
- Establish the backend and credential/service boundary before writing a real generation call; use a dummy or mocked backend for deterministic checks.
- Treat type annotations as output shape, not proof of semantic correctness; combine schemas with requirements and explicit validators.
- Make session/context ownership explicit. Choose independent contexts for concurrency and a chat context only when history is intentional.
- Keep tool execution, generated-code execution, network calls, checkpoint downloads, and exporters disabled in dry-run or parser checks.
- Separate deterministic unit assertions from qualitative model-output claims.
- Preserve usage metadata and paired lifecycle hooks when instrumenting spans; a completion-only hook can feed a metric but cannot open and close a span.
Self-contained helper boundary
Bundled helpers live under the owning route's scripts/ directory. They are
safe diagnostics or validators, not replacements for a model provider:
backends-and-models/scripts/check_backends.pychecks imports and optional device state without provider calls.generative-programming/scripts/inspect_api.pyprints verified signatures.tools-and-agents/scripts/audit_tool_request.pyaudits JSON tool requests without executing them.sampling-and-evaluation/scripts/validate_eval_config.pyvalidates a small eval config without running an evaluator.serving-and-cli/scripts/check_cli_surface.pyinspects CLI help/static structure without starting a server.observability-and-extensions/scripts/check_telemetry_install.pychecks telemetry imports without creating exporters.
Read the nearest sub-skill before running a helper; do not pass secrets or large payloads to diagnostics.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).