v1.0.4
ollama
從 Dart 訪問 Ollama API
32喜歡 138近 30 天下載140Pub 分數
AndroidiOSmacOSWindowsLinux
直接從 Dart 使用 Ollama 的 LLM
^2.0.0以下為英文專案原文快照,最新內容請造訪 GitHub。
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.
Run the following command to install the package:
dart pub add ollama
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'));
final stream = ollama.generate(
'Tell me a joke about programming',
model: 'llama3',
);
await for (final chunk in stream) {
print(chunk.response);
}
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);
}
final embeddings = await ollama.embeddings(
'Here is an article about llamas...',
model: 'llama3',
);
print(embeddings);
Contributions are welcome! Please feel free to submit a Pull Request.