Search packages, repositories and app categories

Package detailsv1.0.4

ollama

Access Ollama API from Dart

AndroidiOSmacOSWindowsLinux
30-day downloads
394
Likes
32
Pub points
140

Install package

flutter pub add ollama

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The ollama package enables Dart applications to interact with the Ollama API, facilitating integration with local large language models (LLMs). It provides a straightforward interface for sending prompts and receiving responses, ideal for developers building AI-powered features within cross-platform apps. The package supports all major platforms, including Android, iOS, macOS, Windows, and Linux, making it suitable for both mobile and desktop applications. With minimal setup via Flutter pub add, developers can quickly prototype or deploy generative AI functionality using locally hosted models.

Use cases

  • Local LLM integration
  • AI chat applications
  • Text generation in apps
  • Code completion tools
  • Research prototyping

Key features

  • Cross-platform support
  • Simple API interface
  • Supports local model hosting
  • Real-time response handling
  • Easy Flutter integration

Suitable for

  • Flutter developers
  • AI experimenters
  • Local LLM users
  • Full-stack app builders
  • Privacy-focused applications

Considerations

  • Requires Ollama server running locally
  • Limited to Ollama-compatible models
  • Network configuration needed for remote access
  • No built-in model management
  • Dependent on Ollama API stability

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Ollama for Dart

A Dart client for interacting with the Ollama API. This library provides an easy-to-use interface for generating text completions, chat responses, and embeddings using Ollama inference engine.

Features

  • Generate text completions
  • Generate chat responses
  • Generate embeddings
  • Support for streaming responses
  • Customizable model parameters

Installation

Run the following command to install the package:

dart pub add ollama

Usage

Initializing the client
import 'package:ollama/ollama.dart';

final ollama = Ollama();
// Or with a custom base URL:
// final ollama = Ollama(baseUrl: Uri.parse('http://your-ollama-server:11434'));
Generating text completions
final stream = ollama.generate(
  'Tell me a joke about programming',
  model: 'llama3',
);

await for (final chunk in stream) {
  print(chunk.response);
}
Generating chat responses
final messages = [
  ChatMessage(role: 'user', content: 'Hello, how are you?'),
];

final stream = ollama.chat(
  messages,
  model: 'llama3',
);

await for (final chunk in stream) {
  print(chunk.message?.content);
}
Generating embeddings
final embeddings = await ollama.embeddings(
  'Here is an article about llamas...',
  model: 'llama3',
);

print(embeddings);

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Categories

Source repository

Projects using this package

No data available yet.