zilmate 1.9.3 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/ad-creative/SKILL.md +362 -0
- package/.agents/skills/ad-creative/evals/evals.json +90 -0
- package/.agents/skills/ad-creative/references/generative-tools.md +637 -0
- package/.agents/skills/ad-creative/references/platform-specs.md +213 -0
- package/.agents/skills/ai-seo/SKILL.md +489 -0
- package/.agents/skills/ai-seo/evals/evals.json +90 -0
- package/.agents/skills/ai-seo/references/content-patterns.md +285 -0
- package/.agents/skills/ai-seo/references/content-types.md +71 -0
- package/.agents/skills/ai-seo/references/okf.md +104 -0
- package/.agents/skills/ai-seo/references/platform-ranking-factors.md +154 -0
- package/.agents/skills/clerk-backend-api/SKILL.md +426 -0
- package/.agents/skills/clerk-backend-api/evals/evals.json +87 -0
- package/.agents/skills/clerk-backend-api/scripts/api-specs-context.sh +30 -0
- package/.agents/skills/clerk-backend-api/scripts/execute-request.sh +88 -0
- package/.agents/skills/clerk-backend-api/scripts/extract-endpoint-detail.sh +165 -0
- package/.agents/skills/clerk-backend-api/scripts/extract-tag-endpoints.sh +208 -0
- package/.agents/skills/clerk-backend-api/scripts/extract-tags.js +14 -0
- package/.agents/skills/copy-editing/SKILL.md +457 -0
- package/.agents/skills/copy-editing/evals/evals.json +89 -0
- package/.agents/skills/copy-editing/references/checklist.md +66 -0
- package/.agents/skills/copy-editing/references/content-refresh.md +38 -0
- package/.agents/skills/copy-editing/references/plain-english-alternatives.md +394 -0
- package/.agents/skills/hyperframes/SKILL.md +163 -0
- package/.agents/skills/hyperframes-cli/SKILL.md +109 -0
- package/.agents/skills/hyperframes-cli/references/doctor-browser.md +45 -0
- package/.agents/skills/hyperframes-cli/references/init-and-scaffold.md +51 -0
- package/.agents/skills/hyperframes-cli/references/lambda.md +132 -0
- package/.agents/skills/hyperframes-cli/references/lint-validate-inspect.md +121 -0
- package/.agents/skills/hyperframes-cli/references/preview-render.md +109 -0
- package/.agents/skills/hyperframes-cli/references/upgrade-info-misc.md +75 -0
- package/.agents/skills/hyperframes-media/SKILL.md +97 -0
- package/.agents/skills/hyperframes-media/assets/sfx/CREDITS.md +35 -0
- package/.agents/skills/hyperframes-media/assets/sfx/manifest.json +97 -0
- package/.agents/skills/hyperframes-media/references/bgm.md +72 -0
- package/.agents/skills/hyperframes-media/references/captions/authoring.md +159 -0
- package/.agents/skills/hyperframes-media/references/captions/motion.md +87 -0
- package/.agents/skills/hyperframes-media/references/captions/transcript-handling.md +97 -0
- package/.agents/skills/hyperframes-media/references/remove-background.md +143 -0
- package/.agents/skills/hyperframes-media/references/requirements.md +29 -0
- package/.agents/skills/hyperframes-media/references/sfx.md +42 -0
- package/.agents/skills/hyperframes-media/references/transcribe.md +52 -0
- package/.agents/skills/hyperframes-media/references/tts-to-captions.md +24 -0
- package/.agents/skills/hyperframes-media/references/tts.md +135 -0
- package/.agents/skills/hyperframes-media/scripts/audio.mjs +282 -0
- package/.agents/skills/hyperframes-media/scripts/heygen-tts.mjs +121 -0
- package/.agents/skills/hyperframes-media/scripts/lib/bgm.mjs +235 -0
- package/.agents/skills/hyperframes-media/scripts/lib/heygen.mjs +131 -0
- package/.agents/skills/hyperframes-media/scripts/lib/sfx.mjs +128 -0
- package/.agents/skills/hyperframes-media/scripts/lib/tts.mjs +220 -0
- package/.agents/skills/hyperframes-media/scripts/lyria-recipe.py +128 -0
- package/.agents/skills/hyperframes-media/scripts/wait-bgm.mjs +167 -0
- package/.agents/skills/hyperframes-registry/SKILL.md +101 -0
- package/.agents/skills/hyperframes-registry/examples/add-block.md +51 -0
- package/.agents/skills/hyperframes-registry/examples/add-component.md +73 -0
- package/.agents/skills/hyperframes-registry/references/contributing.md +166 -0
- package/.agents/skills/hyperframes-registry/references/demo-html-pattern.md +54 -0
- package/.agents/skills/hyperframes-registry/references/discovery.md +215 -0
- package/.agents/skills/hyperframes-registry/references/install-locations.md +45 -0
- package/.agents/skills/hyperframes-registry/references/templates.md +417 -0
- package/.agents/skills/hyperframes-registry/references/wiring-blocks.md +61 -0
- package/.agents/skills/hyperframes-registry/references/wiring-components.md +39 -0
- package/.agents/skills/marketing-psychology/SKILL.md +455 -0
- package/.agents/skills/marketing-psychology/evals/evals.json +88 -0
- package/.agents/skills/mintlify/SKILL.md +328 -0
- package/.agents/skills/product-launch-video/SKILL.md +206 -0
- package/.agents/skills/product-launch-video/references/cut-catalog.md +220 -0
- package/.agents/skills/product-launch-video/references/motion-language.md +156 -0
- package/.agents/skills/product-launch-video/references/story-design.md +373 -0
- package/.agents/skills/product-launch-video/references/visual-design.md +126 -0
- package/.agents/skills/product-launch-video/scripts/assemble-index.mjs +570 -0
- package/.agents/skills/product-launch-video/scripts/audio.mjs +253 -0
- package/.agents/skills/product-launch-video/scripts/build-frame.mjs +536 -0
- package/.agents/skills/product-launch-video/scripts/captions.mjs +508 -0
- package/.agents/skills/product-launch-video/scripts/lib/assets.mjs +55 -0
- package/.agents/skills/product-launch-video/scripts/lib/dimensions.mjs +45 -0
- package/.agents/skills/product-launch-video/scripts/lib/storyboard.mjs +249 -0
- package/.agents/skills/product-launch-video/scripts/lib/tokens.mjs +204 -0
- package/.agents/skills/product-launch-video/scripts/lib/transition-registry.mjs +38 -0
- package/.agents/skills/product-launch-video/scripts/lib/transitions.json +71 -0
- package/.agents/skills/product-launch-video/scripts/stage-assets.mjs +39 -0
- package/.agents/skills/product-launch-video/scripts/transitions.mjs +320 -0
- package/.agents/skills/product-launch-video/sub-agents/frame-worker.md +74 -0
- package/.agents/skills/prompt-engineering-patterns/SKILL.md +144 -0
- package/.agents/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
- package/.agents/skills/prompt-engineering-patterns/assets/prompt-template-library.md +264 -0
- package/.agents/skills/prompt-engineering-patterns/references/chain-of-thought.md +412 -0
- package/.agents/skills/prompt-engineering-patterns/references/details.md +338 -0
- package/.agents/skills/prompt-engineering-patterns/references/few-shot-learning.md +386 -0
- package/.agents/skills/prompt-engineering-patterns/references/prompt-optimization.md +428 -0
- package/.agents/skills/prompt-engineering-patterns/references/prompt-templates.md +484 -0
- package/.agents/skills/prompt-engineering-patterns/references/system-prompts.md +195 -0
- package/.agents/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/.agents/skills/remotion-to-hyperframes/SKILL.md +127 -0
- package/.agents/skills/remotion-to-hyperframes/assets/.gitkeep +0 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/run.sh +249 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/README.md +41 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/expected.json +26 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/hf-src/index.html +61 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/package.json +14 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/remotion.config.ts +13 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/src/Root.tsx +13 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/src/TitleCard.tsx +34 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/src/index.ts +4 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-1-title-card/remotion-src/tsconfig.json +15 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/README.md +54 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/expected.json +29 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/hf-src/index.html +118 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/package.json +14 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/remotion.config.ts +13 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/src/MultiScene.tsx +105 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/src/Root.tsx +13 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/src/index.ts +4 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/remotion-src/tsconfig.json +15 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-2-multi-scene/setup.sh +34 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/README.md +85 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/expected.json +41 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/hf-src/index.html +269 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/package.json +15 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/remotion.config.ts +13 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/Root.tsx +27 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/Stargazed.tsx +37 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/components/AnimatedNumber.tsx +23 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/components/StatCard.tsx +59 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/components/UnderlinedText.tsx +47 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/index.ts +4 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/scenes/OutroScene.tsx +18 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/scenes/StatsScene.tsx +34 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/src/scenes/TitleScene.tsx +55 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-3-data-driven/remotion-src/tsconfig.json +15 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/README.md +51 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/01-use-state.tsx +29 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/02-use-effect-deps.tsx +29 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/03-async-metadata.tsx +39 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/04-third-party-react.tsx +30 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/05-lambda-config.tsx +38 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/06-warnings-only.tsx +36 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/07-custom-hook.tsx +28 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/cases/08-mixed.tsx +41 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/expected.json +85 -0
- package/.agents/skills/remotion-to-hyperframes/assets/test-corpus/tier-4-escape-hatch/validate.sh +110 -0
- package/.agents/skills/remotion-to-hyperframes/references/api-map.md +142 -0
- package/.agents/skills/remotion-to-hyperframes/references/escape-hatch.md +115 -0
- package/.agents/skills/remotion-to-hyperframes/references/eval.md +140 -0
- package/.agents/skills/remotion-to-hyperframes/references/fonts.md +112 -0
- package/.agents/skills/remotion-to-hyperframes/references/limitations.md +136 -0
- package/.agents/skills/remotion-to-hyperframes/references/lottie.md +121 -0
- package/.agents/skills/remotion-to-hyperframes/references/media.md +149 -0
- package/.agents/skills/remotion-to-hyperframes/references/parameters.md +167 -0
- package/.agents/skills/remotion-to-hyperframes/references/sequencing.md +195 -0
- package/.agents/skills/remotion-to-hyperframes/references/timing.md +165 -0
- package/.agents/skills/remotion-to-hyperframes/references/transitions.md +114 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/.gitkeep +0 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/frame_strip.sh +107 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/lint_source.py +358 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/render_diff.sh +103 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/tests/fixtures/blocker.tsx +50 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/tests/fixtures/clean.tsx +46 -0
- package/.agents/skills/remotion-to-hyperframes/scripts/tests/smoke.sh +90 -0
- package/.agents/skills/seo-audit/SKILL.md +497 -0
- package/.agents/skills/seo-audit/evals/evals.json +136 -0
- package/.agents/skills/seo-audit/references/ai-writing-detection.md +200 -0
- package/.agents/skills/seo-audit/references/international-seo.md +230 -0
- package/README.md +4 -2
- package/SDK.md +64 -1
- package/dist/agents/coding.agent.d.ts +632 -0
- package/dist/agents/coding.agent.d.ts.map +1 -1
- package/dist/agents/coding.agent.js +11 -3
- package/dist/agents/coding.agent.js.map +1 -1
- package/dist/agents/developer-helper.agent.d.ts +704 -0
- package/dist/agents/developer-helper.agent.d.ts.map +1 -1
- package/dist/agents/developer-helper.agent.js +6 -0
- package/dist/agents/developer-helper.agent.js.map +1 -1
- package/dist/agents/manager.d.ts +1009 -4
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/manager.js +16 -5
- package/dist/agents/manager.js.map +1 -1
- package/dist/agents/security.agent.d.ts +157 -3
- package/dist/agents/security.agent.d.ts.map +1 -1
- package/dist/agents/security.agent.js +3 -0
- package/dist/agents/security.agent.js.map +1 -1
- package/dist/agents/swarm/main.js +1 -1
- package/dist/agents/swarm/main.js.map +1 -1
- package/dist/agents/swarm/registry.d.ts.map +1 -1
- package/dist/agents/swarm/registry.js +232 -26
- package/dist/agents/swarm/registry.js.map +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +32 -10
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/doctor.d.ts +14 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +91 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/format.d.ts +1 -0
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +68 -14
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/menu.d.ts.map +1 -1
- package/dist/cli/menu.js +102 -0
- package/dist/cli/menu.js.map +1 -1
- package/dist/cli/setup.d.ts +10 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +187 -3
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/update.d.ts +2 -0
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +89 -1
- package/dist/cli/update.js.map +1 -1
- package/dist/config/env.d.ts +12 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +19 -5
- package/dist/config/env.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -5
- package/dist/index.js.map +1 -1
- package/dist/jobs/trigger-orchestrator.d.ts +5 -1
- package/dist/jobs/trigger-orchestrator.d.ts.map +1 -1
- package/dist/jobs/trigger-orchestrator.js +29 -9
- package/dist/jobs/trigger-orchestrator.js.map +1 -1
- package/dist/jobs/trigger-router.d.ts.map +1 -1
- package/dist/jobs/trigger-router.js +3 -2
- package/dist/jobs/trigger-router.js.map +1 -1
- package/dist/memory/corporate-wiki.d.ts +15 -0
- package/dist/memory/corporate-wiki.d.ts.map +1 -0
- package/dist/memory/corporate-wiki.js +152 -0
- package/dist/memory/corporate-wiki.js.map +1 -0
- package/dist/observability/doctor.d.ts.map +1 -1
- package/dist/observability/doctor.js +12 -4
- package/dist/observability/doctor.js.map +1 -1
- package/dist/pre-init.d.ts +2 -0
- package/dist/pre-init.d.ts.map +1 -0
- package/dist/pre-init.js +3 -0
- package/dist/pre-init.js.map +1 -0
- package/dist/runtime/chat-bridge.d.ts.map +1 -1
- package/dist/runtime/chat-bridge.js +33 -2
- package/dist/runtime/chat-bridge.js.map +1 -1
- package/dist/runtime/swarm.d.ts +0 -1
- package/dist/runtime/swarm.d.ts.map +1 -1
- package/dist/runtime/swarm.js +26 -15
- package/dist/runtime/swarm.js.map +1 -1
- package/dist/safety/approvals.d.ts +2 -2
- package/dist/safety/approvals.d.ts.map +1 -1
- package/dist/safety/approvals.js +47 -1
- package/dist/safety/approvals.js.map +1 -1
- package/dist/safety/redaction.d.ts.map +1 -1
- package/dist/safety/redaction.js +10 -0
- package/dist/safety/redaction.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/cloud.tool.d.ts +394 -0
- package/dist/tools/cloud.tool.d.ts.map +1 -0
- package/dist/tools/cloud.tool.js +784 -0
- package/dist/tools/cloud.tool.js.map +1 -0
- package/dist/tools/computer-use.tool.d.ts +6 -6
- package/dist/tools/corporate-wiki.tool.d.ts +22 -0
- package/dist/tools/corporate-wiki.tool.d.ts.map +1 -0
- package/dist/tools/corporate-wiki.tool.js +39 -0
- package/dist/tools/corporate-wiki.tool.js.map +1 -0
- package/dist/tools/desktop.tool.d.ts +96 -0
- package/dist/tools/desktop.tool.d.ts.map +1 -1
- package/dist/tools/desktop.tool.js +439 -0
- package/dist/tools/desktop.tool.js.map +1 -1
- package/dist/tools/devops.tool.d.ts +162 -0
- package/dist/tools/devops.tool.d.ts.map +1 -0
- package/dist/tools/devops.tool.js +377 -0
- package/dist/tools/devops.tool.js.map +1 -0
- package/dist/tools/multimedia.tool.d.ts +126 -0
- package/dist/tools/multimedia.tool.d.ts.map +1 -0
- package/dist/tools/multimedia.tool.js +533 -0
- package/dist/tools/multimedia.tool.js.map +1 -0
- package/dist/tools/osint.tool.d.ts +6 -6
- package/dist/tools/sandbox-dev.tool.d.ts +15 -0
- package/dist/tools/sandbox-dev.tool.d.ts.map +1 -0
- package/dist/tools/sandbox-dev.tool.js +139 -0
- package/dist/tools/sandbox-dev.tool.js.map +1 -0
- package/dist/tools/setup-assistant.tool.d.ts +1 -1
- package/dist/tools/shell.tool.d.ts +82 -0
- package/dist/tools/shell.tool.d.ts.map +1 -1
- package/dist/tools/shell.tool.js +192 -1
- package/dist/tools/shell.tool.js.map +1 -1
- package/dist/tools/swarm-ops.tool.d.ts +14 -0
- package/dist/tools/swarm-ops.tool.d.ts.map +1 -1
- package/dist/tools/swarm-ops.tool.js +44 -0
- package/dist/tools/swarm-ops.tool.js.map +1 -1
- package/dist/tools/sysops.tool.d.ts +157 -0
- package/dist/tools/sysops.tool.d.ts.map +1 -0
- package/dist/tools/sysops.tool.js +643 -0
- package/dist/tools/sysops.tool.js.map +1 -0
- package/dist/voice/cascade.d.ts +1 -0
- package/dist/voice/cascade.d.ts.map +1 -1
- package/dist/voice/cascade.js +16 -1
- package/dist/voice/cascade.js.map +1 -1
- package/dist/voice/deepgram.d.ts.map +1 -1
- package/dist/voice/deepgram.js +34 -2
- package/dist/voice/deepgram.js.map +1 -1
- package/dist/voice/terminal.d.ts +1 -0
- package/dist/voice/terminal.d.ts.map +1 -1
- package/dist/voice/terminal.js +28 -0
- package/dist/voice/terminal.js.map +1 -1
- package/dist/voice/types.d.ts +2 -0
- package/dist/voice/types.d.ts.map +1 -1
- package/package.json +9 -1
- package/scripts/release-github.mjs +23 -18
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# prompt-engineering-patterns — detailed patterns and worked examples
|
|
2
|
+
|
|
3
|
+
## Key Patterns
|
|
4
|
+
|
|
5
|
+
### Pattern 1: Structured Output with Pydantic
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from anthropic import Anthropic
|
|
9
|
+
from pydantic import BaseModel, Field
|
|
10
|
+
from typing import Literal
|
|
11
|
+
import json
|
|
12
|
+
|
|
13
|
+
class SentimentAnalysis(BaseModel):
|
|
14
|
+
sentiment: Literal["positive", "negative", "neutral"]
|
|
15
|
+
confidence: float = Field(ge=0, le=1)
|
|
16
|
+
key_phrases: list[str]
|
|
17
|
+
reasoning: str
|
|
18
|
+
|
|
19
|
+
async def analyze_sentiment(text: str) -> SentimentAnalysis:
|
|
20
|
+
"""Analyze sentiment with structured output."""
|
|
21
|
+
client = Anthropic()
|
|
22
|
+
|
|
23
|
+
message = client.messages.create(
|
|
24
|
+
model="claude-sonnet-4-6",
|
|
25
|
+
max_tokens=500,
|
|
26
|
+
messages=[{
|
|
27
|
+
"role": "user",
|
|
28
|
+
"content": f"""Analyze the sentiment of this text.
|
|
29
|
+
|
|
30
|
+
Text: {text}
|
|
31
|
+
|
|
32
|
+
Respond with JSON matching this schema:
|
|
33
|
+
{{
|
|
34
|
+
"sentiment": "positive" | "negative" | "neutral",
|
|
35
|
+
"confidence": 0.0-1.0,
|
|
36
|
+
"key_phrases": ["phrase1", "phrase2"],
|
|
37
|
+
"reasoning": "brief explanation"
|
|
38
|
+
}}"""
|
|
39
|
+
}]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return SentimentAnalysis(**json.loads(message.content[0].text))
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Pattern 2: Chain-of-Thought with Self-Verification
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from langchain_core.prompts import ChatPromptTemplate
|
|
49
|
+
|
|
50
|
+
cot_prompt = ChatPromptTemplate.from_template("""
|
|
51
|
+
Solve this problem step by step.
|
|
52
|
+
|
|
53
|
+
Problem: {problem}
|
|
54
|
+
|
|
55
|
+
Instructions:
|
|
56
|
+
1. Break down the problem into clear steps
|
|
57
|
+
2. Work through each step showing your reasoning
|
|
58
|
+
3. State your final answer
|
|
59
|
+
4. Verify your answer by checking it against the original problem
|
|
60
|
+
|
|
61
|
+
Format your response as:
|
|
62
|
+
## Steps
|
|
63
|
+
[Your step-by-step reasoning]
|
|
64
|
+
|
|
65
|
+
## Answer
|
|
66
|
+
[Your final answer]
|
|
67
|
+
|
|
68
|
+
## Verification
|
|
69
|
+
[Check that your answer is correct]
|
|
70
|
+
""")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Pattern 3: Few-Shot with Dynamic Example Selection
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from langchain_voyageai import VoyageAIEmbeddings
|
|
77
|
+
from langchain_core.example_selectors import SemanticSimilarityExampleSelector
|
|
78
|
+
from langchain_chroma import Chroma
|
|
79
|
+
|
|
80
|
+
# Create example selector with semantic similarity
|
|
81
|
+
example_selector = SemanticSimilarityExampleSelector.from_examples(
|
|
82
|
+
examples=[
|
|
83
|
+
{"input": "How do I reset my password?", "output": "Go to Settings > Security > Reset Password"},
|
|
84
|
+
{"input": "Where can I see my order history?", "output": "Navigate to Account > Orders"},
|
|
85
|
+
{"input": "How do I contact support?", "output": "Click Help > Contact Us or email support@example.com"},
|
|
86
|
+
],
|
|
87
|
+
embeddings=VoyageAIEmbeddings(model="voyage-3-large"),
|
|
88
|
+
vectorstore_cls=Chroma,
|
|
89
|
+
k=2 # Select 2 most similar examples
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
async def get_few_shot_prompt(query: str) -> str:
|
|
93
|
+
"""Build prompt with dynamically selected examples."""
|
|
94
|
+
examples = await example_selector.aselect_examples({"input": query})
|
|
95
|
+
|
|
96
|
+
examples_text = "\n".join(
|
|
97
|
+
f"User: {ex['input']}\nAssistant: {ex['output']}"
|
|
98
|
+
for ex in examples
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return f"""You are a helpful customer support assistant.
|
|
102
|
+
|
|
103
|
+
Here are some example interactions:
|
|
104
|
+
{examples_text}
|
|
105
|
+
|
|
106
|
+
Now respond to this query:
|
|
107
|
+
User: {query}
|
|
108
|
+
Assistant:"""
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Pattern 4: Progressive Disclosure
|
|
112
|
+
|
|
113
|
+
Start with simple prompts, add complexity only when needed:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
PROMPT_LEVELS = {
|
|
117
|
+
# Level 1: Direct instruction
|
|
118
|
+
"simple": "Summarize this article: {text}",
|
|
119
|
+
|
|
120
|
+
# Level 2: Add constraints
|
|
121
|
+
"constrained": """Summarize this article in 3 bullet points, focusing on:
|
|
122
|
+
- Key findings
|
|
123
|
+
- Main conclusions
|
|
124
|
+
- Practical implications
|
|
125
|
+
|
|
126
|
+
Article: {text}""",
|
|
127
|
+
|
|
128
|
+
# Level 3: Add reasoning
|
|
129
|
+
"reasoning": """Read this article carefully.
|
|
130
|
+
1. First, identify the main topic and thesis
|
|
131
|
+
2. Then, extract the key supporting points
|
|
132
|
+
3. Finally, summarize in 3 bullet points
|
|
133
|
+
|
|
134
|
+
Article: {text}
|
|
135
|
+
|
|
136
|
+
Summary:""",
|
|
137
|
+
|
|
138
|
+
# Level 4: Add examples
|
|
139
|
+
"few_shot": """Read articles and provide concise summaries.
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
Article: "New research shows that regular exercise can reduce anxiety by up to 40%..."
|
|
143
|
+
Summary:
|
|
144
|
+
• Regular exercise reduces anxiety by up to 40%
|
|
145
|
+
• 30 minutes of moderate activity 3x/week is sufficient
|
|
146
|
+
• Benefits appear within 2 weeks of starting
|
|
147
|
+
|
|
148
|
+
Now summarize this article:
|
|
149
|
+
Article: {text}
|
|
150
|
+
|
|
151
|
+
Summary:"""
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Pattern 5: Error Recovery and Fallback
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from pydantic import BaseModel, ValidationError
|
|
159
|
+
import json
|
|
160
|
+
|
|
161
|
+
class ResponseWithConfidence(BaseModel):
|
|
162
|
+
answer: str
|
|
163
|
+
confidence: float
|
|
164
|
+
sources: list[str]
|
|
165
|
+
alternative_interpretations: list[str] = []
|
|
166
|
+
|
|
167
|
+
ERROR_RECOVERY_PROMPT = """
|
|
168
|
+
Answer the question based on the context provided.
|
|
169
|
+
|
|
170
|
+
Context: {context}
|
|
171
|
+
Question: {question}
|
|
172
|
+
|
|
173
|
+
Instructions:
|
|
174
|
+
1. If you can answer confidently (>0.8), provide a direct answer
|
|
175
|
+
2. If you're somewhat confident (0.5-0.8), provide your best answer with caveats
|
|
176
|
+
3. If you're uncertain (<0.5), explain what information is missing
|
|
177
|
+
4. Always provide alternative interpretations if the question is ambiguous
|
|
178
|
+
|
|
179
|
+
Respond in JSON:
|
|
180
|
+
{{
|
|
181
|
+
"answer": "your answer or 'I cannot determine this from the context'",
|
|
182
|
+
"confidence": 0.0-1.0,
|
|
183
|
+
"sources": ["relevant context excerpts"],
|
|
184
|
+
"alternative_interpretations": ["if question is ambiguous"]
|
|
185
|
+
}}
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
async def answer_with_fallback(
|
|
189
|
+
context: str,
|
|
190
|
+
question: str,
|
|
191
|
+
llm
|
|
192
|
+
) -> ResponseWithConfidence:
|
|
193
|
+
"""Answer with error recovery and fallback."""
|
|
194
|
+
prompt = ERROR_RECOVERY_PROMPT.format(context=context, question=question)
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
response = await llm.ainvoke(prompt)
|
|
198
|
+
return ResponseWithConfidence(**json.loads(response.content))
|
|
199
|
+
except (json.JSONDecodeError, ValidationError) as e:
|
|
200
|
+
# Fallback: try to extract answer without structure
|
|
201
|
+
simple_prompt = f"Based on: {context}\n\nAnswer: {question}"
|
|
202
|
+
simple_response = await llm.ainvoke(simple_prompt)
|
|
203
|
+
return ResponseWithConfidence(
|
|
204
|
+
answer=simple_response.content,
|
|
205
|
+
confidence=0.5,
|
|
206
|
+
sources=["fallback extraction"],
|
|
207
|
+
alternative_interpretations=[]
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Pattern 6: Role-Based System Prompts
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
SYSTEM_PROMPTS = {
|
|
215
|
+
"analyst": """You are a senior data analyst with expertise in SQL, Python, and business intelligence.
|
|
216
|
+
|
|
217
|
+
Your responsibilities:
|
|
218
|
+
- Write efficient, well-documented queries
|
|
219
|
+
- Explain your analysis methodology
|
|
220
|
+
- Highlight key insights and recommendations
|
|
221
|
+
- Flag any data quality concerns
|
|
222
|
+
|
|
223
|
+
Communication style:
|
|
224
|
+
- Be precise and technical when discussing methodology
|
|
225
|
+
- Translate technical findings into business impact
|
|
226
|
+
- Use clear visualizations when helpful""",
|
|
227
|
+
|
|
228
|
+
"assistant": """You are a helpful AI assistant focused on accuracy and clarity.
|
|
229
|
+
|
|
230
|
+
Core principles:
|
|
231
|
+
- Always cite sources when making factual claims
|
|
232
|
+
- Acknowledge uncertainty rather than guessing
|
|
233
|
+
- Ask clarifying questions when the request is ambiguous
|
|
234
|
+
- Provide step-by-step explanations for complex topics
|
|
235
|
+
|
|
236
|
+
Constraints:
|
|
237
|
+
- Do not provide medical, legal, or financial advice
|
|
238
|
+
- Redirect harmful requests appropriately
|
|
239
|
+
- Protect user privacy""",
|
|
240
|
+
|
|
241
|
+
"code_reviewer": """You are a senior software engineer conducting code reviews.
|
|
242
|
+
|
|
243
|
+
Review criteria:
|
|
244
|
+
- Correctness: Does the code work as intended?
|
|
245
|
+
- Security: Are there any vulnerabilities?
|
|
246
|
+
- Performance: Are there efficiency concerns?
|
|
247
|
+
- Maintainability: Is the code readable and well-structured?
|
|
248
|
+
- Best practices: Does it follow language idioms?
|
|
249
|
+
|
|
250
|
+
Output format:
|
|
251
|
+
1. Summary assessment (approve/request changes)
|
|
252
|
+
2. Critical issues (must fix)
|
|
253
|
+
3. Suggestions (nice to have)
|
|
254
|
+
4. Positive feedback (what's done well)"""
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Integration Patterns
|
|
259
|
+
|
|
260
|
+
### With RAG Systems
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
RAG_PROMPT = """You are a knowledgeable assistant that answers questions based on provided context.
|
|
264
|
+
|
|
265
|
+
Context (retrieved from knowledge base):
|
|
266
|
+
{context}
|
|
267
|
+
|
|
268
|
+
Instructions:
|
|
269
|
+
1. Answer ONLY based on the provided context
|
|
270
|
+
2. If the context doesn't contain the answer, say "I don't have information about that in my knowledge base"
|
|
271
|
+
3. Cite specific passages using [1], [2] notation
|
|
272
|
+
4. If the question is ambiguous, ask for clarification
|
|
273
|
+
|
|
274
|
+
Question: {question}
|
|
275
|
+
|
|
276
|
+
Answer:"""
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### With Validation and Verification
|
|
280
|
+
|
|
281
|
+
```python
|
|
282
|
+
VALIDATED_PROMPT = """Complete the following task:
|
|
283
|
+
|
|
284
|
+
Task: {task}
|
|
285
|
+
|
|
286
|
+
After generating your response, verify it meets ALL these criteria:
|
|
287
|
+
✓ Directly addresses the original request
|
|
288
|
+
✓ Contains no factual errors
|
|
289
|
+
✓ Is appropriately detailed (not too brief, not too verbose)
|
|
290
|
+
✓ Uses proper formatting
|
|
291
|
+
✓ Is safe and appropriate
|
|
292
|
+
|
|
293
|
+
If verification fails on any criterion, revise before responding.
|
|
294
|
+
|
|
295
|
+
Response:"""
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Performance Optimization
|
|
299
|
+
|
|
300
|
+
### Token Efficiency
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
# Before: Verbose prompt (150+ tokens)
|
|
304
|
+
verbose_prompt = """
|
|
305
|
+
I would like you to please take the following text and provide me with a comprehensive
|
|
306
|
+
summary of the main points. The summary should capture the key ideas and important details
|
|
307
|
+
while being concise and easy to understand.
|
|
308
|
+
"""
|
|
309
|
+
|
|
310
|
+
# After: Concise prompt (30 tokens)
|
|
311
|
+
concise_prompt = """Summarize the key points concisely:
|
|
312
|
+
|
|
313
|
+
{text}
|
|
314
|
+
|
|
315
|
+
Summary:"""
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Caching Common Prefixes
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
from anthropic import Anthropic
|
|
322
|
+
|
|
323
|
+
client = Anthropic()
|
|
324
|
+
|
|
325
|
+
# Use prompt caching for repeated system prompts
|
|
326
|
+
response = client.messages.create(
|
|
327
|
+
model="claude-sonnet-4-6",
|
|
328
|
+
max_tokens=1000,
|
|
329
|
+
system=[
|
|
330
|
+
{
|
|
331
|
+
"type": "text",
|
|
332
|
+
"text": LONG_SYSTEM_PROMPT,
|
|
333
|
+
"cache_control": {"type": "ephemeral"}
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
messages=[{"role": "user", "content": user_query}]
|
|
337
|
+
)
|
|
338
|
+
```
|