Back to list
Qredence

dspy-configuration

by Qredence

1🍴 1📅 Jan 23, 2026

SKILL.md


name: dspy-configuration description: DSPy configuration, LM setup, caching, and version management. Use when configuring language models, enabling caching, managing dependencies, or setting up multi-provider configurations.

DSPy Configuration

DSPy configuration, LM setup, caching, and version management.

Quick Start

Configure LM Globally

import dspy

# Configure LM globally
dspy.configure(lm=dspy.LM('openai/gpt-4o-mini'))
response = qa(question="How many floors are in the castle?")
print('GPT-4o-mini:', response.answer)

Switch LM Locally

# Change LM within a context block
with dspy.context(lm=dspy.LM('openai/gpt-3.5-turbo')):
    response = qa(question="How many floors are in the castle?")
    print('GPT-3.5-turbo:', response.answer)

Enable Caching

# Configure caching
dspy.configure_cache(
    enable_disk_cache=True,
    enable_memory_cache=True,
)

Configure Responses API

dspy.configure(
    lm=dspy.LM(
        "openai/gpt-5-mini",
        model_type="responses",
        temperature=1.0,
        max_tokens=16000,
    ),
)

When to Use This Skill

Use this skill when:

  • Configuring language models for DSPy
  • Setting up LM switching (global/local)
  • Enabling and customizing caching
  • Configuring multi-provider LMs
  • Managing version compatibility
  • Setting up Responses API for advanced models

Core Concepts

LM Configuration

Configure which language models to use and how to switch between them.

Key features:

  • Global configuration: dspy.configure(lm=...) for entire session
  • Local overrides: dspy.context(lm=...) for code blocks
  • Multi-provider: Support for OpenAI, Anthropic, Together AI, and more
  • Responses API: Enable advanced model features

See: references/lm-config.md for:

  • LM configuration patterns
  • Multi-provider setup
  • Responses API configuration
  • Best practices

Caching

Manage cache behavior to improve performance and control costs.

Cache layers:

  • In-memory cache: Fast access using cachetools.LRUCache
  • On-disk cache: Persistent storage using diskcache.FanoutCache
  • Server-side cache: Managed by LLM provider (OpenAI, Anthropic)

See: references/caching.md for:

  • Cache architecture details
  • Custom cache key implementation
  • Cache debugging techniques
  • Configuration options

Version Management

Track and manage dependency versions to ensure compatibility.

Key features:

  • Automatic versioning: save() captures dependency versions
  • Version checking: Alerts on version mismatches
  • Compatibility: Prevents issues from outdated dependencies

See: references/versioning.md for:

  • Dependency versioning patterns
  • Version mismatch detection
  • Compatibility best practices

Scripts

The scripts/ directory provides reusable tools:

  • compile-dspy.py: Compile DSPy modules with proper caching
  • clear-cache.py: Clear DSPy cache safely

Progressive Disclosure

This skill uses progressive disclosure:

  1. SKILL.md (this file): Quick reference and navigation
  2. references/: Detailed technical docs loaded as needed

Load reference files only when you need detailed information on a specific topic.

  • dspy-basics: Signature design, basic modules, program composition
  • dspy-optimization: Teleprompters, metrics, optimization workflows
  • dspy-advanced: ReAct agents, tool calling, output refinement

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon