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

パッケージ詳細v1.1.0

flutter_chatgpt_api

非公式 ChatGPT API 用の ChatGPT 囲みの Flutter/Dart API。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
93
いいね数
100
Pub ポイント
130

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

flutter pub add flutter_chatgpt_api

パッケージ概要

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

非公式のChatGPT API用のシンプルなAPIラッパーを提供するFlutter/Dartパッケージで、開発者がFlutterアプリにChatGPT機能を統合できるようにします。Android、iOS、macOS、Windows、Linuxなど複数のプラットフォームをサポートしています。低レベルのHTTP操作を抽象化し、ChatGPTへのメッセージ送信と応答受信を簡単なインターフェースで行えるようにしています。公式APIに依存せずに会話型AI機能が必要なアプリに最適です。

用途

  • モバイルアプリへのチャットボットの統合
  • AI駆動のカスタマーサポートツールの構築
  • インタラクティブな学習アプリケーションの作成
  • アプリでのリアルタイムテキスト生成の有効化

主な機能

  • 非公式 ChatGPT API 統合
  • クロスプラットフォーム対応
  • シンプルな同期および非同期メッセージ処理
  • 組み込みエラー処理
  • 軽量で設置が簡単

適している対象

  • AIチャット機能を開発する開発者
  • 生成型AIアプリケーションのプロトタイピング
  • ChatGPTのような応答に素早くアクセスが必要なアプリ

注意事項

  • 非公式APIに依存しています(不安定または終了する可能性があります)
  • 公式のGoogle / Apple承認なし
  • レート制限と潜在的なIPブロッキング
  • 有効な認証トークンが必要です

元の README

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

Flutter ChatGPT API

This package is a Flutter/Dart API around ChatGPT by OpenAI.

This package requires a valid session token from ChatGPT to access its unofficial REST API.

This version have been updated to use Puppeteer to log in to ChatGPT and extract the Cloudflare cf_clearance cookie and OpenAI session token. 🔥 Thanks to Node.js ChatGPT API (unofficial)

:warning: Be Careful!

  • Your user-agent and IP address must match from the real browser window you're logged in with to the one you're using for ChatGPTAPI.
    • This means that you currently can't log in with your laptop and then run the bot on a server or proxy somewhere.
  • Please check defaultHeaders

Demo

Installation

dependencies:
  flutter_chatgpt_api: ^1.0.0

Usage


import 'package:flutter_chatgpt_api/flutter_chatgpt_api.dart';

 _api = ChatGPTApi(
       sessionToken: SESSION_TOKEN,
       clearanceToken: CLEARANCE_TOKEN,
     );

setState(() {
  _messages.add(
    ChatMessage(
      text: _textController.text,
      chatMessageType: ChatMessageType.user,
    ),
  );
  isLoading = true;
});  

var newMessage = await _api.sendMessage(
  input,
  conversationId: _conversationId,
  parentMessageId: _parentMessageId,
);

setState(() {
  _conversationId = newMessage.conversationId;
  _parentMessageId = newMessage.messageId;
  isLoading = false;
  _messages.add(
    ChatMessage(
      text: newMessage.message,
      chatMessageType: ChatMessageType.bot,
    ),
  );
});

SessionToken

To get a session token:

  1. Go to https://chat.openai.com/chat and log in or sign up.
  2. Open dev tools.
  3. Open Application > Cookies (Storage > Cookies)

image

  1. Create these files and add your session token to run the tests and example respectively:

Copy the value for __Secure-next-auth.session-token and save it to your environment.example/lib/session_token.dart

Copy the value for cf_clearance and save it to your environment. example/lib/clearance_token.dart

Should look something like this:

const SESSION_TOKEN = '__Secure-next-auth.session-token from https://chat.openai.com/chat';
const CLEARANCE_TOKEN = 'cf_clearance token from https://chat.openai.com/chat';

Credit

License

MIT Copyright (c) 2022, Emre Coşkunçay

If you found this project interesting, please consider supporting my open source work by sponsoring me or following me on twitter twitter

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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

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