ai-sdk-ollama 0.4.0 → 0.5.1
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 +26 -0
- package/README.md +56 -3
- package/dist/index.browser.cjs +663 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +219 -0
- package/dist/index.browser.d.ts +219 -0
- package/dist/index.browser.js +642 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +38 -19
- package/dist/compatibility.test.d.ts +0 -2
- package/dist/compatibility.test.d.ts.map +0 -1
- package/dist/compatibility.test.js +0 -123
- package/dist/index.d.ts.map +0 -1
- package/dist/integration.test.d.ts +0 -2
- package/dist/integration.test.d.ts.map +0 -1
- package/dist/integration.test.js +0 -221
- package/dist/internal/index.cjs +0 -135
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.d.cts +0 -18
- package/dist/internal/index.d.ts +0 -18
- package/dist/internal/index.d.ts.map +0 -1
- package/dist/internal/index.js +0 -107
- package/dist/internal/index.js.map +0 -1
- package/dist/models/chat-language-model.d.ts +0 -49
- package/dist/models/chat-language-model.d.ts.map +0 -1
- package/dist/models/chat-language-model.js +0 -278
- package/dist/models/chat-language-model.test.d.ts +0 -2
- package/dist/models/chat-language-model.test.d.ts.map +0 -1
- package/dist/models/chat-language-model.test.js +0 -486
- package/dist/models/embedding-model.d.ts +0 -24
- package/dist/models/embedding-model.d.ts.map +0 -1
- package/dist/models/embedding-model.js +0 -77
- package/dist/models/embedding-model.test.d.ts +0 -2
- package/dist/models/embedding-model.test.d.ts.map +0 -1
- package/dist/models/embedding-model.test.js +0 -281
- package/dist/provider-dual-parameters.test.d.ts +0 -2
- package/dist/provider-dual-parameters.test.d.ts.map +0 -1
- package/dist/provider-dual-parameters.test.js +0 -223
- package/dist/provider.d.ts +0 -123
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -52
- package/dist/provider.test.d.ts +0 -2
- package/dist/provider.test.d.ts.map +0 -1
- package/dist/provider.test.js +0 -192
- package/dist/test-setup.d.ts +0 -4
- package/dist/test-setup.d.ts.map +0 -1
- package/dist/test-setup.js +0 -31
- package/dist/utils/convert-to-ollama-messages.d.ts +0 -4
- package/dist/utils/convert-to-ollama-messages.d.ts.map +0 -1
- package/dist/utils/convert-to-ollama-messages.js +0 -105
- package/dist/utils/convert-to-ollama-messages.test.d.ts +0 -2
- package/dist/utils/convert-to-ollama-messages.test.d.ts.map +0 -1
- package/dist/utils/convert-to-ollama-messages.test.js +0 -433
- package/dist/utils/map-ollama-finish-reason.d.ts +0 -3
- package/dist/utils/map-ollama-finish-reason.d.ts.map +0 -1
- package/dist/utils/map-ollama-finish-reason.js +0 -15
- package/dist/utils/map-ollama-finish-reason.test.d.ts +0 -2
- package/dist/utils/map-ollama-finish-reason.test.d.ts.map +0 -1
- package/dist/utils/map-ollama-finish-reason.test.js +0 -47
- package/dist/utils/model-capabilities.d.ts +0 -28
- package/dist/utils/model-capabilities.d.ts.map +0 -1
- package/dist/utils/model-capabilities.js +0 -327
- package/dist/utils/model-suggestions.d.ts +0 -38
- package/dist/utils/model-suggestions.d.ts.map +0 -1
- package/dist/utils/model-suggestions.js +0 -158
- package/dist/utils/normalize-tool-parameters.d.ts +0 -17
- package/dist/utils/normalize-tool-parameters.d.ts.map +0 -1
- package/dist/utils/normalize-tool-parameters.js +0 -63
- package/dist/utils/normalize-tool-parameters.test.d.ts +0 -2
- package/dist/utils/normalize-tool-parameters.test.d.ts.map +0 -1
- package/dist/utils/normalize-tool-parameters.test.js +0 -100
- package/dist/utils/ollama-error.d.ts +0 -16
- package/dist/utils/ollama-error.d.ts.map +0 -1
- package/dist/utils/ollama-error.js +0 -13
- package/dist/utils/ollama-error.test.d.ts +0 -2
- package/dist/utils/ollama-error.test.d.ts.map +0 -1
- package/dist/utils/ollama-error.test.js +0 -94
- package/dist/utils/validate-model.d.ts +0 -32
- package/dist/utils/validate-model.d.ts.map +0 -1
- package/dist/utils/validate-model.js +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- edb4d47: Updated ai package version to 5.0.15
|
|
8
|
+
|
|
9
|
+
## 0.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add browser support with automatic environment detection
|
|
14
|
+
- Add browser-specific provider using ollama/browser package
|
|
15
|
+
- Implement dual package exports for Node.js and browser environments
|
|
16
|
+
- Add comprehensive browser example with Vite and interactive UI
|
|
17
|
+
- Update build configuration to generate separate browser and Node.js bundles
|
|
18
|
+
- Add browser compatibility tests and examples
|
|
19
|
+
|
|
20
|
+
- e02f8af: Feature: Browser support and streaming improvements. Closes https://github.com/jagreehal/ai-sdk-ollama/issues/14
|
|
21
|
+
- feat(browser): Automatic browser support via `ollama/browser` with dedicated `index.browser` export. Works seamlessly with bundlers and `ai` v5 in browser contexts.
|
|
22
|
+
- fix(streaming): Emit trailing `text-delta` on the final `done` chunk to avoid empty streams for models that only flush content at the end. Note: streams may include one additional text chunk now.
|
|
23
|
+
- tests: Add `gpt-oss:20b` integration coverage and make prompts/token limits more robust; update unit tests to reflect final text emission on `done`.
|
|
24
|
+
- docs/examples: Switch Node examples to per-file `tsx` execution and update READMEs; clarify how to run browser and node examples.
|
|
25
|
+
- chore(repo): Monorepo migration (no user-facing API changes), Dependabot config for package folder, and CI refinements.
|
|
26
|
+
|
|
27
|
+
No breaking changes to the public API.
|
|
28
|
+
|
|
3
29
|
## 0.4.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -15,6 +15,10 @@ A Vercel AI SDK v5+ provider for Ollama built on the official `ollama` package.
|
|
|
15
15
|
- [Quick Start](#quick-start)
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
- [Basic Usage](#basic-usage)
|
|
18
|
+
- [Browser Support](#browser-support)
|
|
19
|
+
- [Browser Usage](#browser-usage)
|
|
20
|
+
- [Explicit Browser Import](#explicit-browser-import)
|
|
21
|
+
- [CORS Configuration](#cors-configuration)
|
|
18
22
|
- [Key Features](#key-features)
|
|
19
23
|
- [Cross Provider Compatibility](#cross-provider-compatibility)
|
|
20
24
|
- [Native Ollama Power](#native-ollama-power)
|
|
@@ -24,6 +28,7 @@ A Vercel AI SDK v5+ provider for Ollama built on the official `ollama` package.
|
|
|
24
28
|
- [Custom Ollama Instance](#custom-ollama-instance)
|
|
25
29
|
- [Structured Output](#structured-output)
|
|
26
30
|
- [Auto-Detection of Structured Outputs](#auto-detection-of-structured-outputs)
|
|
31
|
+
- [Reasoning Support](#reasoning-support)
|
|
27
32
|
- [Common Issues](#common-issues)
|
|
28
33
|
- [Supported Models](#supported-models)
|
|
29
34
|
- [Testing](#testing)
|
|
@@ -114,6 +119,52 @@ const { embedding } = await embed({
|
|
|
114
119
|
console.log(embedding.length); // 768 dimensions
|
|
115
120
|
```
|
|
116
121
|
|
|
122
|
+
## Browser Support
|
|
123
|
+
|
|
124
|
+
See the [browser example](../../examples/browser/).
|
|
125
|
+
|
|
126
|
+
This provider works in both Node.js and browser environments. The library automatically selects the correct Ollama client based on the environment.
|
|
127
|
+
|
|
128
|
+
### Browser Usage
|
|
129
|
+
|
|
130
|
+
The same API works in browsers with automatic environment detection:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { ollama } from 'ai-sdk-ollama'; // Automatically uses browser version
|
|
134
|
+
import { generateText } from 'ai';
|
|
135
|
+
|
|
136
|
+
const { text } = await generateText({
|
|
137
|
+
model: ollama('llama3.2'),
|
|
138
|
+
prompt: 'Write a haiku about coding',
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Explicit Browser Import
|
|
143
|
+
|
|
144
|
+
You can also explicitly import the browser version:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { ollama } from 'ai-sdk-ollama/browser';
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### CORS Configuration
|
|
151
|
+
|
|
152
|
+
For browser usage, you have several options to handle CORS:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Option 1: Use a proxy (recommended for development)
|
|
156
|
+
# Configure your bundler (Vite, Webpack, etc.) to proxy /api/* to Ollama
|
|
157
|
+
# See browser example for Vite proxy configuration
|
|
158
|
+
|
|
159
|
+
# Option 2: Allow all origins (development only)
|
|
160
|
+
OLLAMA_ORIGINS=* ollama serve
|
|
161
|
+
|
|
162
|
+
# Option 3: Allow specific origins
|
|
163
|
+
OLLAMA_ORIGINS="http://localhost:3000,https://myapp.com" ollama serve
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Recommended**: Use a development proxy (like Vite proxy) to avoid CORS issues entirely. See the browser example for a complete working setup.
|
|
167
|
+
|
|
117
168
|
## Key Features
|
|
118
169
|
|
|
119
170
|
### Cross Provider Compatibility
|
|
@@ -157,12 +208,14 @@ Ollama supports tool calling with compatible models.
|
|
|
157
208
|
|
|
158
209
|
```typescript
|
|
159
210
|
import { z } from 'zod';
|
|
211
|
+
import { generateText, tool } from 'ai';
|
|
212
|
+
import { ollama } from 'ai-sdk-ollama';
|
|
160
213
|
|
|
161
214
|
const { text, toolCalls } = await generateText({
|
|
162
215
|
model: ollama('llama3.2'),
|
|
163
216
|
prompt: 'What is the weather in San Francisco?',
|
|
164
217
|
tools: {
|
|
165
|
-
getWeather: {
|
|
218
|
+
getWeather: tool({
|
|
166
219
|
description: 'Get current weather for a location',
|
|
167
220
|
inputSchema: z.object({
|
|
168
221
|
location: z.string().describe('City name'),
|
|
@@ -172,7 +225,7 @@ const { text, toolCalls } = await generateText({
|
|
|
172
225
|
// Your actual weather API call here
|
|
173
226
|
return { temp: 18, unit, condition: 'sunny' };
|
|
174
227
|
},
|
|
175
|
-
},
|
|
228
|
+
}),
|
|
176
229
|
},
|
|
177
230
|
});
|
|
178
231
|
```
|
|
@@ -329,7 +382,7 @@ Install with: `ollama pull deepseek-r1:7b`
|
|
|
329
382
|
|
|
330
383
|
Works with any model in your Ollama installation:
|
|
331
384
|
|
|
332
|
-
- **Chat**: `llama3.2`, `mistral`, `phi4-mini`, `qwen2.5`, `codellama`
|
|
385
|
+
- **Chat**: `llama3.2`, `mistral`, `phi4-mini`, `qwen2.5`, `codellama`, `gpt-oss:20b`
|
|
333
386
|
- **Vision**: `llava`, `bakllava`, `llama3.2-vision`, `minicpm-v`
|
|
334
387
|
- **Embeddings**: `nomic-embed-text`, `all-minilm`, `mxbai-embed-large`
|
|
335
388
|
- **Reasoning**: `deepseek-r1:7b`, `deepseek-r1:1.5b`, `deepseek-r1:8b`
|