Install
npm install @ts-dspy/core @ts-dspy/anthropic
Requirements
Node.js 22 or newer. Ships ESM and CommonJS builds with types for both.
Write it
import { Signature, InputField, OutputField, Predict, configure } from '@ts-dspy/core'
import { AnthropicLM } from '@ts-dspy/anthropic'
configure({ lm: new AnthropicLM({ apiKey: process.env.ANTHROPIC_API_KEY }) })
class RateAnswer extends Signature {
@InputField({ description: 'the question' })
question!: string
@OutputField({ description: 'confidence 0-1', type: 'number' })
score!: number
}
const { score } = await new Predict(RateAnswer).forward({ question })
// score is a number, or this threw