Skip to content

Commit 32eb8f6

Browse files
authored
Merge pull request #402 from miurla/fix/simulate-streaming-for-ollama
Fix: Add simulated streaming support for Ollama provider
2 parents 3dc6a87 + e434810 commit 32eb8f6

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

bun.lockb

0 Bytes
Binary file not shown.

lib/utils/registry.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { experimental_createProviderRegistry as createProviderRegistry } from 'ai'
2-
import { openai, createOpenAI } from '@ai-sdk/openai'
31
import { anthropic } from '@ai-sdk/anthropic'
4-
import { google } from '@ai-sdk/google'
52
import { createAzure } from '@ai-sdk/azure'
3+
import { google } from '@ai-sdk/google'
4+
import { createOpenAI, openai } from '@ai-sdk/openai'
5+
import { experimental_createProviderRegistry as createProviderRegistry } from 'ai'
66
import { createOllama } from 'ollama-ai-provider'
77

88
export const registry = createProviderRegistry({
@@ -27,6 +27,17 @@ export const registry = createProviderRegistry({
2727
})
2828

2929
export function getModel(model: string) {
30+
// if ollama provider, set simulateStreaming to true
31+
if (model.includes('ollama')) {
32+
const modelName = model.split(':')[1]
33+
const ollama = createOllama({
34+
baseURL: `${process.env.OLLAMA_BASE_URL}/api`
35+
})
36+
return ollama(modelName, {
37+
simulateStreaming: true
38+
})
39+
}
40+
3041
return registry.languageModel(model)
3142
}
3243

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"next": "^15.1.3",
4141
"next-themes": "^0.3.0",
4242
"node-html-parser": "^6.1.13",
43-
"ollama-ai-provider": "^1.1.0",
43+
"ollama-ai-provider": "^1.2.0",
4444
"react": "^19.0.0",
4545
"react-dom": "^19.0.0",
4646
"react-icons": "^5.0.1",

0 commit comments

Comments
 (0)