@easbot/ollama-sdk 0.1.3 → 0.1.7
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.en.md +15 -15
- package/README.md +13 -13
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +26 -23
- package/dist/index.d.ts +26 -23
- package/dist/index.mjs +6 -6
- package/package.json +29 -29
package/README.en.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @easbot/ollama-sdk
|
|
2
2
|
|
|
3
|
-
AI SDK
|
|
3
|
+
AI SDK v3 compatible Ollama Provider with automatic complete event stream generation.
|
|
4
4
|
|
|
5
5
|
[中文文档](./README.md) | English
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- ✅ Full AI SDK
|
|
9
|
+
- ✅ Full AI SDK v3 compatibility
|
|
10
10
|
- ✅ Tool Calling support
|
|
11
11
|
- ✅ Automatic complete event stream generation
|
|
12
12
|
- ✅ Native Ollama implementation with no extra dependencies
|
|
@@ -30,7 +30,7 @@ import { NativeOllamaLanguageModel } from '@easbot/ollama-sdk';
|
|
|
30
30
|
import { streamText } from 'ai';
|
|
31
31
|
|
|
32
32
|
// Create Ollama model
|
|
33
|
-
const model = new NativeOllamaLanguageModel('
|
|
33
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
34
34
|
baseURL: 'http://localhost:11434', // Optional, default value
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -51,7 +51,7 @@ for await (const chunk of result.textStream) {
|
|
|
51
51
|
import { NativeOllamaLanguageModel } from '@easbot/ollama-sdk';
|
|
52
52
|
import { generateText } from 'ai';
|
|
53
53
|
|
|
54
|
-
const model = new NativeOllamaLanguageModel('
|
|
54
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
55
55
|
|
|
56
56
|
// Define tools
|
|
57
57
|
const tools = {
|
|
@@ -89,7 +89,7 @@ console.log(result.text);
|
|
|
89
89
|
```typescript
|
|
90
90
|
import { generateText } from 'ai';
|
|
91
91
|
|
|
92
|
-
const model = new NativeOllamaLanguageModel('
|
|
92
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
93
93
|
|
|
94
94
|
const result = await generateText({
|
|
95
95
|
model,
|
|
@@ -110,7 +110,7 @@ console.log(result.text);
|
|
|
110
110
|
|
|
111
111
|
Tool calling feature requires models that support tool calling. Recommended:
|
|
112
112
|
|
|
113
|
-
- `
|
|
113
|
+
- `qwen3:0.6b` - Lightweight, suitable for development and testing
|
|
114
114
|
- `qwen2.5:7b` - Balanced performance and quality
|
|
115
115
|
- `llama3.1:8b` - High-quality tool calling
|
|
116
116
|
- `mistral:7b` - General-purpose model
|
|
@@ -127,10 +127,10 @@ Look for the `tools` field in the model information.
|
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
129
|
// Method 1: Direct model instance creation
|
|
130
|
-
const model1 = new NativeOllamaLanguageModel('
|
|
130
|
+
const model1 = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
131
131
|
|
|
132
132
|
// Method 2: Custom baseURL
|
|
133
|
-
const model2 = new NativeOllamaLanguageModel('
|
|
133
|
+
const model2 = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
134
134
|
baseURL: 'http://192.168.1.100:11434',
|
|
135
135
|
});
|
|
136
136
|
|
|
@@ -360,7 +360,7 @@ new NativeOllamaLanguageModel(modelId: string, config?: {
|
|
|
360
360
|
|
|
361
361
|
**Parameters:**
|
|
362
362
|
|
|
363
|
-
- `modelId` (string): Ollama model ID (e.g., '
|
|
363
|
+
- `modelId` (string): Ollama model ID (e.g., 'qwen3:0.6b', 'llama3.1:8b')
|
|
364
364
|
- `config` (optional): Model configuration
|
|
365
365
|
- `baseURL` (string): Ollama API base URL, defaults to `'http://localhost:11434'`
|
|
366
366
|
|
|
@@ -372,7 +372,7 @@ new NativeOllamaLanguageModel(modelId: string, config?: {
|
|
|
372
372
|
**Example:**
|
|
373
373
|
|
|
374
374
|
```typescript
|
|
375
|
-
const model = new NativeOllamaLanguageModel('
|
|
375
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
376
376
|
baseURL: 'http://localhost:11434',
|
|
377
377
|
});
|
|
378
378
|
|
|
@@ -458,7 +458,7 @@ import {
|
|
|
458
458
|
} from '@easbot/ollama-sdk';
|
|
459
459
|
|
|
460
460
|
try {
|
|
461
|
-
const model = new NativeOllamaLanguageModel('
|
|
461
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
462
462
|
const result = await generateText({
|
|
463
463
|
model,
|
|
464
464
|
tools: {
|
|
@@ -531,11 +531,12 @@ Ollama HTTP API
|
|
|
531
531
|
### vs `ai-sdk-ollama`
|
|
532
532
|
|
|
533
533
|
- ✅ Complete tool calling support (ai-sdk-ollama doesn't support)
|
|
534
|
-
- ✅ Complete AI SDK
|
|
534
|
+
- ✅ Complete AI SDK v3 event stream
|
|
535
535
|
- ✅ Better TypeScript type support
|
|
536
|
-
- ✅ Complete error handling
|
|
536
|
+
- ✅ Complete error handling
|
|
537
537
|
- ✅ Structured logging and debugging support
|
|
538
538
|
- ✅ Zero extra dependencies
|
|
539
|
+
- ✅ Cleaner API
|
|
539
540
|
|
|
540
541
|
### vs `ollama-ai-provider`
|
|
541
542
|
|
|
@@ -543,7 +544,6 @@ Ollama HTTP API
|
|
|
543
544
|
- ✅ Tool calling support
|
|
544
545
|
- ✅ Automatic event stream generation
|
|
545
546
|
- ✅ Cleaner API
|
|
546
|
-
- ✅ Complete documentation and examples
|
|
547
547
|
|
|
548
548
|
## Development
|
|
549
549
|
|
|
@@ -570,4 +570,4 @@ MIT
|
|
|
570
570
|
|
|
571
571
|
## Contributing
|
|
572
572
|
|
|
573
|
-
Issues and Pull Requests are welcome!
|
|
573
|
+
Issues and Pull Requests are welcome!
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ AI SDK v2 兼容的 Ollama Provider,自动生成完整的事件流。
|
|
|
4
4
|
|
|
5
5
|
## 特性
|
|
6
6
|
|
|
7
|
-
- ✅ 完整的 AI SDK
|
|
7
|
+
- ✅ 完整的 AI SDK v3 兼容性
|
|
8
8
|
- ✅ 工具调用支持(Tool Calling)
|
|
9
9
|
- ✅ 自动生成完整的事件流
|
|
10
10
|
- ✅ 原生 Ollama 实现,无需额外依赖
|
|
@@ -28,7 +28,7 @@ import { NativeOllamaLanguageModel } from '@easbot/ollama-sdk';
|
|
|
28
28
|
import { streamText } from 'ai';
|
|
29
29
|
|
|
30
30
|
// 创建 Ollama 模型
|
|
31
|
-
const model = new NativeOllamaLanguageModel('
|
|
31
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
32
32
|
baseURL: 'http://localhost:11434', // 可选,默认值
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -49,7 +49,7 @@ for await (const chunk of result.textStream) {
|
|
|
49
49
|
import { NativeOllamaLanguageModel } from '@easbot/ollama-sdk';
|
|
50
50
|
import { generateText } from 'ai';
|
|
51
51
|
|
|
52
|
-
const model = new NativeOllamaLanguageModel('
|
|
52
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
53
53
|
|
|
54
54
|
// 定义工具
|
|
55
55
|
const tools = {
|
|
@@ -87,7 +87,7 @@ console.log(result.text);
|
|
|
87
87
|
```typescript
|
|
88
88
|
import { generateText } from 'ai';
|
|
89
89
|
|
|
90
|
-
const model = new NativeOllamaLanguageModel('
|
|
90
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
91
91
|
|
|
92
92
|
const result = await generateText({
|
|
93
93
|
model,
|
|
@@ -108,7 +108,7 @@ console.log(result.text);
|
|
|
108
108
|
|
|
109
109
|
工具调用功能需要使用支持工具调用的模型,推荐:
|
|
110
110
|
|
|
111
|
-
- `
|
|
111
|
+
- `qwen3:0.6b` - 轻量级,适合开发测试
|
|
112
112
|
- `qwen2.5:7b` - 平衡性能和质量
|
|
113
113
|
- `llama3.1:8b` - 高质量工具调用
|
|
114
114
|
- `mistral:7b` - 通用模型
|
|
@@ -125,10 +125,10 @@ ollama show <model-name>
|
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
127
|
// 方式 1: 直接创建模型实例
|
|
128
|
-
const model1 = new NativeOllamaLanguageModel('
|
|
128
|
+
const model1 = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
129
129
|
|
|
130
130
|
// 方式 2: 自定义 baseURL
|
|
131
|
-
const model2 = new NativeOllamaLanguageModel('
|
|
131
|
+
const model2 = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
132
132
|
baseURL: 'http://192.168.1.100:11434',
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -358,7 +358,7 @@ new NativeOllamaLanguageModel(modelId: string, config?: {
|
|
|
358
358
|
|
|
359
359
|
**参数:**
|
|
360
360
|
|
|
361
|
-
- `modelId` (string): Ollama 模型 ID(例如:'
|
|
361
|
+
- `modelId` (string): Ollama 模型 ID(例如:'qwen3:0.6b'、'llama3.1:8b')
|
|
362
362
|
- `config` (可选): 模型配置
|
|
363
363
|
- `baseURL` (string): Ollama API 基础 URL,默认 `'http://localhost:11434'`
|
|
364
364
|
|
|
@@ -370,7 +370,7 @@ new NativeOllamaLanguageModel(modelId: string, config?: {
|
|
|
370
370
|
**示例:**
|
|
371
371
|
|
|
372
372
|
```typescript
|
|
373
|
-
const model = new NativeOllamaLanguageModel('
|
|
373
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b', {
|
|
374
374
|
baseURL: 'http://localhost:11434',
|
|
375
375
|
});
|
|
376
376
|
|
|
@@ -456,7 +456,7 @@ import {
|
|
|
456
456
|
} from '@easbot/ollama-sdk';
|
|
457
457
|
|
|
458
458
|
try {
|
|
459
|
-
const model = new NativeOllamaLanguageModel('
|
|
459
|
+
const model = new NativeOllamaLanguageModel('qwen3:0.6b');
|
|
460
460
|
const result = await generateText({
|
|
461
461
|
model,
|
|
462
462
|
tools: {
|
|
@@ -529,11 +529,12 @@ Ollama HTTP API
|
|
|
529
529
|
### vs `ai-sdk-ollama`
|
|
530
530
|
|
|
531
531
|
- ✅ 完整的工具调用支持(ai-sdk-ollama 不支持)
|
|
532
|
-
- ✅ 完整的 AI SDK
|
|
532
|
+
- ✅ 完整的 AI SDK v3 事件流
|
|
533
533
|
- ✅ 更好的 TypeScript 类型支持
|
|
534
|
-
- ✅
|
|
534
|
+
- ✅ 完整的错误处理
|
|
535
535
|
- ✅ 结构化日志和调试支持
|
|
536
536
|
- ✅ 零额外依赖
|
|
537
|
+
- ✅ 更简洁的 API
|
|
537
538
|
|
|
538
539
|
### vs `ollama-ai-provider`
|
|
539
540
|
|
|
@@ -541,7 +542,6 @@ Ollama HTTP API
|
|
|
541
542
|
- ✅ 工具调用支持
|
|
542
543
|
- ✅ 自动事件流生成
|
|
543
544
|
- ✅ 更简洁的 API
|
|
544
|
-
- ✅ 完整的文档和示例
|
|
545
545
|
|
|
546
546
|
## 开发
|
|
547
547
|
|