Agent skill
ai-prompting-structured-output
Sub-skill of ai-prompting: Structured Output (+2).
Install this agent skill to your Project
npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/_archive/ai/prompting/ai-prompting/structured-output
SKILL.md
Structured Output (+2)
Structured Output
from pydantic import BaseModel
class OutputSchema(BaseModel):
summary: str
key_points: list[str]
confidence: float
# Force structured output
response = llm.complete(
prompt,
response_format={"type": "json_object"},
schema=OutputSchema.schema()
)
Error Handling and Fallbacks
def robust_llm_call(prompt, fallback_response=None):
try:
response = llm.complete(prompt, timeout=30)
if not validate_response(response):
raise ValueError("Invalid response format")
return response
except RateLimitError:
time.sleep(60)
return robust_llm_call(prompt, fallback_response)
except Exception as e:
logger.error(f"LLM call failed: {e}")
return fallback_response
Caching and Cost Optimization
import hashlib
from functools import lru_cache
@lru_cache(maxsize=1000)
def cached_embedding(text: str) -> list[float]:
return embedding_model.embed(text)
def cache_key(prompt, model, temperature):
content = f"{prompt}|{model}|{temperature}"
return hashlib.sha256(content.encode()).hexdigest()
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
gsd-complete-milestone
Archive completed milestone and prepare for next version
gsd-reapply-patches
Reapply local modifications after a GSD update
gsd-verify-work
Validate built features through conversational UAT
gsd-thread
Manage persistent context threads for cross-session work
clinical-trial-protocol
Generate clinical trial protocols for medical devices or drugs through a modular, waypoint-based architecture with research-only and full protocol modes.
single-cell-rna-qc
Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations.
Didn't find tool you were looking for?