パッケージ、リポジトリ、アプリカテゴリを検索

chatgpt_completions のカバー
パッケージ詳細v1.0.4

chatgpt_completions

非公式のChatGPT API用のDartクライアント。v1/completionsからのテキスト補完およびストリーム応答をサポートしています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
231
いいね数
42
Pub ポイント
120

パッケージをインストール

flutter pub add chatgpt_completions

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

非公式な ChatGPT API 用の Dart クライアントで、v1/completions エンドポイントを介してテキスト補完とストリーミング応答を可能にします。Flutter アプリ向けに設計されており、Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームをサポートしています。このパッケージは、ChatGPT のテキスト生成機能との統合を簡略化し、開発者がリアルタイムで AI 生成コンテンツを取得できるようにします。チャットインターフェース、コンテンツアシスタント、自然言語処理が必要なインタラクティブアプリに最適です。

用途

  • リアルタイムチャットアプリケーション
  • AI駆動のコンテンツ生成
  • インタラクティブな学習ツール
  • 自動応答システム
  • コード提案機能

主な機能

  • テキスト補完をサポートしています
  • リアルタイムで応答をストリーミング
  • クロスプラットフォーム互換性
  • シンプルなAPIインターフェース
  • 公式ではないが機能的なChatGPTへのアクセス

適している対象

  • AIチャット機能を構築するFlutter開発者
  • リアルタイムでのテキスト生成を必要とするアプリ
  • 迅速なAI統合を必要とするプロトタイプ

注意事項

  • 非公式API—更新で動作しなくなる可能性があります
  • レート制限と安定性は外部サービスに依存します
  • OpenAIからの公式サポートなし
  • APIキーの管理が必要です
  • 完了エンドポイントに限定され、完全なチャット履歴は含まれない

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

serverPubfilesLicensePRs Welcome

Dart client for the unofficial ChatGPT API. Support Text Completeion and stream response from v1/completions.

Features

  • Text completions without stream response
  • Text completions with stream response

Getting started

  • Install package
flutter pub add chatgpt_completions

Usage

  • Initialize instance
/// Generate api key from openai console: https://platform.openai.com/account/api-keys
ChatGPTCompletions.instance.initialize(apiKey: "api_key_here");
  • Text completions without stream response (stream: false)
String? responseWithoutStream =
      await ChatGPTCompletions.instance.textCompletions(TextCompletionsParams(
    prompt: "What's Flutter?",
    model: GPTModel.davinci,
    temperature: 0.2,
    topP: 1,
    n: 1,
    stream: false,
    maxTokens: 2048,
));

print("OpenAI: $responseWithoutStream");
  • Text completions with stream response (stream: true)
StreamSubscription? responseSubscription;

await ChatGPTCompletions.instance.textCompletions(
    TextCompletionsParams(
      prompt: "What's Flutter?",
      model: GPTModel.davinci,
      temperature: 0.2,
      topP: 1,
      n: 1,
      stream: true, // --> set this is true
      maxTokens: 2048,
    ),
    onStreamValue: (characters) {
      responseWithStream += characters;
      print(responseWithStream);
    },
    onStreamCreated: (subscription) {
      responseSubscription = subscription;
    },
);
  • Stop generating (with stream)
responseSubscription?.cancel();
  • Using model gpt-3.5-turbo/gpt-4
// Using GPT-3.5-Turbo
await ChatGPTCompletions.instance.textCompletions(
  TextCompletionsParams(
    // using messagesTurbo insteal of prompt
    messagesTurbo: [
      MessageTurbo(
        role: TurboRole.user,
        content: "What's Flutter?",
      ),
    ],
    model: GPTModel.gpt3p5turbo, // --> switch to gpt-3.5-turbo model
  ),
  onStreamValue: (characters) {
    responseWithStream += characters;
    print(responseWithStream);
  },
  onStreamCreated: (subscription) {
    responseSubscription = subscription;
  },
  // Debounce 100ms for receive next value
  debounce: const Duration(milliseconds: 100),
);

License - lambiengcode

MIT License

Copyright (c) 2023 lambiengcode

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。