搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.4

ollama

從 Dart 訪問 Ollama API

AndroidiOSmacOSWindowsLinux
近 30 天下載
394
喜歡數
32
Pub 分數
140

安裝套件

flutter pub add ollama

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

ollama 套件讓 Dart 應用程式能與 Ollama API 互動,促進與本地大型語言模型(LLM)的整合。它提供一個簡單的介面,用於傳送提示並接收回應,非常適合開發人員在跨平台應用中建構 AI 功能。此套件支援所有主要平台,包括 Android、iOS、macOS、Windows 和 Linux,適用於行動與桌面應用程式。透過 Flutter pub add 進行最少設定,開發者可快速建立原型或部署使用本地主機模型的生成式 AI 功能。

適用情境

  • 本地大語言模型整合
  • AI聊天應用
  • 應用中的文字生成
  • 程式碼補全工具
  • 研究原型

主要特色

  • 跨平台支援
  • 簡單 API 接口
  • 支援本地模型託管
  • 即時回應處理
  • 輕鬆整合 Flutter

適合對象

  • Flutter 開發者
  • AI實驗者
  • 本地 LLM 使用者
  • 全-stack 應用程式建構者
  • 注重隱私的應用程式

使用建議

  • 需要本地運行的 Ollama 伺服器
  • 僅限相容 Ollama 的模型
  • 遠端存取所需的網路設定
  • 無內建模型管理
  • 依賴於 Ollama API 的穩定性

原始 README

以下為關聯原始碼儲存庫的 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。