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 ↗

언어Dart

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 1 개
  • lints개발 의존성^2.0.0

원본 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.