Skip to content

Commit 168928a

Browse files
docs: update provider docs and add changeset for Ollama integration
1 parent 37aae11 commit 168928a

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

.changeset/ollama-integration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# .changeset/ollama-integration.md
2+
3+
---
4+
5+
"@voltagent/ollama": minor
6+
"@voltagent/core": patch
7+
8+
---
9+
10+
feat(ollama): Implement Ollama provider integration
11+
12+
This feature allows users to use local Ollama instance as an LLM provider within VoltAgent applications.
13+
14+
- Adds OllamaProvider class implementing LLMProvider interface
15+
- Implements core text generation functionalities
16+
- Adds configuration for Ollama endpoint URL
17+
- Includes example implementation
18+
- Updates provider documentation
19+
20+
Fixes #15

website/docs/agents/providers.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,90 @@ Always refer to the documentation for the specific provider you are using to kno
5757
VoltAgent offers built-in providers for various popular services and SDKs, including Vercel AI, Google AI (Gemini/Vertex), Groq, and any OpenAI-compatible API endpoint (via xsAI).
5858

5959
**For detailed information on each available provider, including specific installation, configuration, and usage instructions, please see the [Providers Overview](../providers/overview.md).**
60+
61+
### `@voltagent/ollama` (Ollama AI Provider)
62+
63+
Connects to Ollama and allowing you to use your locally hosted Ollama models with Voltagent.
64+
65+
## Prerequisites
66+
67+
1. [Install Ollama](https://ollama.ai/download) on your machine
68+
2. Pull the models you want to use:
69+
```bash
70+
ollama pull llama3
71+
# or any other model you want to use
72+
```
73+
3. Ensure Ollama is running:
74+
```bash
75+
ollama serve
76+
```
77+
78+
## Usage
79+
80+
```typescript
81+
import { Agent } from "@voltagent/core";
82+
import { OllamaProvider } from "@voltagent/ollama";
83+
84+
// Initialize the Ollama provider
85+
const ollama = new OllamaProvider({
86+
// Optional: provide a custom URL if Ollama is not running on the default localhost:11434
87+
baseUrl: "http://localhost:11434",
88+
});
89+
90+
// Create an agent using the Ollama provider
91+
const agent = new Agent({
92+
name: "LocalLLMAgent",
93+
description: "An agent that uses a local Ollama model",
94+
llm: ollama,
95+
// Specify the model name - this should match a model you've pulled in Ollama
96+
model: "llama3",
97+
});
98+
99+
// Use the agent
100+
const response = await agent.generateText("Hello, what can you do for me?");
101+
console.log(response.text);
102+
```
103+
104+
## Provider-Specific Options
105+
106+
When calling agent methods, you can pass provider-specific options:
107+
108+
```typescript
109+
const response = await agent.generateText("What is the capital of France?", {
110+
provider: {
111+
temperature: 0.7,
112+
maxTokens: 500,
113+
topP: 0.9,
114+
seed: 123,
115+
},
116+
});
117+
```
118+
119+
## Available Models
120+
121+
The available models depend on what you've pulled to your Ollama instance. Common models include:
122+
123+
- `llama3`
124+
- `mistral`
125+
- `gemma`
126+
- `phi`
127+
- `llama2`
128+
- `llama2-uncensored`
129+
- `orca-mini`
130+
- `codellama`
131+
- `stable-code`
132+
133+
Check the [Ollama model library](https://ollama.ai/library) for the full list of available models.
134+
135+
## Example with Streaming
136+
137+
```typescript
138+
const stream = await agent.streamText("Tell me a story about a robot");
139+
140+
// Process the stream
141+
for await (const chunk of stream.textStream) {
142+
process.stdout.write(chunk);
143+
}
144+
```
145+
146+
**Choose @voltagent/ollama when:** You want to use models available through Ollama, which provides a convenient local-first framework for running open-source language models. Ollama is well-suited for tasks that benefit from customizable, offline-friendly models, including text generation, lightweight coding tasks, and privacy-sensitive applications.

0 commit comments

Comments
 (0)