@ax-llm/ax 19.0.39 → 19.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # Ax: Build Reliable AI Apps in TypeScript
2
+
3
+ **Stop wrestling with prompts. Start shipping AI features.**
4
+
5
+ Ax brings DSPy's revolutionary approach to TypeScript – just describe what you
6
+ want, and let the framework handle the rest. Production-ready, type-safe, and
7
+ works with all major LLMs.
8
+
9
+ [![NPM Package](https://img.shields.io/npm/v/@ax-llm/ax?style=for-the-badge&color=green)](https://www.npmjs.com/package/@ax-llm/ax)
10
+ [![Twitter](https://img.shields.io/twitter/follow/dosco?style=for-the-badge&color=red)](https://twitter.com/dosco)
11
+ [![Discord Chat](https://img.shields.io/discord/1078454354849304667?style=for-the-badge&color=green)](https://discord.gg/DSHg3dU7dW)
12
+
13
+ ## Transform Your AI Development in 30 Seconds
14
+
15
+ ```typescript
16
+ import { ai, ax } from "@ax-llm/ax";
17
+
18
+ // 1. Pick any LLM
19
+ const llm = ai({ name: "openai", apiKey: process.env.OPENAI_APIKEY! });
20
+
21
+ // 2. Say what you want
22
+ const classifier = ax(
23
+ 'review:string -> sentiment:class "positive, negative, neutral"',
24
+ );
25
+
26
+ // 3. Get type-safe results
27
+ const result = await classifier.forward(llm, {
28
+ review: "This product is amazing!",
29
+ });
30
+ console.log(result.sentiment); // "positive" ✨
31
+ ```
32
+
33
+ **That's it.** No prompt engineering. No trial and error. It works with GPT-4,
34
+ Claude, Gemini, or any LLM.
35
+
36
+ ## Why Thousands of Developers Choose Ax
37
+
38
+ ### 🎯 **Define Once, Run Anywhere**
39
+
40
+ Write your logic once. Switch between OpenAI, Anthropic, Google, or 15+
41
+ providers with one line. No rewrites needed.
42
+
43
+ ### ⚡ **Ship 10x Faster**
44
+
45
+ Stop tweaking prompts. Define inputs → outputs. The framework generates optimal
46
+ prompts automatically.
47
+
48
+ ### 🛡️ **Production-Ready from Day One**
49
+
50
+ Built-in streaming, validation, error handling, observability. Used by startups
51
+ in production handling millions of requests.
52
+
53
+ ### 🚀 **Gets Smarter Over Time**
54
+
55
+ Train your programs with examples. Watch accuracy improve automatically. No ML
56
+ expertise needed.
57
+
58
+ ## Real Apps, Real Simple
59
+
60
+ ### Extract Structured Data from Customer Emails
61
+
62
+ ```typescript
63
+ const extractor = ax(`
64
+ customerEmail:string, currentDate:datetime ->
65
+ priority:class "high, normal, low",
66
+ sentiment:class "positive, negative, neutral",
67
+ ticketNumber?:number,
68
+ nextSteps:string[],
69
+ estimatedResponseTime:string
70
+ `);
71
+
72
+ const result = await extractor.forward(ai, {
73
+ customerEmail: "Order #12345 hasn't arrived. Need this resolved immediately!",
74
+ currentDate: new Date(),
75
+ });
76
+ // Automatically extracts all fields with proper types and validation
77
+ ```
78
+
79
+ ### Build Agents That Use Tools (ReAct Pattern)
80
+
81
+ ```typescript
82
+ const assistant = ax(
83
+ "question:string -> answer:string",
84
+ {
85
+ functions: [
86
+ { name: "getCurrentWeather", func: weatherAPI },
87
+ { name: "searchNews", func: newsAPI },
88
+ ],
89
+ },
90
+ );
91
+
92
+ const result = await assistant.forward(ai, {
93
+ question: "What's the weather in Tokyo and any news about it?",
94
+ });
95
+ // AI automatically calls both functions and combines results
96
+ ```
97
+
98
+ ### Multi-Modal Analysis with Images
99
+
100
+ ```typescript
101
+ const analyzer = ax(`
102
+ image:image, question:string ->
103
+ description:string,
104
+ mainColors:string[],
105
+ category:class "electronics, clothing, food, other",
106
+ estimatedPrice:string
107
+ `);
108
+ // Process images and text together seamlessly
109
+ ```
110
+
111
+ ## Quick Start
112
+
113
+ ### Install
114
+
115
+ ```bash
116
+ npm install @ax-llm/ax
117
+ ```
118
+
119
+ ### Your First AI Feature (2 minutes)
120
+
121
+ ```typescript
122
+ import { ai, ax } from "@ax-llm/ax";
123
+
124
+ const llm = ai({ name: "openai", apiKey: process.env.OPENAI_APIKEY! });
125
+
126
+ const translator = ax(`
127
+ text:string,
128
+ language:string ->
129
+ translation:string
130
+ `);
131
+
132
+ const result = await translator.forward(llm, {
133
+ text: "Hello world",
134
+ language: "Spanish",
135
+ });
136
+ console.log(result.translation); // "Hola mundo"
137
+ ```
138
+
139
+ ## Powerful Features, Zero Complexity
140
+
141
+ - ✅ **15+ LLM Providers** - OpenAI, Anthropic, Google, Mistral, Ollama, and
142
+ more
143
+ - ✅ **Type-Safe Everything** - Full TypeScript support with auto-completion
144
+ - ✅ **Streaming First** - Real-time responses with validation
145
+ - ✅ **Multi-Modal** - Images, audio, text in the same signature
146
+ - ✅ **Smart Optimization** - Automatic prompt tuning with MiPRO
147
+ - ✅ **Production Observability** - OpenTelemetry tracing built-in
148
+ - ✅ **Advanced Workflows** - Compose complex pipelines with AxFlow
149
+ - ✅ **Enterprise RAG** - Multi-hop retrieval with quality loops
150
+ - ✅ **Agent Framework** - Agents that can use tools and call other agents
151
+ - ✅ **Zero Dependencies** - Lightweight, fast, reliable
152
+
153
+ ## Learn More
154
+
155
+ ### 🚀 Quick Wins
156
+
157
+ - [**Getting Started Guide**](https://github.com/ax-llm/ax/blob/main/docs/QUICKSTART.md) -
158
+ Set up in 5 minutes
159
+ - [**Examples Guide**](https://github.com/ax-llm/ax/blob/main/docs/EXAMPLES.md) -
160
+ Comprehensive examples with explanations
161
+ - [**DSPy Concepts**](https://github.com/ax-llm/ax/blob/main/docs/DSPY.md) -
162
+ Understand the revolutionary approach
163
+
164
+ ### 📚 Deep Dives
165
+
166
+ - [**AxFlow Workflows**](https://github.com/ax-llm/ax/blob/main/docs/AXFLOW.md) -
167
+ Build complex AI systems
168
+ - [**Optimization Guide**](https://github.com/ax-llm/ax/blob/main/docs/OPTIMIZE.md) -
169
+ Make your programs smarter
170
+ - [**Advanced RAG**](https://github.com/ax-llm/ax/blob/main/docs/AXRAG.md) -
171
+ Production search & retrieval
172
+ - [**API Reference**](https://github.com/ax-llm/ax/blob/main/docs/API.md) -
173
+ Complete documentation
174
+
175
+ ## Examples
176
+
177
+ Run any example:
178
+
179
+ ```bash
180
+ OPENAI_APIKEY=your-key npm run tsx ./src/examples/[example-name].ts
181
+ ```
182
+
183
+ ### Core Examples
184
+
185
+ - [extract.ts](src/examples/extract.ts) - Extract structured data from text
186
+ - [react.ts](src/examples/react.ts) - ReAct pattern with function calling
187
+ - [agent.ts](src/examples/agent.ts) - Multi-agent collaboration
188
+ - [streaming1.ts](src/examples/streaming1.ts) - Real-time streaming responses
189
+ - [multi-modal.ts](src/examples/multi-modal.ts) - Image + text processing
190
+
191
+ ### Production Patterns
192
+
193
+ - [customer-support.ts](src/examples/customer-support.ts) - Complete support
194
+ system
195
+ - [food-search.ts](src/examples/food-search.ts) - Restaurant recommendations
196
+ with tools
197
+ - [simple-optimizer-test.ts](src/examples/simple-optimizer-test.ts) - Automatic
198
+ optimization
199
+ - [mipro-python-optimizer.ts](src/examples/mipro-python-optimizer.ts) - Advanced
200
+ MIPRO optimization
201
+ - [ax-flow-enhanced-demo.ts](src/examples/ax-flow-enhanced-demo.ts) - Complex
202
+ workflows
203
+
204
+ [📚 **View Full Examples Guide** →](docs/EXAMPLES.md)\
205
+ [View All 70+ Examples →](src/examples/)
206
+
207
+ ## Join the Community
208
+
209
+ - 🐦 [Follow on Twitter](https://twitter.com/dosco) - Latest updates
210
+ - 💬 [Discord Community](https://discord.gg/DSHg3dU7dW) - Get help, share ideas
211
+ - ⭐ [Star on GitHub](https://github.com/ax-llm/ax) - Support the project
212
+ - 📖 [Ask DeepWiki](https://deepwiki.com/ax-llm/ax) - AI-powered docs
213
+
214
+ ## Production Ready
215
+
216
+ - ✅ **Battle-tested** - Used by startups in production
217
+ - ✅ **No breaking changes** - Stable minor versions
218
+ - ✅ **Comprehensive tests** - Large test coverage
219
+ - ✅ **OpenTelemetry** - Built-in observability
220
+ - ✅ **TypeScript first** - Type-safe by design
221
+
222
+ ## License
223
+
224
+ Apache 2 - Use it anywhere, build anything.
225
+
226
+ ---
227
+
228
+ **Ready to build the future?** Stop fighting with prompts. Start shipping with
229
+ signatures.
230
+
231
+ ```bash
232
+ npm install @ax-llm/ax
233
+ ```
234
+
235
+ _Built with ❤️ by developers, for developers._