omidzamani/dspy-skills

dspy-adapters-multimodal

Use for DSPy adapter selection, JSONAdapter, XMLAdapter, ChatAdapter, native function calling, structured outputs, and multimodal inputs like dspy.Image or dspy.Audio.

First seen Jun 12, 2026

Installation

$ npx skills add omidzamani/dspy-skills --skill dspy-adapters-multimodal

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from omidzamani/dspy-skills · top by installs.

npx skills add omidzamani/dspy-skills

Browse all from omidzamani/dspy-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 121
License LICENSE
Default branch master
Open issues 1
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0.0
Allowed toolsRead, Write, Glob, Grep

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,456 B
  • docs SUMMARY.md 199 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 7 installs

SKILL.md

DSPy Adapters and Multimodal I/O

Goal

Choose an adapter deliberately and model image, audio, and file inputs with DSPy's typed primitives.

Adapter Selection

Adapter Use it for
dspy.ChatAdapter() Default, human-readable field markers, broad model compatibility
dspy.JSONAdapter() Structured JSON output and native function calling where supported
dspy.XMLAdapter() XML-tagged fields when XML is easier for the target LM to follow
dspy.TwoStepAdapter() A separate extraction pass when parsing needs extra help

Configure globally or for a limited scope:

import dspy

dspy.configure(
    lm=dspy.LM("openai/gpt-4o-mini"),
    adapter=dspy.JSONAdapter(),
)

with dspy.context(adapter=dspy.XMLAdapter()):
    result = dspy.Predict("question -> answer")(question="What is DSPy?")

Native Function Calling

JSONAdapter enables native function calling by default. ChatAdapter keeps text parsing by default. Override either behavior explicitly:

chat_native = dspy.ChatAdapter(use_native_function_calling=True)
json_manual = dspy.JSONAdapter(use_native_function_calling=False)

DSPy falls back to manual parsing when the configured LM does not support native function calling.

Image Inputs

class DescribeImage(dspy.Signature):
    image: dspy.Image = dspy.InputField()
    description: str = dspy.OutputField()

describe = dspy.Predict(DescribeImage)
result = describe(image=dspy.Image("./diagram.png"))

Pass a local path, HTTP URL, bytes, PIL image, or existing data URI directly to dspy.Image(...).

Audio and File Inputs

class SummarizeAudio(dspy.Signature):
    audio: dspy.Audio = dspy.InputField()
    summary: str = dspy.OutputField()

audio = dspy.Audio.from_file("./meeting.wav")
summary = dspy.Predict(SummarizeAudio)(audio=audio)
class SummarizeFile(dspy.Signature):
    file: dspy.File = dspy.InputField()
    summary: str = dspy.OutputField()

document = dspy.File.from_path("./research.pdf")
summary = dspy.Predict(SummarizeFile)(file=document)

Provider capabilities vary. Verify that the selected model accepts the media type before deployment.

Best Practices

  1. Start with ChatAdapter; switch only for a measured reason.
  2. Use typed signatures for structured output.
  3. Test adapter behavior against the exact production model.
  4. Avoid deprecated Image.fromfile() and Image.fromurl() helpers; call dspy.Image(...).
  5. Keep local file handling and uploaded file IDs within provider policy.

Related Skills

  • Design signatures: [dspy-signature-designer](../dspy-signature-designer/SKILL.md)
  • Build tool agents: [dspy-react-agent-builder](../dspy-react-agent-builder/SKILL.md)

Official Documentation