AGENT SKILL

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

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 PromptTemplate or ChatPromptTemplate behavior, prompt inspection, prompt updates, or output-parser formatting instructions.
  • You need Pydantic structured output through PydanticOutputParser, LLMTextCompletionProgram, llm.as_structured_llm(...), or get_response_synthesizer(output_cls=...).
  • You need callbacks, instrumentation, token counting, or evaluator result shapes to debug query behavior.
  • You need deterministic tests using MockLLM and MockEmbedding while 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/ for AgentWorkflow, FunctionAgent, ReActAgent, handoffs, tools, and agent orchestration; return here for schemas, parsers, prompts, and structured-output validation.

Core Workflow

  1. Decide scope: prefer per-object constructor arguments (llm=, embed_model=, callback_manager=, prompt templates) when isolation matters; use global Settings only for app-wide defaults.
  2. For tests, set Settings.llm = MockLLM(...) and Settings.embed_model = MockEmbedding(embed_dim=...), then restore prior Settings fields after the test.
  3. Customize prompts with PromptTemplate, ChatPromptTemplate, partial_format, template_var_mappings, function_mappings, or component prompt APIs such as get_prompts() / update_prompts().
  4. Add structured outputs with a Pydantic model, then choose the surface: parser-attached prompt, LLMTextCompletionProgram.from_defaults, structured LLM wrapper, or response synthesizer output_cls.
  5. Add callbacks or instrumentation before constructing the component that should emit events, then verify events with a local query or explicit callback-manager context.
  6. Evaluate with evaluator classes that return EvaluationResult fields (query, contexts, response, passing, score, feedback, invalid metadata), making sure input shapes match the evaluator.

Bundled References

  • references/customization-recipes.md contains copy-adapt recipes for Settings isolation, prompts, structured outputs, callbacks, instrumentation, and evaluation.
  • references/api-reference.md summarizes verified import paths, signatures, and object responsibilities for this sub-skill.
  • references/troubleshooting.md maps common customization and structured-output failures to targeted fixes.
  • scripts/inspect_settings_and_prompts.py prints Settings, prompt, parser, callback, evaluator, and mock-model checks without requiring external APIs.

Safety Notes

  • Avoid deprecated ServiceContext; current code uses Settings and explicit constructor arguments.
  • Never let global Settings mutations 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351