FLUTTER ECOSYSTEM

breitburg/dart-ollama

直接從 Dart 使用 Ollama 的 LLM

dart-ollama 專案封面
Stars
44
Forks
4
最近推送(UTC)
2024年8月4日
專案狀態
未封存
Ilia Breitburg GitHub avatar
GITHUB User

Ilia Breitburg ↗

@wesprint-io官方網站 ↗
語言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.