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

套件詳情v1.0.0

flutter_ai_toolkit

適用於行動、桌面和網頁的 Flutter 應用的 AI 聊天小工具,支援文字、圖片和語音輸入。

AndroidiOSWebmacOS
近 30 天下載
1.2萬
喜歡數
246
Pub 分數
140

安裝套件

flutter pub add flutter_ai_toolkit

套件介紹

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

Flutter AI Toolkit 是一個多功能的 AI 驅動聊天元件,專為跨行動、桌面與 Web 平台的 Flutter 應用設計。它支援文字、影像與語音輸入,能無縫整合生成式 AI 功能。此工具包專為希望提升使用者互動體驗、打造智慧對話介面的開發者所設計,可簡化將先進 AI 功能嵌入應用程式的過程,且無需複雜設定。它採用現代大型語言模型(LLM),並提供即時回應,非常適合用於聊天機器人、虛擬助理與互動內容工具。該套件由 Flutter Labs 維護,並公開於 GitHub,確保透明度並促進社群貢獻。

適用情境

  • AI 驅動的客戶支援
  • 互動學習應用
  • 支援語音的虛擬助理
  • 內容生成工具
  • 即時協作聊天

主要特色

  • 支援文字、圖片和語音輸入
  • 跨平台相容性
  • 即時AI回應
  • 與 Flutter 的輕鬆整合
  • 聊天介面的內建UI元件

適合對象

  • 開發AI聊天功能的開發者
  • 教育類應用程式創作者
  • 客戶服務應用團隊
  • 生產力工具建構者
  • Web 和移動應用初創公司

使用建議

  • 需要後端AI服務整合
  • 可能需要針對特定的大型語言模型進行客製化
  • 性能取決於網路速度
  • 有限的離線功能
  • 依賴外部API的可用性

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

package:flutter_ai_toolkit pub package package publisher

Hello and welcome to the Flutter AI Toolkit!

The AI Toolkit is a set of AI chat-related widgets to make it easy to add an AI chat window to your Flutter app. The AI Toolkit is organized around an abstract LLM provider API that makes it easy to swap out the LLM provider that you'd like your chat provider to use. Out of the box, it comes with support for one LLM provider integration: Firebase AI.

Key features

  • Multi-turn chat: Maintains context across multiple interactions.
  • Streaming responses: Displays AI responses in real-time as they're generated.
  • Rich text display: Supports formatted text in chat messages.
  • Voice input: Allows users to input prompts using speech.
  • Multimedia attachments: Enables sending and receiving various media types.
  • Custom styling: Offers extensive customization to match your app's design.
  • Chat serialization/deserialization: Store and retrieve conversations between app sessions.
  • Pluggable LLM support: Implement a simple interface to plug in your own LLM.
  • Cross-platform support: Compatible with the Android, iOS, web, and macOS platforms.

Getting started

  1. Installation

    Add the following dependencies to your pubspec.yaml file:

    $ flutter pub add flutter_ai_toolkit firebase_ai firebase_core
    
  2. Configuration

    To use Firebase AI in your project, follow the steps described in Get started with the Gemini API using the Firebase AI Logic SDKs.

    After following these instructions, you're ready to use Firebase AI in your Flutter app. Start by initializing Firebase:

    import 'package:firebase_core/firebase_core.dart';
    import 'package:firebase_vertexai/firebase_ai.dart';
    import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';
    
    // Other app imports...
    
    import 'firebase_options.dart'; // Generated by `flutterfire config`.
    
    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
      runApp(const App());
    }
    
    // Implementation of App and other widgets...
    

    With Firebase properly initialized in your Flutter app, you're now ready to create an instance of the Firebase provider:

    class ChatPage extends StatelessWidget {
      const ChatPage({super.key});
    
      @override
      Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text(App.title)),
        body: LlmChatView(
          provider: FirebaseProvider(
            model: FirebaseAI.vertexAI().generativeModel(
              model: 'gemini-2.0-flash'
            ),
          ),
        ),
      );
    }
    

    The FirebaseAI class comes from the firebase_ai package. The AI Toolkit provides the FirebaseProvider class to expose Firebase AI to the LlmChatView. Note that you provide a model name that corresponds to one of the available model names.

    For a complete usage example, check out the vertex.dart sample.

  3. Set up device permissions

To enable your users to take advantage of features like voice input and media attachments, ensure that your app has the necessary permissions:

  • Network access:

To enable network access on macOS, add the following to your *.entitlements files:

<plist version="1.0">
    <dict>
      ...
      <key>com.apple.security.network.client</key>
      <true/>
    </dict>
</plist>

To enable network access on Android, ensure that your AndroidManifest.xml file contains the following:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    ...
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>
  • Microphone access: To enable voice input for users, update configs according to the permission and setup instructions for package:record.

  • File selection: To enable users to select and attach files, follow the usage instructions for package:file_selector.

  • Image selection: To enable users to take or select a picture from their device, refer to the installation instructions for package:image_picker.

Samples

To run the example apps in the example/lib directory, first replace the example/lib/firebase_options.dart file by running flutterfire config (you may need to manually delete this file first). The provided firebase_options.dart file is a placeholder for configuration needed by the examples.

Breaking changes and migration

The v0.9.8 release contained breaking changes. If you have code that uses a version prior to that, please see the migration notes.

Feedback

As you use this package, please log issues and feature requests as well as submit any code you'd like to contribute. We want your feedback and contributions to ensure that the AI Toolkit is as robust and useful as it can be for your real-world apps.

所屬分類

依賴

依賴清單 13 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。