customization-and-structured-outputs
Customize LlamaIndex Settings, prompts, callbacks, instrumentation, evaluation signals, and Pydantic structured outputs without relying on external APIs during local checks.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- customization-and-structured-outputs
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Customize LlamaIndex Settings, prompts, callbacks, instrumentation, evaluation signals, and Pydantic structured outputs without relying on external APIs during local checks.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md7.6 KB
- 参考文档references/customization-recipes.md8.6 KB
- 参考文档references/troubleshooting.md6.4 KB
- 脚本scripts/inspect_settings_and_prompts.py5.9 KB
03 SKILL.md 正文
Customization and Structured Outputs
Use This Sub-Skill When
- You need to configure
Settings.llm,Settings.embed_model,Settings.node_parser,Settings.transformations,Settings.callback_manager, tokenizer, chunk sizes, or prompt helpers. - You need custom
PromptTemplateorChatPromptTemplatebehavior, prompt inspection, prompt updates, or output-parser formatting instructions. - You need Pydantic structured output through
PydanticOutputParser,LLMTextCompletionProgram,llm.as_structured_llm(...), orget_response_synthesizer(output_cls=...). - You need callbacks, instrumentation, token counting, or evaluator result shapes to debug query behavior.
- You need deterministic tests using
MockLLMandMockEmbeddingwhile avoiding external provider calls.
Route Elsewhere
- Use
../indexing-and-querying/for index construction, retrievers, query engines, node parsing as part of ingestion, and response modes in normal RAG flows. - Use
../integrations-and-storage/for provider packages, credentials, vector stores, readers, and external backend setup. - Use
../agents-and-workflows/forAgentWorkflow,FunctionAgent,ReActAgent, handoffs, tools, and agent orchestration; return here for schemas, parsers, prompts, and structured-output validation.
Core Workflow
- Decide scope: prefer per-object constructor arguments (
llm=,embed_model=,callback_manager=, prompt templates) when isolation matters; use globalSettingsonly for app-wide defaults. - For tests, set
Settings.llm = MockLLM(...)andSettings.embed_model = MockEmbedding(embed_dim=...), then restore priorSettingsfields after the test. - Customize prompts with
PromptTemplate,ChatPromptTemplate,partial_format,template_var_mappings,function_mappings, or component prompt APIs such asget_prompts()/update_prompts(). - Add structured outputs with a Pydantic model, then choose the surface: parser-attached prompt,
LLMTextCompletionProgram.from_defaults, structured LLM wrapper, or response synthesizeroutput_cls. - Add callbacks or instrumentation before constructing the component that should emit events, then verify events with a local query or explicit callback-manager context.
- Evaluate with evaluator classes that return
EvaluationResultfields (query,contexts,response,passing,score,feedback, invalid metadata), making sure input shapes match the evaluator.
Bundled References
references/customization-recipes.mdcontains copy-adapt recipes for Settings isolation, prompts, structured outputs, callbacks, instrumentation, and evaluation.references/api-reference.mdsummarizes verified import paths, signatures, and object responsibilities for this sub-skill.references/troubleshooting.mdmaps common customization and structured-output failures to targeted fixes.scripts/inspect_settings_and_prompts.pyprints Settings, prompt, parser, callback, evaluator, and mock-model checks without requiring external APIs.
Safety Notes
- Avoid deprecated
ServiceContext; current code usesSettingsand explicit constructor arguments. - Never let global
Settingsmutations leak between tests; snapshot and restore modified attributes. - Do not hard-code provider API keys in skill examples; provider installation and credentials are integration concerns.
- Treat Pydantic validation errors as schema/prompt/model-contract feedback, not as retriever failures.
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).