FLUTTER ECOSYSTEM

breitburg/dart-ollama

DartからOllamaのLLMを直接使用する

dart-ollama のプロジェクト画像
Stars
44
Forks
4
最終プッシュ(UTC)
2024/08/04
プロジェクト状態
公開中
Ilia Breitburg GitHub avatar
GITHUB User

Ilia Breitburg ↗

言語Dart

技術トピック

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 1 件

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

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.