ai-sdk-ollama 0.7.0 → 0.8.0
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/CHANGELOG.md +42 -0
- package/README.md +57 -5
- package/dist/index.browser.cjs +168 -328
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +230 -163
- package/dist/index.browser.d.ts +230 -163
- package/dist/index.browser.js +170 -330
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +168 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +230 -163
- package/dist/index.d.ts +230 -163
- package/dist/index.js +170 -330
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7ce6ed0: Enhanced tool calling with reliable wrapper functions
|
|
8
|
+
|
|
9
|
+
## What's New
|
|
10
|
+
- **New Enhanced Wrapper Functions**: Added `generateTextOllama()` and `streamTextOllama()` for guaranteed tool calling reliability
|
|
11
|
+
- **Automatic Response Synthesis**: Enhanced functions automatically complete responses when tools are executed but return empty text
|
|
12
|
+
- **Configurable Reliability Options**: Control synthesis behavior with `enhancedOptions` parameter
|
|
13
|
+
- **Improved Documentation**: Comprehensive examples and comparison tables for standard vs enhanced functions
|
|
14
|
+
|
|
15
|
+
## Key Features
|
|
16
|
+
- **Reliable Tool Calling**: Standard `generateText()` may return empty responses after tool execution. Enhanced wrappers guarantee complete, useful responses every time
|
|
17
|
+
- **Backward Compatible**: All existing code continues to work unchanged
|
|
18
|
+
- **Production Ready**: Designed for critical applications that can't handle unpredictable empty responses
|
|
19
|
+
- **Cross Provider Compatible**: Enhanced functions work with any AI SDK provider
|
|
20
|
+
|
|
21
|
+
## Breaking Changes
|
|
22
|
+
|
|
23
|
+
None - this is a purely additive enhancement.
|
|
24
|
+
|
|
25
|
+
## Migration
|
|
26
|
+
|
|
27
|
+
No migration required. Existing code works unchanged. To get enhanced reliability:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// Before (may return empty text after tool calls)
|
|
31
|
+
const { text } = await generateText({
|
|
32
|
+
model: ollama('llama3.2'),
|
|
33
|
+
tools,
|
|
34
|
+
prompt,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// After (guaranteed complete responses)
|
|
38
|
+
const { text } = await generateTextOllama({
|
|
39
|
+
model: ollama('llama3.2'),
|
|
40
|
+
tools,
|
|
41
|
+
prompt,
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
3
45
|
## 0.7.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
A Vercel AI SDK v5+ provider for Ollama built on the official `ollama` package. Type safe, future proof, with cross provider compatibility and native Ollama features.
|
|
9
9
|
|
|
10
|
-
>
|
|
10
|
+
> **🚀 Reliable Tool Calling**: This provider includes built-in reliability features enabled by default, plus enhanced wrapper functions for guaranteed tool calling success:
|
|
11
11
|
>
|
|
12
|
-
> - `generateText`
|
|
13
|
-
> - `
|
|
14
|
-
> - `
|
|
15
|
-
>
|
|
12
|
+
> - **Standard**: `generateText({ model: ollama('llama3.2'), tools, prompt })` - works with built-in reliability
|
|
13
|
+
> - **Enhanced**: `generateTextOllama({ model: ollama('llama3.2'), tools, prompt })` - reliable tool calling
|
|
14
|
+
> - **Streaming**: `streamTextOllama()` - enhanced streaming with tool awareness
|
|
15
|
+
>
|
|
16
|
+
> **The Problem We Solve**: Standard Ollama providers often execute tools but return empty responses. Our enhanced functions guarantee complete, useful responses every time.
|
|
16
17
|
|
|
17
18
|
## Contents
|
|
18
19
|
|
|
@@ -30,6 +31,7 @@ A Vercel AI SDK v5+ provider for Ollama built on the official `ollama` package.
|
|
|
30
31
|
- [Cross Provider Compatibility](#cross-provider-compatibility)
|
|
31
32
|
- [Native Ollama Power](#native-ollama-power)
|
|
32
33
|
- [Tool Calling Support](#tool-calling-support)
|
|
34
|
+
- [Enhanced Tool Calling Wrappers](#enhanced-tool-calling-wrappers)
|
|
33
35
|
- [Simple and Predictable](#simple-and-predictable)
|
|
34
36
|
- [Advanced Features](#advanced-features)
|
|
35
37
|
- [Custom Ollama Instance](#custom-ollama-instance)
|
|
@@ -240,6 +242,56 @@ const { text, toolCalls } = await generateText({
|
|
|
240
242
|
|
|
241
243
|
> **Note on Tool Parameters**: Due to Zod version compatibility issues, tool schemas may not always convert properly. When this happens, Ollama may use different parameter names than defined in your schema. It's recommended to handle parameter variations in your tool's execute function (e.g., checking for both `location` and `city`).
|
|
242
244
|
|
|
245
|
+
### Enhanced Tool Calling Wrappers
|
|
246
|
+
|
|
247
|
+
For maximum tool calling reliability, use our enhanced wrapper functions that guarantee complete responses:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { ollama, generateTextOllama, streamTextOllama } from 'ai-sdk-ollama';
|
|
251
|
+
import { tool } from 'ai';
|
|
252
|
+
import { z } from 'zod';
|
|
253
|
+
|
|
254
|
+
// Enhanced generateText with automatic response synthesis
|
|
255
|
+
const result = await generateTextOllama({
|
|
256
|
+
model: ollama('llama3.2'),
|
|
257
|
+
prompt: 'What is 15 + 27? Use the math tool to calculate it.',
|
|
258
|
+
tools: {
|
|
259
|
+
math: tool({
|
|
260
|
+
description: 'Perform math calculations',
|
|
261
|
+
inputSchema: z.object({
|
|
262
|
+
operation: z.string().describe('Math operation like "15 + 27"'),
|
|
263
|
+
}),
|
|
264
|
+
execute: async ({ operation }) => {
|
|
265
|
+
return { result: eval(operation), operation };
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
},
|
|
269
|
+
// Optional: Configure reliability behavior
|
|
270
|
+
enhancedOptions: {
|
|
271
|
+
enableSynthesis: true, // Default: true
|
|
272
|
+
maxSynthesisAttempts: 2, // Default: 2
|
|
273
|
+
minResponseLength: 10, // Default: 10
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
console.log(result.text); // "15 + 27 equals 42. Using the math tool, I calculated..."
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**When to Use Enhanced Wrappers:**
|
|
281
|
+
|
|
282
|
+
- **Critical tool calling scenarios** where you need guaranteed text responses
|
|
283
|
+
- **Production applications** that can't handle empty responses after tool execution
|
|
284
|
+
- **Complex multi-step tool interactions** requiring reliable synthesis
|
|
285
|
+
|
|
286
|
+
**Standard vs Enhanced Comparison:**
|
|
287
|
+
|
|
288
|
+
| Function | Standard `generateText` | Enhanced `generateTextOllama` |
|
|
289
|
+
| -------------------------- | ------------------------- | ------------------------------------ |
|
|
290
|
+
| **Simple prompts** | ✅ Perfect | ✅ Works (slight overhead) |
|
|
291
|
+
| **Tool calling** | ⚠️ May return empty text | ✅ **Guarantees complete responses** |
|
|
292
|
+
| **Complete responses** | ❌ Manual handling needed | ✅ **Automatic completion** |
|
|
293
|
+
| **Production reliability** | ⚠️ Unpredictable | ✅ **Reliable** |
|
|
294
|
+
|
|
243
295
|
### Simple and Predictable
|
|
244
296
|
|
|
245
297
|
The provider works the same way with any model - just try the features you need:
|