
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
DSPy.ts - Declarative Self-Learning TypeScript: A framework for compositional LM pipelines with self-improving prompt strategies.
DSPy.ts helps you build powerful AI applications right in your web browser. It's based on Stanford's DSPy framework but made specifically for JavaScript and TypeScript developers. Unlike traditional AI frameworks that require expensive servers and complex infrastructure, DSPy.ts lets you create and run sophisticated AI models directly in your users' browsers. This means you can build everything from smart chatbots to image recognition systems that work entirely on your users' devices, making your AI applications faster, cheaper, and more private.
Here's what makes it special:
created by rUv, cause he could.
npm install dspy.ts
DSPy.ts stands for Declarative Self-improving TypeScript. It makes building AI apps easier by:
Key Benefits:
DSPy.ts seamlessly integrates with:
Build sophisticated AI agents that can:
Example of an agentic system:
// Create a research agent with tools
const researcher = new ReActModule({
tools: [
new WebSearch(),
new PDFReader(),
new Summarizer(),
new CitationManager()
],
strategy: 'ReAct',
optimization: {
metric: accuracyMetric,
method: 'BootstrapFewShot'
}
});
// The agent can:
// 1. Search for relevant papers
// 2. Read and understand PDFs
// 3. Generate summaries
// 4. Manage citations
// 5. Learn from feedback
npm install dspy.ts onnxruntime-web js-pytorch
import { PredictModule, configureLM, ONNXModel } from 'dspy.ts';
// Configure local inference with ONNX Runtime
const model = new ONNXModel({
modelPath: 'path/to/model.onnx',
executionProvider: 'wasm'
});
configureLM(model);
// Create a self-improving module
class MathSolver extends PredictModule {
constructor() {
super({
name: 'MathSolver',
signature: {
inputs: [{ name: 'question', type: 'string' }],
outputs: [
{ name: 'reasoning', type: 'string' },
{ name: 'answer', type: 'number' }
]
},
strategy: 'ChainOfThought'
});
}
}
// Use and optimize the module
const solver = new MathSolver();
const optimizer = new BootstrapFewShot(exactMatchMetric);
const optimizedSolver = await optimizer.compile(solver, trainset);
Build AI systems as composable TypeScript modules:
// Question answering with context
const qa = new Pipeline([
new ContextRetriever(),
new QuestionAnswerer(),
new ResponseValidator()
]);
Automatically optimize your systems:
// Optimize with few-shot learning
const optimizer = new BootstrapFewShot(metric);
const betterQA = await optimizer.compile(qa, examples);
Choose your execution environment:
// Local inference with ONNX
const localLM = new ONNXModel({
modelPath: 'model.onnx',
executionProvider: 'wasm'
});
// Cloud fallback
const cloudLM = new OpenRouterLM(API_KEY);
Task Type | Model | Local (ONNX) | Cloud API | Memory Usage | Optimization Gain |
---|---|---|---|---|---|
QA (RAG) | BERT | 80-150ms | 500-800ms | 150-300MB | +15-25% accuracy |
Classification | DistilBERT | 30-50ms | 300-500ms | 80-120MB | +10-20% accuracy |
Agents | GPT-2 | 100-200ms | 600-1000ms | 200-400MB | +20-30% success |
Generation | T5 | 150-250ms | 700-1200ms | 250-500MB | +15-25% quality |
Benchmarks run on standard hardware (4-core CPU, 16GB RAM). Local inference uses ONNX Runtime with WASM backend.
// Intelligent support agent
const supportAgent = new Pipeline([
new IntentClassifier(),
new ContextRetriever({ source: 'knowledge-base' }),
new ResponseGenerator({ style: 'professional' }),
new SentimentValidator()
]);
// Optimize for your metrics
const optimizer = new BootstrapFewShot(satisfactionMetric);
const betterAgent = await optimizer.compile(supportAgent, examples);
// Automated document analysis
const docProcessor = new Pipeline([
new DocumentParser(),
new EntityExtractor(),
new RelationshipMapper(),
new SummaryGenerator()
]);
// Intelligent coding assistant
const codeAssistant = new ReActModule({
tools: [
new CodeAnalyzer(),
new TestGenerator(),
new DocumentationWriter()
],
strategy: 'ReAct'
});
// OpenAPI spec generator
const apiGenerator = new Pipeline([
new SchemaAnalyzer(),
new EndpointDesigner(),
new DocumentationBuilder()
]);
// Cross-platform content generator
const contentEngine = new Pipeline([
new TopicExpander(),
new ContentGenerator({
variants: ['blog', 'social', 'email']
}),
new ToneOptimizer(),
new SEOEnhancer()
]);
// Market intelligence system
const marketAnalyzer = new Pipeline([
new DataCollector({ sources: ['news', 'social', 'reports'] }),
new TrendAnalyzer(),
new InsightGenerator(),
new RecommendationEngine()
]);
// Research assistant
const researchAssistant = new ReActModule({
tools: [
new PaperSearch(),
new CitationAnalyzer(),
new SummaryGenerator(),
new BibtexFormatter()
],
strategy: 'ChainOfThought'
});
// Automated data analysis
const dataAnalyst = new Pipeline([
new DataCleaner(),
new StatisticalAnalyzer(),
new VisualizationGenerator(),
new InsightExtractor()
]);
We welcome contributions! See our Contributing Guide for details.
DSPy.ts is MIT licensed. See the LICENSE file for details.
DSPy.ts is inspired by Stanford's DSPy project, bringing its powerful concepts of declarative, self-improving AI systems to the JavaScript ecosystem. We extend our gratitude to the Stanford NLP group and the DSPy community.
FAQs
DSPy.ts - Declarative Self-Learning TypeScript: A framework for compositional LM pipelines with self-improving prompt strategies.
The npm package dspy.ts receives a total of 4 weekly downloads. As such, dspy.ts popularity was classified as not popular.
We found that dspy.ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.