Skip to content

Commit

Permalink
Fix: Add simulated streaming support for Ollama provider
Browse files Browse the repository at this point in the history
  • Loading branch information
miurla committed Jan 18, 2025
1 parent 3dc6a87 commit e434810
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Binary file modified bun.lockb
Binary file not shown.
17 changes: 14 additions & 3 deletions lib/utils/registry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { experimental_createProviderRegistry as createProviderRegistry } from 'ai'
import { openai, createOpenAI } from '@ai-sdk/openai'
import { anthropic } from '@ai-sdk/anthropic'
import { google } from '@ai-sdk/google'
import { createAzure } from '@ai-sdk/azure'
import { google } from '@ai-sdk/google'
import { createOpenAI, openai } from '@ai-sdk/openai'
import { experimental_createProviderRegistry as createProviderRegistry } from 'ai'
import { createOllama } from 'ollama-ai-provider'

export const registry = createProviderRegistry({
Expand All @@ -27,6 +27,17 @@ export const registry = createProviderRegistry({
})

export function getModel(model: string) {
// if ollama provider, set simulateStreaming to true
if (model.includes('ollama')) {
const modelName = model.split(':')[1]
const ollama = createOllama({
baseURL: `${process.env.OLLAMA_BASE_URL}/api`
})
return ollama(modelName, {
simulateStreaming: true
})
}

return registry.languageModel(model)
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"next": "^15.1.3",
"next-themes": "^0.3.0",
"node-html-parser": "^6.1.13",
"ollama-ai-provider": "^1.1.0",
"ollama-ai-provider": "^1.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-icons": "^5.0.1",
Expand Down

0 comments on commit e434810

Please sign in to comment.