Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计提醒

dspy-promptingdspy 提示

Agent Skill

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。它适合让 Agent 规范任务边界、统一输出格式、拆分操作步骤或优化提示词可复用性。使用时需要保留真实业务约束,不要把示例当硬规则;涉及自动执行、外部工具或高风险操作时,应在提示词中明确确认步骤、权限边界和失败处理方式。

总安装

979

周安装

40

GitHub Stars

4

下载量

314
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dspy-prompting(dspy 提示)
来源仓库:https://github.com/eyadsibai/ltk
仓库路径:skills/dspy-prompting
安装命令:
npx skills add https://github.com/eyadsibai/ltk --skill dspy-prompting
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/eyadsibai/ltk --skill dspy-prompting

简介

用于辅助提示词、系统指令与 Agent 行为模板的规范化整理与复用。

  • 它帮助定义任务边界、统一输出格式并拆分操作步骤以提高可维护性。
  • 使用时需保留真实业务约束,避免将示例误作硬性规则执行。
  • 涉及自动执行或外部工具调用时应显式声明权限边界与失败处理机制。
  • dspy-prompting 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

DSPy Declarative Language Model Programming

Build AI systems with automatic prompt optimization from Stanford NLP.

When to Use

  • Building complex AI systems with multiple components
  • Programming LMs declaratively instead of manual prompting
  • Optimizing prompts automatically using data-driven methods
  • Creating modular AI pipelines that are maintainable
  • Building RAG systems, agents, or classifiers with better reliability

Quick Start

pip install dspy

Basic Question Answering

import dspy

lm = dspy.Claude(model="claude-sonnet-4-5-20250929")
dspy.settings.configure(lm=lm)

# Define a signature (input -> output)
class QA(dspy.Signature):
    """Answer questions with short factual answers."""
    question = dspy.InputField()
    answer = dspy.OutputField(desc="often between 1 and 5 words")

qa = dspy.Predict(QA)
response = qa(question="What is the capital of France?")
print(response.answer)  # "Paris"

Chain of Thought Reasoning

class MathProblem(dspy.Signature):
    """Solve math word problems."""
    problem = dspy.InputField()
    answer = dspy.OutputField(desc="numerical answer")

cot = dspy.ChainOfThought(MathProblem)
response = cot(problem="If John has 5 apples and gives 2 to Mary, how many does he have?")
print(response.rationale)  # Shows reasoning steps
print(response.answer)     # "3"

Core Modules

ModuleUse Case
dspy.PredictBasic prediction
dspy.ChainOfThoughtReasoning with steps
dspy.ReActAgent-like with tools
dspy.ProgramOfThoughtCode generation for reasoning

ReAct Agent

from dspy.predict import ReAct

class SearchQA(dspy.Signature):
    """Answer questions using search."""
    question = dspy.InputField()
    answer = dspy.OutputField()

def search_tool(query: str) -> str:
    """Search Wikipedia."""
    return results

react = ReAct(SearchQA, tools=[search_tool])
result = react(question="When was Python created?")

Automatic Optimization

BootstrapFewShot

from dspy.teleprompt import BootstrapFewShot

trainset = [
    dspy.Example(question="What is 2+2?", answer="4").with_inputs("question"),
    dspy.Example(question="What is 3+5?", answer="8").with_inputs("question"),
]

def validate_answer(example, pred, trace=None):
    return example.answer == pred.answer

optimizer = BootstrapFewShot(metric=validate_answer, max_bootstrapped_demos=3)
optimized_qa = optimizer.compile(qa, trainset=trainset)

MIPRO Optimizer

from dspy.teleprompt import MIPRO

optimizer = MIPRO(
    metric=validate_answer,
    num_candidates=10,
    init_temperature=1.0
)

optimized_cot = optimizer.compile(cot, trainset=trainset, num_trials=100)

Multi-Stage Pipeline

class MultiHopQA(dspy.Module):
    def __init__(self):
        super().__init__()
        self.retrieve = dspy.Retrieve(k=3)
        self.generate_query = dspy.ChainOfThought("question -> search_query")
        self.generate_answer = dspy.ChainOfThought("context, question -> answer")

    def forward(self, question):
        search_query = self.generate_query(question=question).search_query
        passages = self.retrieve(search_query).passages
        context = "\n".join(passages)
        answer = self.generate_answer(context=context, question=question).answer
        return dspy.Prediction(answer=answer, context=context)

Structured Output

from pydantic import BaseModel, Field

class PersonInfo(BaseModel):
    name: str = Field(description="Full name")
    age: int = Field(description="Age in years")
    occupation: str = Field(description="Current job")

class ExtractPerson(dspy.Signature):
    """Extract person information from text."""
    text = dspy.InputField()
    person: PersonInfo = dspy.OutputField()

extractor = dspy.TypedPredictor(ExtractPerson)
result = extractor(text="John Doe is a 35-year-old software engineer.")

LLM Providers

# Anthropic
lm = dspy.Claude(model="claude-sonnet-4-5-20250929")

# OpenAI
lm = dspy.OpenAI(model="gpt-4")

# Local (Ollama)
lm = dspy.OllamaLocal(model="llama3.1", base_url="http://localhost:11434")

dspy.settings.configure(lm=lm)

Save and Load

# Save optimized module
optimized_qa.save("models/qa_v1.json")

# Load later
loaded_qa = dspy.ChainOfThought("question -> answer")
loaded_qa.load("models/qa_v1.json")

vs Alternatives

FeatureDSPyLangChainManual
Prompt EngineeringAutomaticManualManual
OptimizationData-drivenNoneTrial & error
ModularityHighMediumLow
Learning CurveMedium-HighMediumLow

Choose DSPy when:

  • You have training data or can generate it
  • Need systematic prompt improvement
  • Building complex multi-stage systems

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.25%
按下载量换算114

Claude

31.6%
按下载量换算99

Cursor

19.21%
按下载量换算60

Gemini CLI

9.82%
按下载量换算31

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills