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.
Files changed (84) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +56 -3
  3. package/dist/index.browser.cjs +663 -0
  4. package/dist/index.browser.cjs.map +1 -0
  5. package/dist/index.browser.d.cts +219 -0
  6. package/dist/index.browser.d.ts +219 -0
  7. package/dist/index.browser.js +642 -0
  8. package/dist/index.browser.js.map +1 -0
  9. package/dist/index.cjs +7 -0
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +7 -0
  12. package/dist/index.js.map +1 -1
  13. package/package.json +38 -19
  14. package/dist/compatibility.test.d.ts +0 -2
  15. package/dist/compatibility.test.d.ts.map +0 -1
  16. package/dist/compatibility.test.js +0 -123
  17. package/dist/index.d.ts.map +0 -1
  18. package/dist/integration.test.d.ts +0 -2
  19. package/dist/integration.test.d.ts.map +0 -1
  20. package/dist/integration.test.js +0 -221
  21. package/dist/internal/index.cjs +0 -135
  22. package/dist/internal/index.cjs.map +0 -1
  23. package/dist/internal/index.d.cts +0 -18
  24. package/dist/internal/index.d.ts +0 -18
  25. package/dist/internal/index.d.ts.map +0 -1
  26. package/dist/internal/index.js +0 -107
  27. package/dist/internal/index.js.map +0 -1
  28. package/dist/models/chat-language-model.d.ts +0 -49
  29. package/dist/models/chat-language-model.d.ts.map +0 -1
  30. package/dist/models/chat-language-model.js +0 -278
  31. package/dist/models/chat-language-model.test.d.ts +0 -2
  32. package/dist/models/chat-language-model.test.d.ts.map +0 -1
  33. package/dist/models/chat-language-model.test.js +0 -486
  34. package/dist/models/embedding-model.d.ts +0 -24
  35. package/dist/models/embedding-model.d.ts.map +0 -1
  36. package/dist/models/embedding-model.js +0 -77
  37. package/dist/models/embedding-model.test.d.ts +0 -2
  38. package/dist/models/embedding-model.test.d.ts.map +0 -1
  39. package/dist/models/embedding-model.test.js +0 -281
  40. package/dist/provider-dual-parameters.test.d.ts +0 -2
  41. package/dist/provider-dual-parameters.test.d.ts.map +0 -1
  42. package/dist/provider-dual-parameters.test.js +0 -223
  43. package/dist/provider.d.ts +0 -123
  44. package/dist/provider.d.ts.map +0 -1
  45. package/dist/provider.js +0 -52
  46. package/dist/provider.test.d.ts +0 -2
  47. package/dist/provider.test.d.ts.map +0 -1
  48. package/dist/provider.test.js +0 -192
  49. package/dist/test-setup.d.ts +0 -4
  50. package/dist/test-setup.d.ts.map +0 -1
  51. package/dist/test-setup.js +0 -31
  52. package/dist/utils/convert-to-ollama-messages.d.ts +0 -4
  53. package/dist/utils/convert-to-ollama-messages.d.ts.map +0 -1
  54. package/dist/utils/convert-to-ollama-messages.js +0 -105
  55. package/dist/utils/convert-to-ollama-messages.test.d.ts +0 -2
  56. package/dist/utils/convert-to-ollama-messages.test.d.ts.map +0 -1
  57. package/dist/utils/convert-to-ollama-messages.test.js +0 -433
  58. package/dist/utils/map-ollama-finish-reason.d.ts +0 -3
  59. package/dist/utils/map-ollama-finish-reason.d.ts.map +0 -1
  60. package/dist/utils/map-ollama-finish-reason.js +0 -15
  61. package/dist/utils/map-ollama-finish-reason.test.d.ts +0 -2
  62. package/dist/utils/map-ollama-finish-reason.test.d.ts.map +0 -1
  63. package/dist/utils/map-ollama-finish-reason.test.js +0 -47
  64. package/dist/utils/model-capabilities.d.ts +0 -28
  65. package/dist/utils/model-capabilities.d.ts.map +0 -1
  66. package/dist/utils/model-capabilities.js +0 -327
  67. package/dist/utils/model-suggestions.d.ts +0 -38
  68. package/dist/utils/model-suggestions.d.ts.map +0 -1
  69. package/dist/utils/model-suggestions.js +0 -158
  70. package/dist/utils/normalize-tool-parameters.d.ts +0 -17
  71. package/dist/utils/normalize-tool-parameters.d.ts.map +0 -1
  72. package/dist/utils/normalize-tool-parameters.js +0 -63
  73. package/dist/utils/normalize-tool-parameters.test.d.ts +0 -2
  74. package/dist/utils/normalize-tool-parameters.test.d.ts.map +0 -1
  75. package/dist/utils/normalize-tool-parameters.test.js +0 -100
  76. package/dist/utils/ollama-error.d.ts +0 -16
  77. package/dist/utils/ollama-error.d.ts.map +0 -1
  78. package/dist/utils/ollama-error.js +0 -13
  79. package/dist/utils/ollama-error.test.d.ts +0 -2
  80. package/dist/utils/ollama-error.test.d.ts.map +0 -1
  81. package/dist/utils/ollama-error.test.js +0 -94
  82. package/dist/utils/validate-model.d.ts +0 -32
  83. package/dist/utils/validate-model.d.ts.map +0 -1
  84. 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`